How to escape double quotes on a SQL Update via ODBC

Caché, ODBC, SQL

Hi all,

I am new in Cache. I have to update a record with a long text field, for that,  I am using ODBC but the issue is that it is returning an error when I execute the ODBC  SQL statement because the field contains some commas, colon, double quotes, single quotes, and CR LF characters.

There is a way to escape this chars? I have seen I can save the field when I replace the single quotes with a double single quote (it's -> it''s) but I can not save the information when the field contains double quote chars. What about the other chars?

The statement is something like:

SET description = '240-page + cover perfect bound book. Insides on 29" 22.1 ",  productName = ' "AAA244 - Sometext, sometext.  "  '  WHERE id=25

Any Ideas? Than you in advance.

  • 0
  • 0
  • 452
  • 4
  • 2

Answers

Use parameters instead of building the query manually. Everything would be escaped automatically.

Thank you for your prompt response.  But ... do you have an example?

The statement in your post is not well formed. The value for the description field starts with a single quote, contains a couple of double quotes, but is not terminated with a single quote.

Sorry, It was an example. The single quotes in the program are good. Thanks!