PL/PGSQL q?

Started by Vitaliy N. Kravchenkoover 23 years ago1 messages
#1Vitaliy N. Kravchenko
kvn@phbme.ntu-kpi.kiev.ua

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/&gt;)
PEAR [ru] (<http://pear.php.net/manual/ru/&gt;)
mailto:kvn@php.net