christopherbarsuk has asked for the wisdom of the Perl Monks concerning the following question:
Let's say I have an array, @values = ( 'test', 'Now()' ), and I build an SQL statement like this: INSERT INTO test ( Name, EntryDate ) VALUES ( ?, ? ).
If I call prepare and execute (passing the SQL statement to prepare, and @values to execute), the date that actually gets inserted into EntryDate is null. This, I've determined, is because execute is passing the value as a string ( "Now()" ) rather than a bare word ( Now() ).
If I call prepare, then bind_param( 2, $values[1], SQL_DATE ), I get the same result. This, I presume, is because the database driver only distinguishes character and integers, and treats the SQL_DATE type like a character.
If I call bind_param( 2, $values[1], SQL_INTEGER ), then everything works fine.
So here's my question: Is this what I've got to do, or is there something I'm overlooking, some easier/better way of doing it?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI placeholders, bind_values, and SQL_DATE
by runrig (Abbot) on Aug 16, 2001 at 00:33 UTC | |
|
Re: DBI placeholders, bind_values, and SQL_DATE
by dga (Hermit) on Aug 16, 2001 at 00:45 UTC | |
|
Re: DBI placeholders, bind_values, and SQL_DATE
by tune (Curate) on Aug 16, 2001 at 20:11 UTC | |
by christopherbarsuk (Acolyte) on Aug 16, 2001 at 23:21 UTC | |
by chipmunk (Parson) on Aug 16, 2001 at 23:51 UTC | |
by dga (Hermit) on Aug 17, 2001 at 01:11 UTC |