Double-quote problem over ODBC
Posted in 1999
Topics: Connectivity: ODBC / JDBC / .NET
Hi All-
I've run into a problem with Informix over ODBC (I'm using the
Informix 2.80 32-bit driver).
If I run the following directly in Informix, it works fine, but over
ODBC I get a General Error:
insert into temp_table values ("Mr. O'neil says ""Hi""")
Any ideas why?
-Derek Karnes
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
dkarnes@my-deja.com wrote:
> I've run into a problem with Informix over ODBC (I'm using the
> Informix 2.80 32-bit driver).
>
> If I run the following directly in Informix, it works fine, but over
> ODBC I get a General Error:
> insert into temp_table values ("Mr. O'neil says ""Hi""")
I think you'll find that the ODBC standard (& possibly Informix) only
formally allows single quotes for syntax. However, both may let double
quotes through as an addition. Also, you can escape characters in ODBC
so that they do not get interpreted which is probably what is
happening. I'd have to go and look up the exact syntax, but it should
be in any good ODBC reference. You're looking somewhere along the lines
of {escape '\\'} so that you could escape a backslash or in your case a
quote.
Allan Gould
SCO CID Support, Leeds, UK
(allang at sco dot com)
(Please remove anti-spam measures if replying)
dkarnes@my-deja.com wrote:
> I've run into a problem with Informix over ODBC (I'm using the
> Informix 2.80 32-bit driver).
>
> If I run the following directly in Informix, it works fine, but over
> ODBC I get a General Error:
> insert into temp_table values ("Mr. O'neil says ""Hi""")>
> Any ideas why?
It's OK as far as Informix is concerned; unless you set DELIMIDENT,
it treats double quotes as equivalent to single quotes. As far as
ANSI SQL is concerned, it is not OK; you need to use single quotes
around strings, and double quotes around delimited identifiers (=>
the neame of the environment variable). I guess that is the source
of your problem; the ODBC layer is messing around with the statement
and objecting to the 'incorrect' formatting. Informix has to support
both for reasons of backwards compatability.
Fix? Use:
INSERT INTO Temp_Table VALUES('Mr. O''neil says "Hi"')
Shouldn't there be a capital N in O'Neil, though? And a comma after
'says'?
--
Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net)
Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN
#include <disclaimer.h>