Reputation: 668
Getting error while executing the stored procedure from perl. I am able to connect to the MS SQL server from perl without any issues. But when I execute the procedure with the following binding parameters I am getting the error
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '@id'. (SQL-42000)
this 'id' is the first parameter. When I look at the procedure it is fine. Anyone have any thoughts on this error?
Code
#GetStatusDescription(?, ?, ?) - id - LONG, status - VARCHAR, description - VARCHAR
my $sth = $dbh -> prepare('exec GetStatusDescription(?, ?, ?)');
my $str1, my $str2;
my $intid = 11122;
use DBI qw(:sql_types);
$sth->bind_param(1, $intid, DBI::SQL_INTEGER);
$sth->bind_param_inout(2, \$str1, DBI::SQL_VARCHAR);
$sth->bind_param_inout(3, \$str2, DBI::SQL_VARCHAR);
$sth->execute() or die $dbh -> errstr;
Upvotes: 1
Views: 2098
Reputation: 32717
If you're calling to a stored procedure, those don't take parentheses in SQL Server. that is, you want:
my $sth = $dbh -> prepare('exec GetStatusDescription ?, ?, ?');
Upvotes: 3