On Fri, 29 Nov 2002 10:37:59 -0800 Eric <[EMAIL PROTECTED]> wrote:

> Using DBI 1.30 on FreeBSD 4.6 with mySQL 4.04, DBD::mysql 2.0416, and
> Perl 5.06
> 
> Is it possible to insert a NULL with query like this?
> 
> $insert = qq!
> 
> INSERT INTO blah a,b,c VALUES (?,?,?)
> 
> !;
>         
> $insert_hnd = $dbh->prepare($insert_orders);
> 
> $insert_hnd->execute($var1,$var2,$var3);
> 
> 
> 
> Ok, so I have three vars to place in my execute statement, how can I
> make 
> one of them at least potentially insert a NULL?
> 
> 
> Or is there no way to do this with this form?
> I am trying to keep some logic out of a query module, but I can't get this 
> to work. Most of the time $var3 will have data. Some of the time it needs 
> to be left NULL.  Setting $var3 = 'NULL' or '"" doesn't work. What if I 
> undef ed $var3?

Try it and see.

The undef/NULL relationship is mentioned several times in the fine DBI
manual.  Specifics for mysql are in the fine DBD::mysql manual.

http://xmlproj.com/fom-serve/cache/49.html

-- 
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.


Reply via email to