Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7C0C847614C for ; Tue, 26 Nov 2002 03:56:46 -0500 (EST) Received: from global.dnsprotect.com (ns9.dnsprotect.com [216.180.225.50]) by postgresql.org (Postfix) with ESMTP id 6660F475FCE for ; Tue, 26 Nov 2002 03:56:33 -0500 (EST) Received: from difforg by global.dnsprotect.com with local (Exim 3.36 #1) id 18GbWF-0007oU-00 for pgsql-sql@postgresql.org; Tue, 26 Nov 2002 03:56:35 -0500 From: "Ferruccio Zamuner" To: pgsql-sql@postgresql.org Reply-To: nonsolosoft@diff.org Subject: PL/SQL trouble X-Mailer: NeoMail 1.25 X-IPAddress: 217.133.205.215 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Message-Id: Date: Tue, 26 Nov 2002 03:56:35 -0500 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - global.dnsprotect.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [32135 636] / [32135 636] X-AntiAbuse: Sender Address Domain - global.dnsprotect.com X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/361 X-Sequence-Number: 10503 Hi, I really don't understand following PostgreSQL 7.2.3 behaviour: $ psql mydb mydb=> CREATE FUNCTION MONDAY(timestamp) RETURNS DATE AS ' DECLARE var1 date; BEGIN select into var1 to_date($1::date-(case when extract(DOW from timestamp $1) = 0 then 6 else (extract(DOW from timestamp $1)-1) end)); RETURN var1; END' language 'plpgsql'; CREATE mydb=> select MONDAY('now'::timestamp); NOTICE: Error occurred while executing PL/pgSQL function MONDAY NOTICE: line 4 at select into variables ERROR: parser: parse error at or near "$2" mydb=> \q But I've not inserted any $2 there. I've rewritten the same function in other ways but I've got the same error. I thank you in advance for any hints. Bye, \fer