Received: from erm1.u-strasbg.fr (erm1.u-strasbg.fr [130.79.74.61]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id eAKG4Es24849 for ; Mon, 20 Nov 2000 11:04:14 -0500 (EST) (envelope-from bboett@erm1.u-strasbg.fr) Received: (qmail 25884 invoked by uid 501); 20 Nov 2000 16:21:05 -0000 Date: Mon, 20 Nov 2000 17:21:05 +0100 From: Bruno Boettcher To: pgsql-sql@postgresql.org Subject: pgpl-problem, what's wrong with my loop? Message-ID: <20001120172105.E25191@erm1.u-strasbg.fr> References: <20001120165133.D25191@erm1.u-strasbg.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Mutt/1.0.1i In-Reply-To: <20001120165133.D25191@erm1.u-strasbg.fr>; from bboett@erm1.u-strasbg.fr on Mon, Nov 20, 2000 at 04:51:33PM +0100 X-Archive-Number: 200011/157 X-Sequence-Number: 188 Hello, once more, i ran into a problem.... i got no syntax error, i don't know how to debug, except for raising exceptions.... the loop never executes.... making the select call by hand with fixed values, returns a result... but the second raise is never passed with the function...so something seems wrong.... CREATE FUNCTION accSum(text,text) RETURNS int4 AS ' DECLARE col ALIAS FOR $1; sumup ALIAS FOR $2; actsum journal.amount%TYPE; arow journal%ROWTYPE; conversion float4; temp float4; sum int4; BEGIN sum := 0; RAISE NOTICE ''stats %=% '', col,sumup; FOR arow IN SELECT currency,amount FROM journal WHERE col=sumup LOOP RAISE NOTICE ''% current line: %'', arow.id,arow.amount; SELECT conv FROM currencies WHERE tag=arow.currency INTO conversion; temp := conversion*arow.amount+0.5; sum := sum + temp; END LOOP; return sum; END; ' LANGUAGE 'plpgsql'; as sayd : fibu=> select accSum('plus','102'); NOTICE: stats plus=102 accsum -------- 0 (1 row) fibu=> SELECT currency,amount FROM journal WHERE plus=102; currency | amount ----------+-------- EUR | 100000 EUR | 100000 EUR | 100000 EUR | 100000 EUR | 100000 (5 rows) surely some stupid error somewhere..... -- 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....