From: | bboett(at)erm1(dot)u-strasbg(dot)fr (Bruno Boettcher) |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | HELP: what's wrong with my PL/PSQL function?? |
Date: | 2001-05-18 09:21:36 |
Message-ID: | 20010518112136.A468@erm1.u-strasbg.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
hello!
i have the following function:
CREATE FUNCTION plusSum(text,int4) RETURNS int4 AS '
DECLARE
jrlname ALIAS FOR $1;
sumup ALIAS FOR $2;
actsum int4;
arow RECORD;
conversion float8;
temp float8;
sum float8;
BEGIN
sum := 0;
RAISE NOTICE ''stats % '', sumup;
FOR arow IN SELECT * FROM "jrlname" WHERE plus=sumup LOOP
SELECT conv FROM currencies WHERE tag=arow.currency INTO conversion;
sum := sum + (arow.amount/conversion);
END LOOP;
return round(sum);
END;
' LANGUAGE 'plpgsql';
select plusSum('journal','102');
and i get an error:
ERROR: parser: parse error at or near "$1"
(BTW would be helpful if the thing could spit out also the line
number....)
isolated the prob to this line:
FOR arow IN SELECT * FROM "jrlname" WHERE plus=sumup LOOP
in fact it doesn't seem to like the fact that i use a dynamic table
name??
i remind vaguely that pl/psql had indeed this sort of problem... but
this was years ago.... is there any workaround? even using perl?
The whole prog is a bookkeeping program... and i want it now really able
to work with several sets of tables.... without duplicating also the
functions i wrote associated to the tables....
BTW is there a possibility to make further select calls out of plperl?
(an example making this would come in handy...)
i am using a postgres7.03 DB on a debian system...
--
ciao bboett
==============================================================
bboett(at)earthling(dot)net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
===============================================================
the total amount of intelligence on earth is constant.
human population is growing....
From | Date | Subject | |
---|---|---|---|
Next Message | Justin Clift | 2001-05-18 09:47:08 | Re: has anyone tried running in MAC OS X |
Previous Message | Giorgio Valoti | 2001-05-18 08:46:06 | Re: has anyone tried running in MAC OS X |