473,385 Members | 1,582 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,385 software developers and data experts.

a strange sql

hi , i am trying to create such sql on db2 v8.2 on windows.
create view AP (APAM32, APNO20, APQY05, pocd01) as select APP1.APAM32,
APP1.APNO20, APP1.APQY05, COALESCE(POPT.POCD01, ' ') from APP1 left
join POPT on APP1.PONO01 = POPT.PONO01 and APP1.PONO05 = POPT.PONO05
where((POCD01<>'D') and ( POCD01<>'F') and ( POCD01<>'O')), but could
not come up with right output, so i have to do seperate steps, first
create a temporay view without where clause, then create the final view
append with the where clause, can somebody understand the mystery
behind it? thanks

Aug 31 '06 #1
6 2426
db2group88 wrote:
hi , i am trying to create such sql on db2 v8.2 on windows.
create view AP (APAM32, APNO20, APQY05, pocd01) as select APP1.APAM32,
APP1.APNO20, APP1.APQY05, COALESCE(POPT.POCD01, ' ') from APP1 left
join POPT on APP1.PONO01 = POPT.PONO01 and APP1.PONO05 = POPT.PONO05
where((POCD01<>'D') and ( POCD01<>'F') and ( POCD01<>'O')), but could
not come up with right output, so i have to do seperate steps, first
create a temporay view without where clause, then create the final view
append with the where clause, can somebody understand the mystery
behind it? thanks
If you would provide some information on the table structure, the data in
the table, the output you got, and the output you expect, then we may be
able to assist in figuring out what's going on. For all we can tell, it
may be just a mistake in the view definition...

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Aug 31 '06 #2
Hi, we are trying to create a join view based on two tables ( only have
varchar and decimal type column), If i simply create the view together
with where clause, i got less row than what it should be, that's why i
come up the other way. thank you

Knut Stolze wrote:
db2group88 wrote:
hi , i am trying to create such sql on db2 v8.2 on windows.
create view AP (APAM32, APNO20, APQY05, pocd01) as select APP1.APAM32,
APP1.APNO20, APP1.APQY05, COALESCE(POPT.POCD01, ' ') from APP1 left
join POPT on APP1.PONO01 = POPT.PONO01 and APP1.PONO05 = POPT.PONO05
where((POCD01<>'D') and ( POCD01<>'F') and ( POCD01<>'O')), but could
not come up with right output, so i have to do seperate steps, first
create a temporay view without where clause, then create the final view
append with the where clause, can somebody understand the mystery
behind it? thanks

If you would provide some information on the table structure, the data in
the table, the output you got, and the output you expect, then we may be
able to assist in figuring out what's going on. For all we can tell, it
may be just a mistake in the view definition...

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Aug 31 '06 #3
How about this?
where((POCD01<>'D') and ( POCD01<>'F') and ( POCD01<>'O'))
OR POCD01 IS NULL;

Sep 1 '06 #4
db2group88 wrote:
Hi, we are trying to create a join view based on two tables ( only have
varchar and decimal type column), If i simply create the view together
with where clause, i got less row than what it should be, that's why i
come up the other way. thank you
There may be a problem in DB2 or there may be a misconception on your side.
My point is that we can't help you at all if you don't give us a complete
scenario.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Sep 1 '06 #5

db2group88 wrote:
hi , i am trying to create such sql on db2 v8.2 on windows.
create view AP (APAM32, APNO20, APQY05, pocd01) as select APP1.APAM32,
APP1.APNO20, APP1.APQY05, COALESCE(POPT.POCD01, ' ') from APP1 left
join POPT on APP1.PONO01 = POPT.PONO01 and APP1.PONO05 = POPT.PONO05
where((POCD01<>'D') and ( POCD01<>'F') and ( POCD01<>'O')), but could
not come up with right output, so i have to do seperate steps, first
create a temporay view without where clause, then create the final view
append with the where clause, can somebody understand the mystery
behind it? thanks
Not an answer, just a note.

where((POCD01<>'D') and ( POCD01<>'F') and ( POCD01<>'O'))

should probably be

WHERE NOT POCD01 IN('D', 'F', 'O')

B.

Sep 1 '06 #6

Tonkuma wrote:
How about this?
where((POCD01<>'D') and ( POCD01<>'F') and ( POCD01<>'O'))
OR POCD01 IS NULL;
The reason of my guess is as following.
>hi , i am trying to create such sql on db2 v8.2 on windows.
create view AP (APAM32, APNO20, APQY05, pocd01) as select APP1.APAM32,
APP1.APNO20, APP1.APQY05, COALESCE(POPT.POCD01, ' ') from APP1 left
join POPT on APP1.PONO01 = POPT.PONO01 and APP1.PONO05 = OPT.PONO05
where((POCD01<>'D') and ( POCD01<>'F') and ( POCD01<>'O')), but could
not come up with right output,<<
If POCD01 is NULL, where condition get UnKnown.
Because (POCD01<>'D') =: (NULL <>'D') =: Unknown.
So, the row will not be included the result.
> so i have to do seperate steps, first
create a temporay view without where clause, then create the final view

append with the where clause, can somebody understand the mystery
behind it? thanks <<
Your temporay view would make view column pocd01 to ' '. if original
POPT.POCD01 is NULL.
Because in your original view AP, you used function
COALESCE(POPT.POCD01, ' ') for view column pocd01.
Then if you would select this temporay view with same where condition.
where condition will get True. So, the row will be included the
rresult.

Sep 4 '06 #7

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

Similar topics

2
by: Arthur | last post by:
I've come across some strange xml, that I need to deal with, it looks like this:- <root> <foo attr="1">Some random strange text. <bar attr="2">blar</bar> <bar attr="3">blar blar</bar> <bar...
2
by: Paul Drummond | last post by:
Hi all, I am developing software for Linux Redhat9 and I have noticed some very strange behaviour when throwing exceptions within a shared library. All our exceptions are derived from...
2
by: Olaf | last post by:
I have a frameset page witch contains the myFuc() function. The function is accessed from a page in one of the frames in the frameset. An example is shown below. <input...
7
by: M O J O | last post by:
Hi, I'm developing a asp.net application and ran into a strange css problem. I want all my links to have a dashed underline and when they are hovered, it must change to a solid line. Sounds...
25
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's...
0
by: unknown | last post by:
Hi, I am developing an online book store with shopping cart. My shopping cart is represented as a Xml server control and I am using an XSLT to render it at the client side. I am using an...
0
by: Kris Vanherck | last post by:
yesterday i started getting this strange error when i try to run my asp.net project: Compiler Error Message: CS0006: Metadata file 'c:\winnt\microsoft.net\framework\v1.1.4322\temporary asp.net...
11
by: Martin Joergensen | last post by:
Hi, I've encountered a really, *really*, REALLY strange error :-) I have a for-loop and after 8 runs I get strange results...... I mean: A really strange result.... I'm calculating...
20
by: SpreadTooThin | last post by:
I have a list and I need to do a custom sort on it... for example: a = #Although not necessarily in order def cmp(i,j): #to be defined in this thread. a.sort(cmp) print a
14
by: blumen | last post by:
Hi all, I'm a newbie in VB.Net Programming.. Hope that some of you can help me to solve this.. I'm working out to read,parse and save textfile into SQL Server. The textfile contains thousands...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.