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

Re: Rewrite LUW query to work on z/OS

VGD

"Serge Rielau" <sr*****@ca.ibm.comescribió en el mensaje
news:6e************@mid.individual.net...
I have my doubts as to whether DB2 V8 for zOS supports the WITH clause.
Try this:
select
distinct
value_list.C1 ,
case when Table_val.C2 is null then '?' else Table_val.C2 end
from
Table_val
right outer join
( values
('V2'),
('V2'),
('V3'),
('V4'),
('Vempty'),
('Vempty')
) AS value_list
...

I'm wondering about the VALUES clause as well.
For a LEFT OUTER JOIN the rewrite would be an IN list.
Not obvious (to me) how to get rid of it for a ROJ other than inserting
the content into a temp table.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

Hello Serge

I've checked that DB2 OS/390 8.1.5 accepts WITH clause but doesn't accept
VALUES clause in the context I need.

This is the final SQL sentence we will use:

select
distinct
value_list.C1 ,
case when Table_val.C2 is null then '?' else Table_val.C2 end
from
Table_val
right outer join
(
select 'V2' as C1 from sysibm.sysdummy1 union
select 'V2' as C1 from sysibm.sysdummy1 union
select 'V3' as C1 from sysibm.sysdummy1 union
select 'V4' as C1 from sysibm.sysdummy1 union
select 'Vempty' as C1 from sysibm.sysdummy1 union
select 'Vempty' as C1 from sysibm.sysdummy1 union
) as Value_list
on
Table_val.C1 = Value_list.C1
where
Table_val.C1 <'Vempty';
Thank you very much

Vicente



Jul 17 '08 #1
3 1810
On Jul 17, 3:03 pm, "VGD" <vgar...@boxcounty.comwrote:
"Serge Rielau" <srie...@ca.ibm.comescribió en el mensajenews:6e************@mid.individual.net...
I have my doubts as to whether DB2 V8 for zOS supports the WITH clause.
Try this:
select
distinct
value_list.C1 ,
case when Table_val.C2 is null then '?' else Table_val.C2 end
from
Table_val
right outer join
( values
('V2'),
('V2'),
('V3'),
('V4'),
('Vempty'),
('Vempty')
) AS value_list
...
I'm wondering about the VALUES clause as well.
For a LEFT OUTER JOIN the rewrite would be an IN list.
Not obvious (to me) how to get rid of it for a ROJ other than inserting
the content into a temp table.
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

Hello Serge

I've checked that DB2 OS/390 8.1.5 accepts WITH clause but doesn't accept
VALUES clause in the context I need.

This is the final SQL sentence we will use:

select
distinct
value_list.C1 ,
case when Table_val.C2 is null then '?' else Table_val.C2 end
from
Table_val
right outer join
(
select 'V2' as C1 from sysibm.sysdummy1 union
select 'V2' as C1 from sysibm.sysdummy1 union
select 'V3' as C1 from sysibm.sysdummy1 union
select 'V4' as C1 from sysibm.sysdummy1 union
select 'Vempty' as C1 from sysibm.sysdummy1 union
select 'Vempty' as C1 from sysibm.sysdummy1 union
) as Value_list
on
Table_val.C1 = Value_list.C1
where
Table_val.C1 <'Vempty';

Thank you very much

Vicente
Why do you have V2 and Vempty twice in Value_list?

/Lennart

Jul 17 '08 #2
Lennart wrote:
On Jul 17, 3:03 pm, "VGD" <vgar...@boxcounty.comwrote:
>"Serge Rielau" <srie...@ca.ibm.comescribió en el mensajenews:6e************@mid.individual.net...
>>I have my doubts as to whether DB2 V8 for zOS supports the WITH clause.
Try this:
select
distinct
value_list.C1 ,
case when Table_val.C2 is null then '?' else Table_val.C2 end
from
Table_val
right outer join
( values
('V2'),
('V2'),
('V3'),
('V4'),
('Vempty'),
('Vempty')
) AS value_list
...
I'm wondering about the VALUES clause as well.
For a LEFT OUTER JOIN the rewrite would be an IN list.
Not obvious (to me) how to get rid of it for a ROJ other than inserting
the content into a temp table.
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Hello Serge

I've checked that DB2 OS/390 8.1.5 accepts WITH clause but doesn't accept
VALUES clause in the context I need.

This is the final SQL sentence we will use:

select
distinct
value_list.C1 ,
case when Table_val.C2 is null then '?' else Table_val.C2 end
from
Table_val
right outer join
(
select 'V2' as C1 from sysibm.sysdummy1 union
select 'V2' as C1 from sysibm.sysdummy1 union
select 'V3' as C1 from sysibm.sysdummy1 union
select 'V4' as C1 from sysibm.sysdummy1 union
select 'Vempty' as C1 from sysibm.sysdummy1 union
select 'Vempty' as C1 from sysibm.sysdummy1 union
) as Value_list
on
Table_val.C1 = Value_list.C1
where
Table_val.C1 <'Vempty';

