manoorani has asked for the wisdom of the Perl Monks concerning the following question:

My test code as follows gives an error. Any idea or anybody know where I can find the meaning of the error code I am getting. Thanks
use strict; use Win32::ODBC; my $DSN = "DRIVER=Microsoft Access Driver (*.mdb);FIL=MSAccess;DriverI +d=25;DBQ=c:\\perlscript\\NOTICE.mdb"; my $db; my $query = "INSERT INTO logfile ({Date Send}, {Certificate file} ) VALUES ('01/01/02' 'junk')"; if (!($db = new Win32::ODBC($DSN))) { print "Error connecting to $DSN\n"; print "Error: " . Win32::ODBC::Error() . "\n"; } if ( $db->Sql($query)) { print "error executing query [ \"$query\" ]\n"; print "Error: " . Win32::ODBC::Error() . "\n"; } $db->Close();
error executing query "INSERT INTO logfile ( {Date Send}, {Certificate file} ) VALUES ('01/01/02' 'junk')" Error: -3502 1 "MicrosoftODBC Microsoft Access Driver Syntax error in IN SERT INTO statement."

Replies are listed 'Best First'.
Re: Add record in access table
by MZSanford (Curate) on Feb 08, 2002 at 16:55 UTC
    When using DBD::ODBC you need to use ODBC Standard SQL. I have used this for accessing diffrent ODBC databases, and i believe the following will work (but it is untested) :
    my $query = q! INSERT INTO logfile ("Date Send","Certificate file") VALUES ({d '2002-01-01'},'junk') !; # other code here
    Sorry, but on my current machine i dont have the ability to test this code :/. Win32 Perl Programming : The Standard Extensions covers some of the ODBC specific SQL stuff.
    from the frivolous to the serious
      Thanks that worked. Appreciate it.
Re: Add record in access table
by gellyfish (Monsignor) on Feb 08, 2002 at 16:54 UTC

    INSERT INTO logfile ({Date Send}, {Certificate file} ) VALUES ('01/01/02' 'junk')

    Shouldn't those {Date Send} and {certificate file} be in square rather than curly brackets ?

    /J\