On Apr 8, 4:14 am, [EMAIL PROTECTED] (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

Reply via email to