Ronald,
I came to that epiphony about 1sec before reading your email. I
was quoting before using the bind_param because I had some intermediate
queries that pulled from this same pool of data. Unfortunately with the
setup I have, the program SEGV's when I try to pass an undef to
execute. Since I cannot change the version of Perl and DBI/DBD::Sybase,
I'll have to think of another way around this which will ultimately make
the code look like garbage.
Thanks for the info anyway, though.
--Curt
On Mon, 30 Apr 2001, Ronald J Kimball wrote:
> On Sun, Apr 29, 2001 at 04:22:08PM -0400, Curt Russell Crandall wrote:
> > I'm getting conversion errors (VARCHAR to [SMALL]DATETIME) on an
> > insert. I have a structure that contains a list of params that need to be
> > inserted into a db table. Prior to insertion, I make sure that undef
> > values are treated as SQL NULLs:
> >
> > for (my $i = 0; $i <= $#array; $i++)
> > {
> > if ((!DBI::looks_like_number($array[$i]) && (!$array[$i]))
> > {
> > $array[$i] = $dbh->quote($array[$i];
> > }
> > }
> >
> >
> > Then I go through and use bind_param on all the array members, specifying
> > each params SQL data type:
> >
> > $sth->bind_param(1, \$array[0], SQL_DATE);
> > ....
> >
>
> You should use either $dbh->quote() OR $sth->bind_param(). If you use
> both, then you are inserting the literal string 'NULL', not the special SQL
> value NULL. With placeholders, the quoting is handled automatically.
>
> Ronald
>