markw@osdl.org writes:
>>> DECLARE mycursor CURSOR FOR SELECT new_order(...)
>>> FETCH ALL IN mycursor
>>> ERROR: overflow on numeric ABS(value) >= 10^4 for field with precision 4 scale 0
> Does it make sense that is throws the error on the FETCH instead of the
> previous statement?
Sure: the cursor won't actually be executed until you fetch from it.
Since there's no NUMERIC datatypes in the cursor operation, it's a
dead certainty that the cursor itself is not where the error is being
thrown. I see that your function issues a bunch of inserts and updates
internally; presumably the problem is that one of those is trying to
store bogus data into a table. I'd suggest turning on that DEBUG code
you've sprinkled in there and looking to see which statement gets the
error ...
regards, tom lane