hey perl DB coders

Non-Disc Golf Stuff

Moderators: Timko, Solty, Frank Delicious, Blake_T, Fritz, Booter

hey perl DB coders

Postby SkaBob » Thu Feb 18, 2010 3:20 pm

How can I insert a null value when using positional parameters?

Code: Select all
my $sql = 'INSERT INTO foo (col1, col2) VALUES (?, ?)';
my $sth = $dbh->prepare($sql);
my $rc = $sth->execute($var1, $var2);


What can I put in the values of $var1 or $var2 above if I want to insert a null, rather than the string 'NULL', which tends to go asplodey when the column is an int or bool, or other non-text field?
I threw Wizards before they were cool.
SkaBob
Disc Whore
 
Posts: 3493
Joined: Fri Mar 16, 2007 9:51 am
Location: Detroit
Favorite Disc: Comet

Re: hey perl DB coders

Postby SkaBob » Thu Feb 18, 2010 3:36 pm

n/m...solved it myself. Passing undef works.
I threw Wizards before they were cool.
SkaBob
Disc Whore
 
Posts: 3493
Joined: Fri Mar 16, 2007 9:51 am
Location: Detroit
Favorite Disc: Comet


Return to Off-Topic, Miscellaneous, etc.

Who is online

Users browsing this forum: No registered users and 1 guest

cron