PL/PGSQL q?

From: "Vitaliy N(dot) Kravchenko" <kvn(at)phbme(dot)ntu-kpi(dot)kiev(dot)ua>
To: pgsql-hackers(at)postgresql(dot)org
Subject: PL/PGSQL q?
Date: 2002-07-27 15:38:50
Message-ID: ahueqa$676$1@igloo.uran.net.ua
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


1234567890
Hi!
I write function on plpgsql and have some troubles:

I have table "owe" : uid int4, date int4, cost float4;
I want to select into "owe_old" : DECLARE owe_old float4;

cur_date := date_part(''year'', now()) || ''-'' || date_part(''month'', now()) || ''-01'';
we have cur_date = '2002-05-01' for example..

And I want to :
SELECT INTO owe_old sum(cost) FROM owe WHERE date > int4(ABSTIME ''''cur_date''''');

And I have error:
NOTICE: line 24 at select into variables
ERROR: parser: parse error at or near "$1"

How I can substitute "cur_date" into SQL statement..?
Or how I can get sum(cost) in different way..?

Thank you!

--
--
Best regards, KVN.
PHP4You (<http://php4you.kiev.ua/>)
PEAR [ru] (<http://pear.php.net/manual/ru/>)
mailto:kvn(at)php(dot)net

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2002-07-27 18:00:33 What exactly does lanispl mean?
Previous Message Tom Lane 2002-07-27 06:35:36 Re: Virus Emails