Double quotes in select statement throw an error

From: James Moosmann (james.moosmann_at_bankofamerica.com)
Date: 01/18/05


Date: Tue, 18 Jan 2005 16:10:52 -0500
To: dbi-users@perl.org

The following line produces and error in DBI excuting with either a do or a
prepare, execute

my $statement = "SELECT \"Rows inserted\" + @rows "); # ODBC error
my $statement2 = "SELECT 'Rows inserted' + @rows "); # works

$dbh->do( $statement );

or

$sth->prepare( $statement );
$sth->execute();

DBI: 1.46
DBD-ODBC: 1.11

Active State Perl 5.8.3 multi-thread
Win2K

The error:

DBD::ODBC::db do failed: [Microsoft][ODBC SQL Server Driver][SQL
Server]Invalid column name 'Rows inserted: '. (SQL-42S22)
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'Rows
inserted: '. (SQL-42S22)(DBD: Execute immediate failed err=-1) at
c:/Cw/Dev/Library/Executables/sptool line 215, <$fileHandle> line 211.:

MSSQL isql and Embarqadero do not complain about the double quotes.

This is in a stored procedure, the text of which we are trying to run.
Other tools do not complain about the double quotes, only DBI.

Any ideas? Is this a bug? Or, is it simply incorrect for the user to be
using double quotes (ie, not ANSI ? )

Thanks,

James



Relevant Pages

  • Re: Double quotes in select statement throw an error
    ... > prepare, execute ... > MSSQL isql and Embarqadero do not complain about the ... > Other tools do not complain about the double quotes, ... > only DBI. ...
    (perl.dbi.users)
  • Re: Problem with Perl/Tk
    ... You don't need quotes at all. ... I'm not sure when you want this to execute, ... Many live that deserve death. ...
    (comp.lang.perl.misc)
  • Re: basic help to run an application from WSH
    ... string values must be enclosed in quotes. ... The Run method will execute on c:\notepad.exe. ... I'm just learning vbscript for wsh and here is my first script, ... Also if I cut and paste the exact file path from the script into the ...
    (microsoft.public.scripting.vbscript)
  • Re: Launching Multiple Programs From A Command Prompt Script
    ... quotes "" before the quotes containing the actual executable name, ... >> I would like to launch multiple programs from a command prompt script ... the script will not execute the second line until the first ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Handling Quotes in Expression Builder
    ... I just saw a property line for the statement to execute and figured ... them when they are contained in the data string. ... My silly string's have quotes, ... Using the parameter support of the Execute SQL Task would be safer and ...
    (microsoft.public.sqlserver.dts)