Subject | RE: [IBO] Apostrphe within single quotes |
---|---|
Author | Jack Cane, PhD |
Post date | 2004-11-13T05:00:19Z |
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:
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...
jwc
-----Original Message-----
From: Helen Borrie [mailto:helebor@...]
Sent: Friday, November 12, 2004 11:08 PM
To: IBObjects@yahoogroups.com
Subject: Re: [IBO] Apostrphe within single quotes
At 09:48 PM 12/11/2004 -0500, you wrote:
ParamByName('CharacterField').AsString :=
QuotedStr(ParamByName('CharacterField').AsString);
HB
___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !
Yahoo! Groups Links
involved, so that I cannot see how to parse the portion to send to
QuotedStr(). Suppose that my query is:
>>Select c.name, 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...
jwc
-----Original Message-----
From: Helen Borrie [mailto:helebor@...]
Sent: Friday, November 12, 2004 11:08 PM
To: IBObjects@yahoogroups.com
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. Theresulting
>query would then contain the qualifier, ".where Last_Name containing (or =)Easy!! Let Delphi do the walking ---
>'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.
ParamByName('CharacterField').AsString :=
QuotedStr(ParamByName('CharacterField').AsString);
HB
___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !
Yahoo! Groups Links