Thank you very much

Vicente

Why do you have V2 and Vempty twice in Value_list?
...a ssuming that that's purpose then you want to use UNION ALL to
preserve the duplicates.
(You want UNION ALL wherever possible)
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jul 17 '08 #3
VGD
>
"Lennart" <Er******************@gmail.comescribió en el mensaje
news:ac**********************************@k30g2000 hse.googlegroups.com...

This is the final SQL sentence we will use:

select
distinct
value_list.C1 ,
case when Table_val.C2 is null then '?' else Table_val.C2 end
from
Table_val
right outer join
(
select 'V2' as C1 from sysibm.sysdummy1 union
select 'V2' as C1 from sysibm.sysdummy1 union
select 'V3' as C1 from sysibm.sysdummy1 union
select 'V4' as C1 from sysibm.sysdummy1 union
select 'Vempty' as C1 from sysibm.sysdummy1 union
select 'Vempty' as C1 from sysibm.sysdummy1 union
) as Value_list
on
Table_val.C1 = Value_list.C1
where
Table_val.C1 <'Vempty';

Thank you very much

Vicente

Why do you have V2 and Vempty twice in Value_list?

/Lennart
I need to search for up to 10 items and I need to know those who have not
been found. And, for unused SearchFor arguments, the main program will fill
it up with 'Vempty' ("never spected to be found" value) because C1 can be
blank.

In fact, the real SQL is more like this:

select
distinct
value_list.C1 ,
case when Table_val.C2 is null then '<C2 not found>' else
Table_val.C2 end
case when Table_val.C3 is null then '<C3 not found>' else
Table_val.C3 end
case when Table_val.C4 is null then '<C4 not found>' else
Table_val.C4 end
case when Table_val.C5 is null then '<C5 not found>' else
Table_val.C5 end
from
Table_val
right outer join
(
select :SearchFor[0] as C1 from sysibm.sysdummy1 union
select :SearchFor[1] as C1 from sysibm.sysdummy1 union
select :SearchFor[2] as C1 from sysibm.sysdummy1 union
select :SearchFor[3] as C1 from sysibm.sysdummy1 union
select :SearchFor[4] as C1 from sysibm.sysdummy1 union
select :SearchFor[5] as C1 from sysibm.sysdummy1 union
select :SearchFor[6] as C1 from sysibm.sysdummy1 union
select :SearchFor[7] as C1 from sysibm.sysdummy1 union
select :SearchFor[8] as C1 from sysibm.sysdummy1 union
select :SearchFor[9] as C1 from sysibm.sysdummy1
) as Value_list
on
Table_val.C1 = Value_list.C1
where
Table_val.C1 <'Vempty';
Regards

Vicente


Jul 18 '08 #4

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

Similar topics

0
by: krystoffff | last post by:
Hi all For speed reasons, I would like to rewrite the following query without the subquery : SELECT * FROM table1 WHERE field1 NOT IN (SELECT field1 FROM table2 where field2=X); I thought...
4
by: rajesh.balu | last post by:
I created a MQT defined as: select a.col1,a.col2,a.col3,b.col1.b.col2 from a , b where a.id = b.id Now, I execute this query which get rewritten to the MQT: select a.col1,b.col1, c.val from...
2
by: VM | last post by:
I'm about to work on a 'buggy' WIndows C GUI application that was entirely made in C. All the user controls were all hard-coded and the code is pretty hard to understand. The application was made...
1
by: DDK | last post by:
How would you go about rewriting a URL such as: http://www.mysite.com/folder/page.aspx?query=WordnotNumber to: http://www.mysite.com/folder/WordnotNumber In other words I would like to put...
7
by: Stan Canepa | last post by:
I am looking for good documentation to help support rewriting a VB 6 app in Dot Net. I looking for things like VB 6 being unsupported in March 2008, general performance improvements, at what point...
14
by: Stan Canepa | last post by:
This post is mostly for discussion. Why rewrite in .NET? Just a general discussion not related to any specific details. I was just looking to see what reasons developers are looking to, to help...
6
by: Jon Slaughter | last post by:
How the heck do I get mod rewrite to add extensions to any file? RewriteRule ^(.*)$ $1\.php To me that should find any group of characters(such as any path) and then add the .php to the end? ...
1
by: soniamuk | last post by:
i am facing a typical issue with apache where i have a filter context(written in c++) which pulls information from apache server. in this process when i am trying to fetch an url where rewrite rule...
1
by: polilop | last post by:
Is there a URL rewrite module that allows to rewrite url by looking at the database. Egxample: http://www.somesite.com/object.aspx?objectCountryId=1&objectId=22 now i look into the database, see...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.