PL/SQL trouble

From: "Ferruccio Zamuner" <nonsolosoft(at)diff(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: PL/SQL trouble
Date: 2002-11-26 08:56:35
Message-ID: E18GbWF-0007oU-00@global.dnsprotect.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message patrick 2002-11-26 09:43:02 Are sub-select error suppressed?
Previous Message Padmanab Sridhar 2002-11-26 06:14:34 How to recover Data