![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
FOR this_rSum IN EXECUTE this_sQuery LOOP this_iSum := this_rSum.isum; END LOOP; this_iTotal := this_iTotal + this_iSum; |
|
If I return this_iSum or this_iTotal in the loop, I get a value. If I return directly after the loop, the value is NULL. I can't figure out why it's doing this. The value comes out of the inside for loop just fine, but not the outer loop. |
#3
| |||
| |||
|
|
Add some RAISE INFO statements to print variables' values at key places. I wonder if one of your SUMs is returning NULL, causing your addition to evaluate to NULL. If so, then perhaps you should use COALESCE to turn those NULLs into zeros. If I've misunderstood the problem then please clarify. -- Michael Fuhr http://www.fuhr.org/~mfuhr/ |
#4
| |||
| |||
|
|
On Sat, 16 Oct 2004 00:59:34 -0600, Michael Fuhr <mike (AT) fuhr (DOT) org> wrote: Add some RAISE INFO statements to print variables' values at key places. I wonder if one of your SUMs is returning NULL, causing your addition to evaluate to NULL. If so, then perhaps you should use COALESCE to turn those NULLs into zeros. Thanks. That's exactly what was happening. I'm still new to postgres. |
#5
| |||
| |||
|
|
Glad you got it working. A question about your design: you appear to have a tblBatchHistory_X table for each iId value in tblServers. Is there a reason for doing that instead of having a single tblBatchHistory table with a foreign key reference to tblServers? |
#6
| |||
| |||
|
|
I didn't write it, but it's to avoid locking. Each table is for a different server. They are all writing at the same time, and I guess it speeds up the inserts to have them in different tables. |
#7
| |||
| |||
|
|
Uh, not in Postgres. Perhaps you're thinking of another database system? In fact I suspect it's slowing down your system somewhat. -- greg |
![]() |
| Thread Tools | |
| Display Modes | |
| |