Thanks Dave. Worked like a charm. Next up is my 'update' question, but that
will have to wait :)

-R-
----- Original Message -----
From: David Kirol <[EMAIL PROTECTED]>
To: robert pimentel <[EMAIL PROTECTED]>
Sent: Friday, April 19, 2002 2:32 PM
Subject: RE: Keyword "date" instigating error


> Try this:
> my $sth = $dbh->prepare(qq(
> INSERT into $tbl
> (employe, project_no, po, etiq_inv, "date") VALUES (?, ?, ?, ?, ?))) or
....
> I'm not sure this will work with your DBMS but Oracle and MySql will let
you
> use reserved words, spaces embedded in column names etc if quoted AND qq()
> will respect them.
> HTH
>
> -----Original Message-----
> From: robert pimentel [mailto:[EMAIL PROTECTED]]
> Sent: Friday, April 19, 2002 3:17 PM
> To: [EMAIL PROTECTED]
> Subject: Keyword "date" instigating error
>
>
> Hello,
>
> Windows NT (sp6)
> Access 2000 (9.0.3821 SR-1)
> Access Driver 4.00.4403.02 (May be slightly outdated (8/8/99))
> Perl 5.6.1
> DBI 1.1.4
> DBD-ODBC 0.28
>
>
> The following error occurs when I attempt an insert...
>
> [
> Couldn't execute insert statement: [Microsoft][ODBC Microsoft Access
Driver]
> Syntax error in INSERT INTO statement. (SQL-37000)(DBD:
> st_execute/SQLExecute err=-1)
> ]
>
> I found the problem is tied to the "date" field. Here's a snippet...
>
> [
>  my $sth = $dbh->prepare("INSERT into $tbl (employe, project_no, po,
> etiq_inv, date) VALUES (?, ?, ?, ?, ?)")
>      or &debug_Print("Couldn't prepare insert statement: $DBI::errstr\n")
&&
> return(0);
>
>  $sth->bind_param(1, $employe);
>  $sth->bind_param(2, $project_no);
>  $sth->bind_param(3, $po);
>  $sth->bind_param(4, $invent);
>  $sth->bind_param(5, $date);    ### , {TYPE => SQL_DATE});
> ]
>
> Notice the column name in the table is named 'date'. I think that's where
> the conflict exists.
> I've tried passing my values in the execute ($employe, $project_no, etc),
> because that will essentially bind them for me. Same result.
> As you can see, I also tried defining the SQL datatype, no luck.
> I also tried using an alternate name for my var ($date2) in case that was
> the problem.
>
> 1) Any ideas?
>
> Quick, second, unrelated question :)
>
> 2)  I mostly use 'qq' before preparing my statements. Unnecessary, when
> using bound parameters correct? Is there risk involved, or is it simply
> overkill??
>
> [
> my $sql = qq{ (INSERT into $tbl (employe, project_no) VALUES (?, ?))};
> my $sth = $dbh->prepare($sql)
> ......
> ]
>
> Thanks,
>
> -R-
>

Reply via email to