[Zope] Re: [Zope-DB] sqlvar tag for text

Jim Penny jpenny@universal-fasteners.com
Mon, 24 Feb 2003 17:48:58 -0500


On Mon, Feb 24, 2003 at 11:24:23PM +0100, Alex Cowan wrote:
> Sorry that some of you will get this twice (I did reply to instead of reply
> to all)
> 
> As a reply to Jim Penny:
> Doesn't help in cases where I want to keep " instead of '

Of course it does.  There is no need to quote double quotes inside a SQL
string.

   A string constant in SQL is an arbitrary sequence of characters
   bounded by single quotes ("'"), e.g., 'This is a string'. SQL allows
   single quotes to be embedded in strings by typing two adjacent single
   quotes (e.g., 'Dianne''s horse').

So, 'He said, "she said: you are so ..."' is a valid SQL string.

See:
http://www.netaktive.com/biblio/sql/SQL98/sql2bnf.aug92.txt

(Now, that a certain vendor might allow, as an extension, strings to be
enclosed in double quotes might be the case, but single quotes are
standard, will always work, are no more work, and should therefore
always be preferred.)

Jim Penny