"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