X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AACAAD1B4EA for ; Mon, 22 Sep 2003 15:43:20 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 51397-01 for ; Mon, 22 Sep 2003 12:42:48 -0300 (ADT) Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net [194.217.242.89]) by svr1.postgresql.org (Postfix) with ESMTP id E6788D1C9E7 for ; Mon, 22 Sep 2003 12:42:47 -0300 (ADT) Received: from lfix.demon.co.uk ([80.177.205.209] helo=cerberus.lfix.co.uk) by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) id 1A1Spq-0005iI-0V; Mon, 22 Sep 2003 16:42:46 +0100 Received: from linda.lfix.co.uk ([192.168.1.1]) by cerberus.lfix.co.uk with esmtp (Exim 4.22) id 1A1SpZ-0001HI-HR; Mon, 22 Sep 2003 16:42:29 +0100 Subject: Re: error with functions From: Oliver Elphick To: shyamperi@davlin.co.in Cc: pgsql-admin@postgresql.org In-Reply-To: <2110482.1064209766872.JavaMail.tomcat@mail.davlin.co.in> References: <2110482.1064209766872.JavaMail.tomcat@mail.davlin.co.in> Content-Type: text/plain Organization: LFIX Limited Message-Id: <1064245382.26041.252.camel@linda.lfix.co.uk> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Mon, 22 Sep 2003 16:43:02 +0100 Content-Transfer-Encoding: 7bit X-LFIX-MailScanner: Found to be clean X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/344 X-Sequence-Number: 10432 On Mon, 2003-09-22 at 06:42, shyamperi@davlin.co.in wrote: > >You do realize that the shell is going to interpret that string in > >double quotes right? > I guess so, for the very same I have tried with > Command: psql test -c "> CREATE FUNCTION add_one (integer) RETURNS > INTEGER AS ' BEGIN RETURN ''$1'' + 1; END; ' LANGUAGE > 'plpgsql';" > But still it is not taking it as $1, instead empty string. > Ideeally it shud consider $1 as string... but why isn't it It's still being interpreted by the shell. The shell takes no notice at all of the nested quotes; everything inside the double quotes is treated as literal text, after replacing variables. Look here: olly@linda$ echo psql test -c "> CREATE FUNCTION add_one (integer) RETURNS INTEGER AS ' BEGIN RETURN ''$1'' + 1; END; ' LANGUAGE 'plpgsql';" psql test -c > CREATE FUNCTION add_one (integer) RETURNS INTEGER AS ' BEGIN RETURN '''' + 1; END; ' LANGUAGE 'plpgsql'; Instead of trying to quote $1, you need to escape the dollar sign: olly@linda$ echo psql test -c "> CREATE FUNCTION add_one (integer) RETURNS INTEGER AS ' BEGIN RETURN \$1 + 1; END; ' LANGUAGE 'plpgsql';" psql test -c > CREATE FUNCTION add_one (integer) RETURNS INTEGER AS ' BEGIN RETURN $1 + 1; END; ' LANGUAGE 'plpgsql'; -- Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight, UK http://www.lfix.co.uk/oliver GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C ======================================== "Therefore when thou doest thine alms, do not sound a trumpet before thee, as the hypocrites do in the synagogues and in the streets, that they may have glory of men. Verily I say unto you, They have their reward. But when thou doest alms, let not thy left hand know what thy right hand doeth; That thine alms may be in secret; and thy Father which seeth in secret himself shall reward thee openly." Matthew 6:2-4