Subject Re: [firebird-support] What is wrong with this SP? (BIGINT range)
Author Helen Borrie
At 05:12 AM 11/04/2006, you wrote:
>Hello,
>
>Thank you for quick response and I apologize for the noise.
>
>[BEFORE READING BELOW => SECURITY OF THE MACHINE RUNNING DB SERVER WAS
>SERIOUSLY COMPROMISED AND SOME OTHER FILES LIKE *.ASPX ARE RANDOMLY DAMAGED]
>
>Few mins after my post I got xx error messages and I was unable to perform
>any operation on the database. The process of recreating database (from xls
>files) is currently running. I'll have to wait until tomorrow since I'm
>currently at home.
>
>Other than that ...
>
>1. The intended logic is to get two results. One is SUM of values in ULAZ
>column and the other is SUM of IZLAZ column. I belive that this statement
>fetches result in one iteration (as one row) and I belive that FOR is
>irelevant here because it will result in only one pass through the logic and
>as far as I can see it should do what is intended.
>
>Is the above correct?

No. To get a one-row result you use the SELECT ..... INTO
<variables> syntax. FOR SELECT gets multiple rows in a loop and
operates on each row one by one.


>2. Correct results are much bigger. The SUM of any 10 values is larger than
>above.

With you syntax, you would be getting the values of the last row
processed. SUM(ONE_VALUE) should return some kind of exception, but
apparently not if it worked for you.


>3. INT.

Make sure that INT is large enough to accommodate your total. If it
is going to exceed ~ 2 billion then use BigInt for your variables.

./heLen