HELP: what's wrong with my PL/PSQL function??

Поиск
Список
Период
Сортировка
От bboett@erm1.u-strasbg.fr (Bruno Boettcher)
Тема HELP: what's wrong with my PL/PSQL function??
Дата
Msg-id 20010518112136.A468@erm1.u-strasbg.fr
обсуждение исходный текст
Список 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;
arowRECORD; 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@earthling.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....


В списке pgsql-sql по дате отправления:

Предыдущее
От: Jan Wieck
Дата:
Сообщение: Re: ON UPDATE CASCADE overhead?
Следующее
От: Giorgio Valoti
Дата:
Сообщение: Re: has anyone tried running in MAC OS X