Re: plpgsql language not aware of standard_conforming_strings ?
| От | Sabin Coanda |
|---|---|
| Тема | Re: plpgsql language not aware of standard_conforming_strings ? |
| Дата | |
| Msg-id | fh9udq$1n50$1@news.hub.org обсуждение исходный текст |
| Ответ на | plpgsql language not aware of standard_conforming_strings ? ("Sabin Coanda" <sabin.coanda@deuromedia.ro>) |
| Список | pgsql-sql |
"Sabin Coanda" <sabin.coanda@deuromedia.ro> wrote in message
news:fh9cbj$2pd2$1@news.hub.org...
>
> "Sabin Coanda" <sabin.coanda@deuromedia.ro> wrote in message
> news:fh99cq$2cfn$1@news.hub.org...
> ...
>>
>> How can I get my desired function that means when I call test( 'a\b' ) it
>> will return 'a\\b' ?
>>
>
...
> CREATE OR REPLACE FUNCTION myreplace(sText varchar, sSrc varchar, sDst
...
Unfortunatelly this is not very productive when sSrc or sDst has to be
constants inside the function. There is another workaround for that, to
specify '\' as chr(92). For instance:
CREATE OR REPLACE FUNCTION myformat(sText varchar) RETURNS varchar AS
$BODY$
BEGINRETURN replace( sText, chr(92), '\\' );
END;
$BODY$ LANGUAGE 'plpgsql' VOLATILE;
Consequently, the statement SELECT myformat('a\b' ) will get the desired
result a\\b
Sabin
В списке pgsql-sql по дате отправления: