Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Double single quotes
Wed, Mar 19 2008 7:39 PMPermanent Link

"Lance Ras"
Tim,

Why is it necessary to use two single quotes around a string default value
for a column, or for the Description for the table?   I always thought 2
single quotes were only for escaping purposes when using things such as
IT'S, where you would use IT''S.

I'm using this in a SQL script exported via the EDB Manager's reverse
engineering.
===
SCRIPT
BEGIN
  EXECUTE IMMEDIATE 'CREATE TABLE "Table1"
                    (
                    "RowID" GUID NOT NULL,
                    "Stuff" VARCHAR(15) COLLATE "ANSI",
                    "ReassignID" GUID DEFAULT
''{00000000-0000-0000-0000-000000000000}''
                    )
                    DESCRIPTION ''Bowler Table''
                    VERSION 1.00
                    UNENCRYPTED
                    INDEX PAGE SIZE 4096
                    BLOB BLOCK SIZE 512
                    MAX ROW BUFFER SIZE 32768
                    MAX INDEX BUFFER SIZE 65536
                    MAX BLOB BUFFER SIZE 32768';
END
===

From comparing to some other DB's following the appropriate standards, it
seems it really should be:

===
SCRIPT
BEGIN
  EXECUTE IMMEDIATE 'CREATE TABLE "Table1"
                    (
                    "RowID" GUID NOT NULL,
                    "Stuff" VARCHAR(15) COLLATE "ANSI",
                    "ReassignID" GUID DEFAULT
'{00000000-0000-0000-0000-000000000000}'
                    )
                    DESCRIPTION 'Bowler Table'
                    VERSION 1.00
                    UNENCRYPTED
                    INDEX PAGE SIZE 4096
                    BLOB BLOCK SIZE 512
                    MAX ROW BUFFER SIZE 32768
                    MAX INDEX BUFFER SIZE 65536
                    MAX BLOB BUFFER SIZE 32768';
END
===

I understand that if I was to assign a delphi string variable with that
directly in Delphi code, I would need to escape with two single quotes or
Delphi will most likely not compile..   However, I'm wondering why I would
have to worry about it in a script.

Lance
Thu, Mar 20 2008 4:05 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Lance

>Why is it necessary to use two single quotes around a string default value
>for a column, or for the Description for the table?

Because what you're doing is passing a string to EXECUTE IMMEDIATE which will then be running some Delphi code to do its magic.

Roy Lambert
Thu, Mar 20 2008 1:25 PMPermanent Link

"Lance Ras"
It sort of makes sense, I guess.

I guess (sigh) that it means I'll have to massage the Datanamic DeZign
output for EDB a little, vs plug and play...    Wink


"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message
news:FB6423C3-7A45-427F-82FE-162BB8B58211@news.elevatesoft.com...
> Lance
>
>>Why is it necessary to use two single quotes around a string default value
>>for a column, or for the Description for the table?
>
> Because what you're doing is passing a string to EXECUTE IMMEDIATE which
> will then be running some Delphi code to do its magic.
>
> Roy Lambert
Thu, Mar 20 2008 2:01 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Lance
As a guess they're producing code that's intended for a query not a script.


Roy Lambert
Image