Thanks Helen.
  
 Yes caught me out to, a single quote is allowed in email addresses to the left 
of the @ apparently.
  
 I have tried QuoteStr and that fails as well.
  
 The behaviour you suggest is what happens if I use format to create the query 
(SELECT * FROM PERSON WHERE EMAIL = '%s'). In this case I get the exception the 
neill (the email address is a.o'[email protected]) is an unknown token. It’s as 
if it sees it as 'a.o'[email protected]
  
 Very strange in deed.
 
  
 

---In [email protected], <[email protected]> 
wrote:

 At 06:17 a.m. 16/10/2013, russell@... mailto:russell@... wrote:
 
 
 >running inside Delphi if I use the query 
 >
 >
 >select * from person where email = :email
 >
 >if the email address is a@... mailto:a@... then it is fine, but if the email 
 >contains an apostrophe a'oneill@b,com then it fails to locate the record. 
 >Even if I use a string replace rather than a parameter it fails.
 >
 >In FlameRobin 
 >
 >select * from person where email = 'a''oneill@... mailto:oneill@...'
 >
 >is fine.
 
 Strange - I thought apostrophes and other diacritics were illegal characters 
in email addresses. Well, well! 
 
 If it's working in FR (which uses IBPP) then it is obviously Delphi that is 
mangling the apostrophe - possibly taking the first of your doubled apostrophes 
as the end of the string and so, for your example, passing 
 
 where email = 'a'
 
 In Delphi I've always found that using QuotedStr to populate parameters and 
variables gets past these little temperamentals in the Delphi parser. What 
QuotedStr does is to treat everything inside the outer pair of apostrophes as 
literals, which is what you need here.
 
 emailvar := QuotedStr ('a''oneill@... mailto:oneill@...'); 
 
 selectstr := 'select * from person where email = ' + emailvar;
 
 Better still is to use parameters and a prepared SELECT statement, which your 
post suggests is what you are actually doing. Assign the value of emailvar to 
your 'EMAIL' parameter.
 
 
 Helen Borrie, Support Consultant, IBPhoenix (Pacific)
 Author of "The Firebird Book" and "The Firebird Book Second Edition"
 http://www.firebird-books.net http://www.firebird-books.net
 __________________________________________________________________

Reply via email to