\\quotes
Posted in 2000
Topics: Connectivity: ODBC / JDBC / .NET
Anyone ever faced the problem of inserting/updating textfields with any kind of quotes in it? Backslashing every quote is a solution, but isn't there something a more elegant? I'm dealing with lots of dynamic (prepared) operations on text containging 'singles', "doubles" and the like (via jdbc and per:dbi). Anton
On Tue, 24 Oct 2000 12:06:54 +0200, "Toon Van Herreweghen"
<toon.van.herreweghen@tvd.be> wrote:
>Anyone ever faced the problem of inserting/updating textfields with any kind
>of quotes in it?
>Backslashing every quote is a solution, but isn't there something a more
>elegant?
>I'm dealing with lots of dynamic (prepared) operations on text containging
>'singles', "doubles" and the like (via jdbc and per:dbi).
>
>Anton
The single quote is its own escape character, so lines like
insert into dummytable values ('Here''s a single quote escaped for
insert')
do the trick.
BUT ... every client since 1997/1998 has had bugs with this (see
Informix support case 979933), depending on the interface used
(straight SQL through dbaccess etc. [usually ok], ODBC [usually half
broken], OLE DB [usually half broken]). The usual problems are not
handling escaped quotes and carriage returns in the same string, or
reporting an incorrect number of rows affected for this kind of
string.
Support has promised that this has been rectified in the 9.21uc4
release in combination with the 2.50 SDK ... but uc4 isn't available
yet (at least not from Intraware or Informix Support out here on the
under-side of the planet.)
Not really much of a solution for you, but something else to play
around with.
Ciao
Fuzzy
;-)
On Tue, 24 Oct 2000 12:06:54 +0200, "Toon Van Herreweghen" <toon.van.herreweghen@tvd.be> wrote: >Anyone ever faced the problem of inserting/updating textfields with any kind >of quotes in it? >Backslashing every quote is a solution, but isn't there something a more >elegant? >I'm dealing with lots of dynamic (prepared) operations on text containging >'singles', "doubles" and the like (via jdbc and per:dbi). > >Anton > > If the statements are already perpared, why not use placeholders. Then you can ignore the quotes entirely. In Perl (since I know it best): $sth = $dbh->prepare("insert into mytable values( ?, ?)"); $sth->execute($val1, $val2); $sth->execute($val3, $val4); . . . Java is not much different. HTH -- Rob Wilson rwilson@ntsource.com