Обсуждение: Deep quotation

Поиск
Список
Период
Сортировка

Deep quotation

От
Casey Allen Shobe
Дата:
I can't seem to get the quoting around "Customers" right in the statement
below.  In db2, I can use \' to escape the quote, and it will insert into the
database properly.  How do I insert single quote data into a table using
single-quote data containers?

insert into    "permissions" (
    "component_id", "action", "query"
) values (
    'home',
    'allow_message_entry',
    'select        count(*)
from only    "users" as "u"
inner join only    "positions" as "p"
on        p."position_id" = u."Position ID"
where        u."UID" = 100
and        p."acl" >= 50
and        p."group_id" != (
    select        g."grosysid"
    from only    "pg_group" as "g"
    where        g."groname" = 'Customers'
)'

Thanks,

--
Casey Allen Shobe / Network Security Analyst & PHP Developer
SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144
cshobe@secureworks.net / http://www.secureworks.net
Content is my own and does not necessarily represent my company.

Lost Terminal.

RESOLVED: Deep quotation

От
Casey Allen Shobe
Дата:
On Sunday 15 September 2002 07:55 am, Casey Allen Shobe wrote:
> I can't seem to get the quoting around "Customers" right in the statement
> below.  In db2, I can use \' to escape the quote, and it will insert into
> the database properly.  How do I insert single quote data into a table
> using single-quote data containers?

Whoops, nevermind this one.  Seems I made a typo.

Thanks,

--
Casey Allen Shobe / Network Security Analyst & PHP Developer
SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144
cshobe@secureworks.net / http://www.secureworks.net
Content is my own and does not necessarily represent my company.

Lost Terminal.

Re: Deep quotation

От
Tom Lane
Дата:
Casey Allen Shobe <cshobe@secureworks.net> writes:
> I can't seem to get the quoting around "Customers" right in the statement
> below.  In db2, I can use \' to escape the quote, and it will insert into the
> database properly.

That works in PG too, or you can use the spec-approved method of
doubling the quote.  See
http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/sql-syntax.html#SQL-SYNTAX-CONSTANTS

            regards, tom lane