On Fri, 11 Jan 2002 14:36:40 -0500 (EST)
"Ronnie Anderson" <[EMAIL PROTECTED]> wrote:
> my $hosthandler = $dbh->prepare(q{
> SELECT id
> FROM host
> WHERE tid = ?
> AND (domain = ? OR (? IS NULL AND domain IS NULL))
> AND (subdom = ? OR (? IS NULL AND subdom IS NULL))
> AND (misc = ? OR (? IS NULL AND misc IS NULL))
> }) or die "Couldn't prepare statement: $DBI::errstr;
> stopped";
>
> $hosthandler->execute
> ($tid,$DOMAIN,$DOMAIN,$SUBDOM,$SUBDOM,$MISC,$MISC);
>
> $DOMAIN,$SUBDOM,$MISC can all be either strings or
> NULLs. I've tried turning the word "NULL" into "undef"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> for each of these without luck. Running the query
> manually against MySQL works just fine.
>
> What am I doing wrong?
>
Hmm ... if I'm reading you correctly, you are expecting this to work:
$DOMAIN = "NULL";
....
$hosthandler->execute( ... );
But in fact, the NULL test wants 'undef's, not strings.
$DOMAIN = undef; # or 'undef $DOMAIN;'
....
--
Jeff Boes vox 616.226.9550
Database Engineer fax 616.349.9076
Nexcerpt, Inc. [EMAIL PROTECTED]