"Sabin Coanda" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
> "Sabin Coanda" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> ...
>>
>> 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$
BEGIN
 RETURN replace( sText, chr(92), '\\' );
END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

Consequently, the statement SELECT myformat('a\b' ) will get the desired 
result a\\b

Sabin 



---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to