473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Division by Zero or changed order of applying predicates in SQL

Hi Folks,

one of our developers uses a statement with a where clause which
usually does not match to any rows. In case of one or more rows found
she wrote a an expression in the select clause which evaluates to a
"division by zero" on purpose to raise an alarm (dirty)

This is the statement:

SELECT
1/VALUE(0,0) <-- this is the point of interest
FROM BIS.SVCPLAN
WHERE (PLANDATUM + 1 DAY) <> DATE('2005-07-13')
AND ANWENDUNG = 'XXX'

Prior DB2 Version 8 Fixpak 9a it worked but after applying the latest
fix it seems that DB2 evaluates the Division by zero expression in the
select clause before evaluting the where clause. Can anybody confirm
this?

I am not a fan of the above approach, however, the developer argues
that this has worked for years and does not work anymore after applying
Fixpak 9a. The developers have hundreds of batches with this way to
raise alarms in case of a matching where clause....

Cheers
Florian

Nov 12 '05 #1
1 1995
fl***********@itgain.de wrote:
Hi Folks,

one of our developers uses a statement with a where clause which
usually does not match to any rows. In case of one or more rows found
she wrote a an expression in the select clause which evaluates to a
"division by zero" on purpose to raise an alarm (dirty)

This is the statement:

SELECT
1/VALUE(0,0) <-- this is the point of interest
FROM BIS.SVCPLAN
WHERE (PLANDATUM + 1 DAY) <> DATE('2005-07-13')
AND ANWENDUNG = 'XXX'

Prior DB2 Version 8 Fixpak 9a it worked but after applying the latest
fix it seems that DB2 evaluates the Division by zero expression in the
select clause before evaluting the where clause. Can anybody confirm
this?

I am not a fan of the above approach, however, the developer argues
that this has worked for years and does not work anymore after applying
Fixpak 9a. The developers have hundreds of batches with this way to
raise alarms in case of a matching where clause....

Cheers
Florian

*sigh* This has turned into a FAQ....
DB2 is rather agressive about evaluating constant expressions.
I.e. it tries to avoid re-computing the expression for every row in
BIS.SVCPLAN (which may, in general, be many).
As DB2 gets better and better about this optimization customers who have
written statements like yours get themselves into trouble.
I would appreciate if you could raise a PMR (call support). Have them
route straight to me (no busy loops with L1/L2 support please).
This needs to get fixed at the root - once and for all.

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: bart van deun | last post by:
Hello, i have a problem with a division by zero fault in my report trough a query... this is the expression in the query: Name: Sum(IIF(=0,0,/)) what is wrong with this expression?
8
by: silentlights | last post by:
Hi, Is there a possibiliy to improve division or Modulo operations in the following, tmp1 = 123; tmp2 = 123; frame = ((char)((tmp1/100)+48)); // Division tmp1 = (tmp2...
9
by: Marcin | last post by:
How I can make division of two numbers placed in arrays, example: short int a = {2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2}; short int b =...
16
by: Greg Donald | last post by:
Converting some MySQL code to work with Postgres here. I have this query: SELECT tasks.task_id, (tasks.task_duration * tasks.task_duration_type / count(user_tasks.task_id)) as...
17
by: seb.haase | last post by:
Hi, Is it true that that "Python 3000" is dead ? Honestly I think that e.g. changing 5/2 to be 2.5 (instead of 2) would just break to much code :-( On the otherhand I'm using Python as "Matlab...
2
by: subnunciation | last post by:
i know, this shouldnt be a conundrum right? one just shouldnt divide by zero. but this is suddenly happening *all over* my site. after chasing the error here and there, i simplified things down to:...
2
by: Pakna | last post by:
Why do I have a zero result on this query for all non-zero rows? Do I have to declare specifically the precision of ratio division? How do I do that? And is there a way to make DB2 'ignore'...
94
by: krypto.wizard | last post by:
Last month I appeared for an interview with EA sports and they asked me this question. How would you divide a number by 7 without using division operator ? I did by doing a subtraction and...
9
by: Joe Cool | last post by:
Hello, I am using VS2005. I am trying to convert a VB.NET app to C#.NET. The VB app uses a progress meter to indiate how far a file has been read. I use the following assignment statement in VB: ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.