Re: plpgsql language not aware of standard_conforming_strings ? - Mailing list pgsql-sql

From Sabin Coanda
Subject Re: plpgsql language not aware of standard_conforming_strings ?
Date
Msg-id fh9udq$1n50$1@news.hub.org
Whole thread Raw
In response to plpgsql language not aware of standard_conforming_strings ?  ("Sabin Coanda" <sabin.coanda@deuromedia.ro>)
List 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 by date:

Previous
From: Tom Lane
Date:
Subject: Re: show value of backslashes in string array argument
Next
From: "Sabin Coanda"
Date:
Subject: Re: show value of backslashes in string array argument