Subject | Re: [IBO] Re: TIB_Query Programatically Defined SQL with Strings |
---|---|
Author | Helen Borrie |
Post date | 2003-12-09T00:05:15Z |
At 11:37 PM 8/12/2003 +0000, you wrote:
vague....
You wrote:
UPDATE MyTable SET MyField = 'ABC Company, Inc.'
I get an error that indicates that the parser believes I want to set
MyField equal to another column as though 'ABC Company, Inc.' is the
name of a column.
That update statement as quoted will store the string
ABC Company, Inc
But, elsewhere, you doubled the single-quotes, as follows:
UPDATE MyTable SET MyField = ''ABC Company, Inc.''
That is two single quotes at each end of the string (not double
quotes). As Paul pointed out, doubling the single quote causes the next
single quote to be treated as a literal. But the above statement won't
work, because you need THREE, not two single quotes in order to store your
single-quote literals:
UPDATE MyTable SET MyField = '''ABC Company, Inc.'''
That is: one single quote (ascii 39) to mark the start of the string,
followed by two single quotes (known as "doubled quote" not to be confused
with double-quote, ascii 34) to mark the literal; and the reverse at the
end of the string. It will then store the string as
'ABC Company, Inc'
As for double-quotes - they are not symbols ANYWHERE except as delimiters
for case-sensitive object identifiers. If you want to store double-quotes
as literals, just do it. The Fb parser just treats them as literals, no
markers required.
Helen
>Thank you, Helen. That was news to me. Any chance you could give meWell, I watched all the messages and the problem description appears pretty
>any advice on the string literal problem from my posting?
>
>Thanks again.
>-Jack
vague....
You wrote:
UPDATE MyTable SET MyField = 'ABC Company, Inc.'
I get an error that indicates that the parser believes I want to set
MyField equal to another column as though 'ABC Company, Inc.' is the
name of a column.
That update statement as quoted will store the string
ABC Company, Inc
But, elsewhere, you doubled the single-quotes, as follows:
UPDATE MyTable SET MyField = ''ABC Company, Inc.''
That is two single quotes at each end of the string (not double
quotes). As Paul pointed out, doubling the single quote causes the next
single quote to be treated as a literal. But the above statement won't
work, because you need THREE, not two single quotes in order to store your
single-quote literals:
UPDATE MyTable SET MyField = '''ABC Company, Inc.'''
That is: one single quote (ascii 39) to mark the start of the string,
followed by two single quotes (known as "doubled quote" not to be confused
with double-quote, ascii 34) to mark the literal; and the reverse at the
end of the string. It will then store the string as
'ABC Company, Inc'
As for double-quotes - they are not symbols ANYWHERE except as delimiters
for case-sensitive object identifiers. If you want to store double-quotes
as literals, just do it. The Fb parser just treats them as literals, no
markers required.
Helen