From: bboett@erm1.u-strasbg.fr
To: pgsql-sql@postgresql.org
Subject: HELP: what's wrong with my PL/PSQL function??
Date: Fri, 18 May 2001 11:21:36 +0200
Message-ID: <20010518112136.A468@erm1.u-strasbg.fr> (raw)
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@earthling.net
http://inforezo.u-strasbg.fr/~bboetthttp://erm1.u-strasbg.fr/~bboett
===============================================================
the total amount of intelligence on earth is constant.
human population is growing....
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: bboett@erm1.u-strasbg.fr
Subject: Re: HELP: what's wrong with my PL/PSQL function??
In-Reply-To: <20010518112136.A468@erm1.u-strasbg.fr>
References: <20010518112136.A468@erm1.u-strasbg.fr>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox