Subject Re: [firebird-support] String literals syntax
Author Timothy Madden
On Tue, Aug 26, 2008 at 12:25 AM, Helen Borrie <helebor@...> wrote:
At 03:32 26/08/2008, you wrote:
>Hello
>
>What is the syntax for string literals in Firebird 2.1.1 ?

Enclose in single quotes.
>How do I escape non-printable characters in a string ?

You don't. They are passed as whatever (bytes) they are. However, the
apostrophe character inside a string literal must always be escaped by
"doubling" it, e.g. 'O''Shaughnessy' (2 apostrophes).
>Where is it in the help ?

'The Firebird Book' Ch. 11 P. 162; but it's SQL standard.
>I have some arbitrary strings in my application and I need
>to update table rows with them.

You'll need a routine at the client side that doubles apostrophes, such as
the QuotedStr() function of Delphi.
>Also the UPDATE statement with query parameters do not
>seem to work for me in embedded SQL, although for
>INSERT statements they seem to work. Could it be that
>UPDATE does not support query parameters in embedded
>SQL, but INSERT does ? ?

No, there is no such restriction. Explain what "do not work" means - what
exception do you see?


I though I should just enclose the string in quotes, I was still worried
about special characters.
Thank you for the tip on QuotedStr.

The error I with my parameterized UPDATE statement is here:
http://www.geocities.com/mrnopersonality/fbParamError.PNG

My statement is

UPDATE
Userfields
SET
"f0000000247_log" = :f0000000247_log,
"f0000000248_opmerkingen" = :f0000000248_opmerkingen,
"f0000000249_trefwoorden" = :f0000000249_trefwoorden,
"f0000000250_versienieuw" = :f0000000250_versienieuw,
"f0000000251_versieoud" = :f0000000251_versieoud
WHERE
"MediaID"= 844199

I get
Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, column 54
7

The line and column number are taken from the statement written all on one
line, because this is how I actually send it to the firebird dll in my
application. It points to the second digit of 7 in the statement, i. e. into
the name of the first query parameter. So the message does not help me too
much, and I assumed UPDATE does not support query parameters.

You may think the parameter names might be too long, but they are all up to
31 characters, and I also tried with shorter names (with less zeroes in
them), and I get the same error pointing on the same digit of 7 :)

If I try to insert a record with a similiar statement, than things work as
expected.

Thank you,
Timothy Madden


[Non-text portions of this message have been removed]