Subject RE: [IBO] Apostrphe within single quotes
Author Jack Cane, PhD
Yes, that works, but the query is formed externally to Delphi, and is more
involved, so that I cannot see how to parse the portion to send to
QuotedStr(). Suppose that my query is:

Select, p.LastName, p.Name from Companies c, Persons p
where p.Name containing 'James O'Rourke'
and p.CompanyNr = c.CompanyNr

Here is where I ran into my problem: It becomes ambiguous to know how to
pass the correct parameter (James O'Rourke) to QuotedStr. How can Delphi
know whether the second apostrophe terminates the string (James O), or that
it should go on to find a third apostrophe?

Maybe the query just cannot be formed externally in this case...then I might
be able to use the Delphi function. There are only a few instances of this.
Might work...


-----Original Message-----
From: Helen Borrie [mailto:helebor@...]
Sent: Friday, November 12, 2004 11:08 PM
Subject: Re: [IBO] Apostrphe within single quotes

At 09:48 PM 12/11/2004 -0500, you wrote:

>Suppose a user's input contains a search string like O'Rourke. The
>query would then contain the qualifier, ".where Last_Name containing (or =)
>'O'Rourke'. To avoid a SQL error, this needs to be changed to 'O''Rourke'.
>The obvious solution is simply to advise the user to add the second
>apostrophe manually. To try and avoid that, I have played with this a bit,
>but cannot find my way out of the semantic box created by the ambiguity
>between the apostrophe in the name and the ending single quote. Wondered if
>any of you know of a solution.

Easy!! Let Delphi do the walking ---

ParamByName('CharacterField').AsString :=


IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________ - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !
Yahoo! Groups Links