Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm, apache force chunked, nrao wwwxxx, xxxxxdup, procmail change subject header, wwwXxx not20, Wwwxxx.doks sas, linux raid resync after reboot

Links

XODOX
Impressum

#1: Returning null from query

Posted on 2008-04-08 01:41:08 by bcfd36

This should be simple. Either it can't be done, I'm using the wrong
syntax, or using the wrong approach.

I'm running a perl script that queries the db, and gets back an
answer. That works just fine. However, on occasion one of the returned
values is null since it is null in the data base. I tried sending a
"set null null" the same way I sent the select command, but it
generated an error:"missing or invalid option. Were I directly in
sqlplus, I could say "set null null" and a string with "null" in it
would be returned.

Any suggestions?

D. Scruggs
Lockhkeed Martin, Sunnyvale Ca.

Report this message

#2: Re: Returning null from query

Posted on 2008-04-08 11:14:42 by Johannes.Gritsch

BCFD36 wrote:
> This should be simple. Either it can't be done, I'm using the wrong
> syntax, or using the wrong approach.
>
> I'm running a perl script that queries the db, and gets back an
> answer. That works just fine. However, on occasion one of the returned
> values is null since it is null in the data base. I tried sending a
> "set null null" the same way I sent the select command, but it
> generated an error:"missing or invalid option. Were I directly in
> sqlplus, I could say "set null null" and a string with "null" in it
> would be returned.
>
> Any suggestions?
>
> D. Scruggs
> Lockhkeed Martin, Sunnyvale Ca.
>
>
The command "SET" is a builtin command of sqlplus, not a valid SQL
command. Thus the database does not understand it. You eiher could use
the SQL-function NVL to circumvent NULLs or check within Perl with
'defined'.

HTH
Hannes

--
Johannes Gritsch
www.linuxification.at

Report this message

#3: Re: Returning null from query

Posted on 2008-04-08 18:12:17 by pgodfrin

On Apr 8, 4:14 am, Johannes.Grit...@gnc.at (Johannes Gritsch) wrote:
> BCFD36 wrote:
> > This should be simple. Either it can't be done, I'm using the wrong
> > syntax, or using the wrong approach.
>
> > I'm running a perl script that queries the db, and gets back an
> > answer. That works just fine. However, on occasion one of the returned
> > values is null since it is null in the data base. I tried sending a
> > "set null null" the same way I sent the select command, but it
> > generated an error:"missing or invalid option. Were I directly in
> > sqlplus, I could say "set null null" and a string with "null" in it
> > would be returned.
>
> > Any suggestions?
>
> > D. Scruggs
> > Lockhkeed Martin, Sunnyvale Ca.
>
> The command "SET" is a builtin command of sqlplus, not a valid SQL
> command. Thus the database does not understand it. You eiher could use
> the SQL-function NVL to circumvent NULLs or check within Perl with
> 'defined'.
>
> HTH
> Hannes
>
> --
> Johannes Gritschwww.linuxification.at

I believe DBI sets the variable undef if a null value is found. So -
you could either test for undef or you can run a quick loop:

foreach (@$array_ref) { $_ = 'null' unless defined }

This uses an array_ref, which makes the loop possible (an array should
work here too), so if you're using bind_columns you'll need to test
for undef or so something else.

phil

Report this message