If that were the issue though Rob, wouldn’t it also occur when applying the same WHERE clause to the originating table for the uniqueId?

The UniqueId by the way is Decimal 15,0 and that definition is consistent across the system.


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On May 12, 2016, at 11:26 AM, Rob Berendt <rob@xxxxxxxxx> wrote:

I think we're getting somewhere.
There's a difference between a 'basic' predicate, (like =)
and a BETWEEN predicate.
In a basic predicate the types must be the same.
In a BETWEEN predicate it will jumble between the two as documented in the
"Rules for result data types" below

One could try CASTing like crazy to verify if this is the situation.

Basic predicate
http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/db2/rbafzbaspred.htm?lang=en-us

BETWEEN predicate
http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/db2/rbafzbetween.htm?lang=en-us

Rules for result data types
http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/db2/rbafzopcomb.htm?lang=en



Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1
Group Dekko
Dept 1600
Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com





From: <paultherrien@xxxxxxxxxxxxxxxxxx>
To: "'Midrange Systems Technical Discussion'"
<midrange-l@xxxxxxxxxxxx>
Date: 05/12/2016 11:15 AM
Subject: RE: Weird results from WHERE clause ...
Sent by: "MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx>



What are the attributes of the field UniqueId?


Paul

-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Jon
Paris
Sent: Thursday, May 12, 2016 11:00 AM
To: Midrange-L Midrange-l
Subject: Re: Weird results from WHERE clause ...

Trust me Charles there is no typo - no room for one really if you think
about it. Simply changing the where clause at the end of a VERY large CTE
changes the result. Multiple people have looked at this and watched the
change being made in the interests of convincing ourselves of our sanity.

As
Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On May 12, 2016, at 10:09 AM, Charles Wilt <charles.wilt@xxxxxxxxx>
wrote:

Jon,

Probably need to see the actual code...guessing some sort of typo.

A quick test of your paraphase code on my system returns the same
single row results.

Charles



On Thu, May 12, 2016 at 10:05 AM, Jon Paris <jon.paris@xxxxxxxxxxxxxx>
wrote:

OK SQL gurus - need your help here. I m pretty sure this has to be
an SQL bug but if so I d have expected it to have been reported
before now and I can t find anything on IBM s site that sounds similar.

Have a large complex CTE which produces a weird result if I use = in
the WHERE compared with BETWEEN.

For example SELECT * from MyCTE where UniqueId between 50 and 50
produces the expected single row result with all columns correctly
populated.

On the other hand SELECT * from MyCTE where UniqueId = 50 also
produces a single row but all columns are empty/null. Needless to say
the results should be identical.

Originally this was run on a 6.1 system so it was moved to a pretty
current 7.1 box with identical results.


Anyone seen this or anything like it?


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L)
mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To
subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take
a moment to review the archives at
http://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take
a moment to review the archives at
http://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.