Re: [SQL] plpgsql function executed multiple times for each return value

2011-10-08 Thread Tom Lane
Steve Northamer writes: > So my questions are: 1) How do we cause the paymentcalc function to be > executed only once? In recent versions, I think marking it volatile would be sufficient. regards, tom lane -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)

Re: [SQL] plpgsql function executed multiple times for each return value

2011-10-08 Thread David Johnston
> So my questions are: 1) How do we cause the paymentcalc function to be > executed only once? and 2) How do we call a table returning function with > inputs from a table? > > Thank you very much! > > Steve > WITH func AS ( SELECT FUNC(...) AS func_result FROM ... ) SELECT (func.func_re

[SQL] plpgsql function executed multiple times for each return value

2011-10-08 Thread Steve Northamer
We have a plpgsql function called paymentcalc, which calculates the payment necessary to pay off a loan. It's defined like this: CREATE OR REPLACE FUNCTION paymentcalc(IN amount numeric, IN interestrate numeric, IN termmonths integer, IN paymentfreq integer, IN dueday1 integer, IN dueday2 i