Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id B479437C703 for ; Mon, 12 Nov 2007 12:43:55 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 71959-04 for ; Mon, 12 Nov 2007 12:43:49 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by postgresql.org (Postfix) with ESMTP id 5182037C68C for ; Mon, 12 Nov 2007 12:43:55 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.1/8.14.1) with ESMTP id lACGhqDw062231 for ; Mon, 12 Nov 2007 12:43:52 -0400 (AST) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.1/8.14.1/Submit) id lACGJ7Rg056484 for pgsql-sql@postgresql.org; Mon, 12 Nov 2007 12:19:07 -0400 (AST) (envelope-from news) From: "Sabin Coanda" X-Newsgroups: pgsql.sql Subject: Re: plpgsql language not aware of standard_conforming_strings ? Date: Mon, 12 Nov 2007 18:19:13 +0200 Organization: Hub.Org Networking Services Lines: 35 Message-ID: References: X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Response To: pgsql-sql@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/53 X-Sequence-Number: 29581 "Sabin Coanda" wrote in message news:fh9cbj$2pd2$1@news.hub.org... > > "Sabin Coanda" 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$ 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