Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id B1FFF9FA0FB for ; Tue, 19 Dec 2006 18:55:20 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 15405-09 for ; Tue, 19 Dec 2006 18:54:57 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id 5F0559FA42F for ; Tue, 19 Dec 2006 18:55:01 -0400 (AST) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Gwnr8-0000kd-KO for pgsql-sql@postgresql.org; Tue, 19 Dec 2006 23:54:42 +0100 Received: from 85.187.136.11 ([85.187.136.11]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 19 Dec 2006 23:54:42 +0100 Received: from milen by 85.187.136.11 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 19 Dec 2006 23:54:42 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: "Milen A. Radev" Subject: Re: Help with quotes in plpgsql Date: Wed, 20 Dec 2006 00:54:13 +0200 Lines: 59 Message-ID: <45886D95.5080300@radev.net> References: <458849F1.1050100@radev.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 85.187.136.11 User-Agent: Mozilla Thunderbird 1.5.0.8 (Windows/20061025) In-Reply-To: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/148 X-Sequence-Number: 27104 Richard Ray написа: > On Tue, 19 Dec 2006, Milen A. Radev wrote: > >> Richard Ray ÿÿÿÿÿÿÿÿÿÿÿÿ: >>> How should this be properly quoted >>> >>> create or replace function test(integer) returns setof text as $$ >>> declare >>> a record; >>> begin >>> select into a now() - interval '$1 day'; >>> return next a; >>> return; >>> end >>> $$ language 'plpgsql'; >>> >>> I'm not having a lot of luck >> >> >> Welcome to psql 8.2.0, the PostgreSQL interactive terminal. >> >> Type: \copyright for distribution terms >> \h for help with SQL commands >> \? for help with psql commands >> \g or terminate with semicolon to execute query >> \q to quit >> >> milen=> create or replace function test(integer) returns setof text as $$ >> milen$> declare >> milen$> a record; >> milen$> begin >> milen$> select into a now() - interval '$1 day'; >> milen$> return next a; >> milen$> return; >> milen$> end >> milen$> $$ language 'plpgsql'; >> CREATE FUNCTION >> milen=> >> >> >> >> No problems here. What version are you using? >> > > I'm using 8.1.0 but I don't think that's the problem > I have no problem creating the function but it will only substract 1 day Sorry about that - I have not understand your problem. In addition to the solution already proposed you could use "EXECUTE". See more info here - http://www.postgresql.org/docs/8.2/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN . -- Milen A. Radev