pgpl-problem, what's wrong with my loop?
От | Bruno Boettcher |
---|---|
Тема | pgpl-problem, what's wrong with my loop? |
Дата | |
Msg-id | 20001120172105.E25191@erm1.u-strasbg.fr обсуждение исходный текст |
Ответ на | numeric conversions? (Bruno Boettcher <bboett@erm1.u-strasbg.fr>) |
Ответы |
Re: pgpl-problem, what's wrong with my loop?
Re: pgpl-problem, what's wrong with my loop? |
Список | pgsql-sql |
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 ''% currentline: %'', 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 | 100000EUR | 100000EUR | 100000EUR | 100000EUR | 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....
В списке pgsql-sql по дате отправления: