By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,851 Members | 1,746 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,851 IT Pros & Developers. It's quick & easy.

If statement

P: n/a
Hi,
We have a SQL store procedure that uses if statement like:

IF someVar <> 0 then
SET SomeVar2 = 100/someVar;
ELSE
SET SomeVar2 = 0;
END IF;

This part of store procedure was working with previous versions.
The problem became when we install FixPack 8.2 on Windows
From now when we run this store procedure we have an exception error
'Division by 0 encountered'.
As we understand it started evaluate both parts of if statement.
If there any way to change this statement to avoid this evaluation.

Any help will be appreciated.
Thanks,
Yury.
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Yury" <y_******@hotmail.com> wrote in message
news:vu********************************@4ax.com...
Hi,
We have a SQL store procedure that uses if statement like:

IF someVar <> 0 then
SET SomeVar2 = 100/someVar;
ELSE
SET SomeVar2 = 0;
END IF;

This part of store procedure was working with previous versions.
The problem became when we install FixPack 8.2 on Windows
From now when we run this store procedure we have an exception error
'Division by 0 encountered'.
As we understand it started evaluate both parts of if statement.
If there any way to change this statement to avoid this evaluation.

Any help will be appreciated.
Thanks,
Yury.


If you are at fixpak 7 (8.2 base code), then move to fixpak 8. If you are on
Fixpak 8, then I would open a problem with IBM support.
Nov 12 '05 #2

P: n/a
Yury wrote:
Hi,
We have a SQL store procedure that uses if statement like:

IF someVar <> 0 then
SET SomeVar2 = 100/someVar;
ELSE
SET SomeVar2 = 0;
END IF;

This part of store procedure was working with previous versions.
The problem became when we install FixPack 8.2 on Windows
From now when we run this store procedure we have an exception error
'Division by 0 encountered'.
As we understand it started evaluate both parts of if statement.
If there any way to change this statement to avoid this evaluation.

Any help will be appreciated.
Thanks,
Yury.

This is a known issue. I believe it's fixed in FP9 (which is immininent).
Here is a quick workaround:
IF someVar <> 0 then
SET SomeVar2 = 100/(COALESCE(someVar, 1);
ELSE
SET SomeVar2 = 0;
END IF;

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.