Try printing out the SQL command and run it in db if you still can't see the
error.  Evidentally dome part of your produced SQL is not right, see exactly
what sql is, you can use trace() to also help in determining.  Not sure if
ODBC supports, but you can also print out

$sth->{Statement} after all your bind_param and see what the statement looks
like then.

Ilya Sterin

-----Original Message-----
From: Matt [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 09, 2001 10:35 AM
To: [EMAIL PROTECTED]
Subject: Fw: dbi script error



----- Original Message -----
From: "Matt" <[EMAIL PROTECTED]>
To: "Perl Win32 db" <[EMAIL PROTECTED]>
Sent: Friday, March 09, 2001 5:28 PM
Subject: dbi script error


> Hi
>
> I've pieced together a script to take data out of a access 97 mdb and
insert
> into a ms-sql 6.5 db, however I keep getting a sql syntax error. This is
the
> first time I've done anything like this and I'm stumped. The code looks as
> follows:
>
> my $sql = qq{ SELECT KioskNumber, AccTime, DetailID, DetailNo,
> MiniAdsCounter, NormalCounter FROM Statistics };
> my $sth = $dbh->prepare( $sql );
> $sth->execute();
>
> my( $KioskNumber, $AccTime, $DetailID, $DetailNo, $MiniAdsCounter,
> $NormalCounter );
> $sth->bind_columns( \$KioskNumber, \$AccTime, \$DetailID, \$DetailNo,
> \$MiniAdsCounter, \$NormalCounter );
>
> while( $sth->fetch() ) {
>  print "$KioskNumber, $AccTime, $DetailID, $DetailNo, $MiniAdsCounter,
> $NormalCounter\n";
>
> my $insert_handle = $dbh2->prepare_cached("INSERT INTO Stats VALUES
> (CONVERT(int,?)), ?, ?, (CONVERT(numeric,?)), (CONVERT(numeric,?)),
> (CONVERT(numeric0,?))");
>
> $insert_handle->bind_param(1, $KioskNumber, SQL_INTEGER);
> $insert_handle->bind_param(2, $AccTime );
> $insert_handle->bind_param(3, $DetailID );
> $insert_handle->bind_param(4, $DetailNo, SQL_INTEGER);
> $insert_handle->bind_param(5, $MiniAdsCounter, SQL_INTEGER);
> $insert_handle->bind_param(6, $NormalCounter, SQL_INTEGER);
>
> $insert_handle->execute($KioskNumber, $AccTime, $DetailID, $DetailNo,
> $MiniAdsCounter, $NormalCounter) or die $dbh2->errstr;
>
> And here is the output with the error:
>
> E:\AStatsTest>perl -w test5.pl
> Scanning for files of type .mdb
> e:\astatstest\newstats031000.mdb
> driver=Microsoft Access Driver
(*.mdb);dbq=e:\astatstest\newstats031000.mdb
> 220, 2000-10-02 15:13:54, Welcome to TranZact, -1, 0, 1
> DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver][SQL
> Server]Line 1:
> Incorrect syntax near ','. (SQL-37000)(DBD: st_execute/SQLExecute err=-1)
at
> test5.pl line 71.
>
> Can anyone please give me some idea of what I'm doing wrong.
>
> regards
>
> Matt
>

Reply via email to