Testing null handling in DBD::Informix 2004.02 (pre-release), I'm
getting a warning from Perl:

Use of uninitialized value in subroutine entry at t/t91udts.t line 97.

OK - it's a valid comment: the code reads:

$sth->execute(2, undef, undef, ..., undef) or stmt_fail;

There are actually 12 undef's in the real code - to insert 12 SQL NULL
non-values into a table with 13 columns (the first column refuses
nulls, hence the 2 in the argument list).

How am I supposed to pass SQL NULL values into $sth->execute?

The original version of the code looked like this, but gave the same warning:

my($null);
undef $null;
$sth->execute(2, $null, $null, ..., $null) or stmt_fail;

(I also tried my(@vals) = (2, undef, undef, ..., undef);
$sth->execute(@vals);  with no joy.)

I tested Perl 5.6.1, 5.8.0, 5.8.6 with the same result -- it's clearly
been a while since I looked at this stuff carefully.

Is there a decent workaround?  Especially one that would permit me to
put a non-null value after a sequence of nulls in the argument list.

(I'm also slightly puzzled about the source of the error message.  I
don't get the message when I simulate it with the trivial Perl script:

sub x { my(@v) = @_; }
x(2, undef);

With or without -w in effect, with or without a 'use strict;' in the
code.  However, I can't find the text in DBI, so it is presumably
generated by Perl - but under what circumstances?)

I'm using DBI 1.46 mainly, but also one copy of DBI 1.42.

(Tim, I had a faintly related question about a change in behaviour
with DBI and Perl 5.61 -- did you get to see that?  I sent it to
[EMAIL PROTECTED] from work, but I'm not sure if it went to the list. 
The copy I sent myself directly to gmail got there, but I'm not sure I
saw the list version.)

-- 
Jonathan Leffler <[EMAIL PROTECTED]>  #include <disclaimer.h>
Guardian of DBD::Informix - v2003.04 - http://dbi.perl.org
"I don't suffer from insanity - I enjoy every minute of it."

Reply via email to