lhoward has asked for the wisdom of the Perl Monks concerning the following question:
I'm running ActiveState perl 5.6.0 on Windows 2000. I'm using DBD::ODBC to connect to an SQLServer 200 DB on the same host. The problem comes when I want to call a stored procedure and one of the arguments I want to pass to it contains a single quote. I've tried all the ways I know of to get around the escaping problem:
$dbh->do('exec sp_MyStoredProg @foo=' . $dbh->quote($bar));
$bar=~s/'/''/g; $dbh->do("exec sp_MyStoredProg \@foo='$bar'");
my $sth=$dbh->prepare('exec sp_MyStoredProg @foo=?'); $sth->execute($bar);
I believe this to be an MS/SQLServer problem, not a DBD::ODBC problem (but I could be wrong). I'm hopeing that someone here will have a good workaround that can get me running.DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver][SQL +Server]Line 1: Incorrect syntax near 's'. (SQL-37000) [Microsoft][ODBC SQL Server Driver][SQL Server]Unclosed quotation mark + before the character string '.... (SQL-37000)(DBD: st_execute/SQLExe +cute err=-1) at testdiff.pl line 113.
Thanks, Les
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SQL quoting problem
by extremely (Priest) on Oct 14, 2000 at 03:43 UTC | |
by lhoward (Vicar) on Oct 14, 2000 at 04:46 UTC | |
|
Re: SQL quoting problem
by chromatic (Archbishop) on Oct 14, 2000 at 03:21 UTC | |
|
(Ovid) Re: SQL quoting problem
by Ovid (Cardinal) on Oct 14, 2000 at 03:31 UTC | |
|
Re: SQL quoting problem
by blogan (Monk) on Oct 14, 2000 at 04:09 UTC | |
|
Re: SQL quoting problem
by wardk (Deacon) on Oct 16, 2000 at 17:34 UTC | |
|
Re: SQL quoting problem
by cadfael (Friar) on Oct 16, 2000 at 20:39 UTC |