Hello
I'm trying to write a function that returns the id of an inserted col. Here's the code I have so far:
Code:
## sqlInsert: takes a table and a value and inserts the value into the table, returns the id.
sub sqlInsert(){
my($table,$values) = @_;
my $qry = $dbh->prepare("DECLARE @GUID uniqueidentifier;
SET @GUID = newid();
INSERT INTO scans VALUES (@GUID, '2009-07-23');
SELECT @GUID");
$qry->execute();
return $qry->fetchrow_array;
}
Here's how I'm connecting to the database:
Code:
use DBI;
...
## Connect to the database!
my $dbh = DBI->connect("dbi:ODBC:$dsn",$usr,$pss);
And I'm getting the following error:
DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver] Incorrect syntax near ';'.
DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver] Incorrect syntax near ','.
DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver] Statement(s) could not be prepared.
Anybody know what I'm doing wrong? Thanks
