Re: Escaping \

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Escaping \
Дата
Msg-id 011d01c0b84c$cc9f6f80$1001a8c0@archonet.com
обсуждение исходный текст
Ответ на Escaping \  ("Martijn van Dijk" <martijn@hardworks.nl>)
Ответы Re: Escaping \  (Cedar Cox <cedarc@visionforisrael.com>)
Список pgsql-sql
From: "Martijn van Dijk" <martijn@hardworks.nl>

> I've a problem with escaping a \ in a string.
>
> When I enter the query:
>
> SELECT '''\\\''; I get the right result: '\'
>
> But when I try this in a Function:
>
> CREATE FUNCTION sp_tmp() RETURNS varchar(10)
> AS '
>         SELECT ''\\\' AS RESULT'
> LANGUAGE 'sql';
>
> I get the following Parse-erros:
>
> psql:tmp1:4: ERROR:  Unterminated quoted string. I don't understand why,
> when you leave the SELECT-statement out you get '''\\\'' and that is not
> unterminated.

Had something similar myself the other day. The reason is that you are
already one deep in Postgres' string-parser, so you need something like:

SELECT ''\\\\'' AS RESULT

HTH

- Richard Huxton



В списке pgsql-sql по дате отправления:

Предыдущее
От: Cedar Cox
Дата:
Сообщение: Re: Function with now() | time 'now' | etc...
Следующее
От: Mathijs Brands
Дата:
Сообщение: Re: Calling Java from psql (was Re: requesting help)