473,773 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Seek DB2 translation of complicated Oracle join statment

Can this statement be translated into DB2 ?
CREATE VIEW RELEASE_REPORTS AS (SELECT RI.GROUP_ID AS GROUP_ID,
RI.RELEASE_ID AS RELEASE_ID,
RI.TARGET_REL_I D, RI.REL_DROP, B.DROPCOUNT ,
DECODE(RI.REL_D ROP, NULL , B.DROPCOUNT ) AS RCOUNT,
RI.CREATED_DATE AS DATE_ENTERED,
RI.QA_TARGET_DA TE AS DATE_SCH_QA,
RI.TARGET_DATE AS DATE_SCH_PRD, Y.READY_FOR_QA,
X.DATA_VAL ENV, NVL(Z.REJECTS, 0) AS REJECT,
X.CREATED_DATE AS CREATED_DATE, X.REQ_DATE, X.REQ_START_TIM E,
X.EST_COMP_DATE , X.EST_COMP_TIME , X.MIN_MODIFIED_ DATE,
D.DATA_VAL AS STATUS,
X.SCM_DATE SCM_DATE,
CHAR(QUARTER(DE PSTAT.MODIFIED_ DATE)) Q,
CHAR(MONTH(DEPS TAT.MODIFIED_DA TE)) MON,
CHAR(DATE((DEPS TAT.MODIFIED_DA TE + (8 -
DAYOFWEEK(DEPST AT.MODIFIED_DAT E)) DAYS)),USA) WEEKEND,
CHAR(YEAR(DEPST AT.MODIFIED_DAT E)) YR
FROM RM_RELEASE_INFO RI, (
SELECT ENV.RELEASE_ID, ENV.DEPLOY_REQ_ ID,
DATA.DATA_VAL, ENV.CREATED_DAT E, ENV.REQ_DATE,
ENV.REQ_START_T IME, ENV.EST_COMP_DA TE,
ENV.EST_COMP_TI ME, A.SCM_DATE, A.MIN_MODIFIED_ DATE
FROM RM_LABELS_DATA DATA, RM_LABELS LABEL,
RM_DEPLOY_REQ_I NFO ENV,
(SELECT R2.DEPLOY_REQ_I D,
R1.SCM_DATE,
R2.MIN_MODIFIED _DATE
FROM (
SELECT DEPLOY_REQ_ID, MAX(MODIFIED_DA TE) SCM_DATE
FROM RM_DEPLOY_REQ_S TATUS
WHERE DEPLOY_STATUS = 8
GROUP BY DEPLOY_REQ_ID
) R1 LEFT OUTER JOIN (
SELECT DEPLOY_REQ_ID,
MIN(MODIFIED_DA TE) MIN_MODIFIED_DA TE
FROM RM_DEPLOY_REQ_S TATUS
GROUP BY DEPLOY_REQ_ID
) R2
ON R1.DEPLOY_REQ_I D = R2.DEPLOY_REQ_I D
) A
WHERE LABEL.LABEL_ID = DATA.LABEL_LABE L_ID
AND LABEL_ID = 8
AND DATA.DATA_ID = ENV.TARGET_ENV
AND ENV.DEPLOY_REQ_ ID = A.DEPLOY_REQ_ID

) X, (
SELECT RELEASE_ID, MAX(SENT_DATE) AS READY_FOR_QA
FROM RM_EMAIL_HISTOR Y
WHERE EMAIL_TYPE = 1
GROUP BY RELEASE_ID
) Y, (
SELECT RELEASE_ID, COUNT(*) AS REJECTS
FROM RM_EMAIL_HISTOR Y
WHERE EMAIL_TYPE = 3
GROUP BY RELEASE_ID
) Z, (
SELECT TARGET_REL_ID, COUNT(*) AS DROPCOUNT
FROM RM_RELEASE_INFO
WHERE REL_DROP IS NOT NULL
GROUP BY TARGET_REL_ID
) B,
(
SELECT INFO.RELEASE_ID , DATA.DATA_VAL
FROM RM_RELEASE_INFO INFO, RM_LABELS_DATA DATA
WHERE INFO.STATE = DATA.LABEL_LABE L_ID
AND INFO.STATUS = DATA.DATA_ID
) D
WHERE RI.RELEASE_ID = X.RELEASE_ID
AND RI.RELEASE_ID = Y.RELEASE_ID(+)
AND RI.RELEASE_ID = Z.RELEASE_ID(+)
AND RI.TARGET_REL_I D = B.TARGET_REL_ID (+)
AND RI.RELEASE_ID = D.RELEASE_ID
)

Nov 12 '05 #1
2 1398
gi************* ******@yahoo.co m wrote:
Can this statement be translated into DB2 ?
CREATE VIEW RELEASE_REPORTS AS (SELECT RI.GROUP_ID AS GROUP_ID,
RI.RELEASE_ID AS RELEASE_ID,
RI.TARGET_REL_I D, RI.REL_DROP, B.DROPCOUNT ,
DECODE(RI.REL_D ROP, NULL , B.DROPCOUNT ) AS RCOUNT,
RI.CREATED_DATE AS DATE_ENTERED,
RI.QA_TARGET_DA TE AS DATE_SCH_QA,
RI.TARGET_DATE AS DATE_SCH_PRD, Y.READY_FOR_QA,
X.DATA_VAL ENV, NVL(Z.REJECTS, 0) AS REJECT,
X.CREATED_DATE AS CREATED_DATE, X.REQ_DATE, X.REQ_START_TIM E,
X.EST_COMP_DATE , X.EST_COMP_TIME , X.MIN_MODIFIED_ DATE,
D.DATA_VAL AS STATUS,
X.SCM_DATE SCM_DATE,
CHAR(QUARTER(DE PSTAT.MODIFIED_ DATE)) Q,
CHAR(MONTH(DEPS TAT.MODIFIED_DA TE)) MON,
CHAR(DATE((DEPS TAT.MODIFIED_DA TE + (8 -
DAYOFWEEK(DEPST AT.MODIFIED_DAT E)) DAYS)),USA) WEEKEND,
CHAR(YEAR(DEPST AT.MODIFIED_DAT E)) YR
FROM RM_RELEASE_INFO RI, (
SELECT ENV.RELEASE_ID, ENV.DEPLOY_REQ_ ID,
DATA.DATA_VAL, ENV.CREATED_DAT E, ENV.REQ_DATE,
ENV.REQ_START_T IME, ENV.EST_COMP_DA TE,
ENV.EST_COMP_TI ME, A.SCM_DATE, A.MIN_MODIFIED_ DATE
FROM RM_LABELS_DATA DATA, RM_LABELS LABEL,
RM_DEPLOY_REQ_I NFO ENV,
(SELECT R2.DEPLOY_REQ_I D,
R1.SCM_DATE,
R2.MIN_MODIFIED _DATE
FROM (
SELECT DEPLOY_REQ_ID, MAX(MODIFIED_DA TE) SCM_DATE
FROM RM_DEPLOY_REQ_S TATUS
WHERE DEPLOY_STATUS = 8
GROUP BY DEPLOY_REQ_ID
) R1 LEFT OUTER JOIN (
SELECT DEPLOY_REQ_ID,
MIN(MODIFIED_DA TE) MIN_MODIFIED_DA TE
FROM RM_DEPLOY_REQ_S TATUS
GROUP BY DEPLOY_REQ_ID
) R2
ON R1.DEPLOY_REQ_I D = R2.DEPLOY_REQ_I D
) A
WHERE LABEL.LABEL_ID = DATA.LABEL_LABE L_ID
AND LABEL_ID = 8
AND DATA.DATA_ID = ENV.TARGET_ENV
AND ENV.DEPLOY_REQ_ ID = A.DEPLOY_REQ_ID

) X, (
SELECT RELEASE_ID, MAX(SENT_DATE) AS READY_FOR_QA
FROM RM_EMAIL_HISTOR Y
WHERE EMAIL_TYPE = 1
GROUP BY RELEASE_ID
) Y, (
SELECT RELEASE_ID, COUNT(*) AS REJECTS
FROM RM_EMAIL_HISTOR Y
WHERE EMAIL_TYPE = 3
GROUP BY RELEASE_ID
) Z, (
SELECT TARGET_REL_ID, COUNT(*) AS DROPCOUNT
FROM RM_RELEASE_INFO
WHERE REL_DROP IS NOT NULL
GROUP BY TARGET_REL_ID
) B,
(
SELECT INFO.RELEASE_ID , DATA.DATA_VAL
FROM RM_RELEASE_INFO INFO, RM_LABELS_DATA DATA
WHERE INFO.STATE = DATA.LABEL_LABE L_ID
AND INFO.STATUS = DATA.DATA_ID
) D
WHERE RI.RELEASE_ID = X.RELEASE_ID
AND RI.RELEASE_ID = Y.RELEASE_ID(+)
AND RI.RELEASE_ID = Z.RELEASE_ID(+)
AND RI.TARGET_REL_I D = B.TARGET_REL_ID (+)
AND RI.RELEASE_ID = D.RELEASE_ID
)

I think this should do (I assume (+) is on the NULL producing side)

CREATE VIEW RELEASE_REPORTS AS (SELECT RI.GROUP_ID AS GROUP_ID,
RI.RELEASE_ID AS RELEASE_ID,
RI.TARGET_REL_I D, RI.REL_DROP, B.DROPCOUNT ,
DECODE(RI.REL_D ROP, NULL , B.DROPCOUNT ) AS RCOUNT,
RI.CREATED_DATE AS DATE_ENTERED,
RI.QA_TARGET_DA TE AS DATE_SCH_QA,
RI.TARGET_DATE AS DATE_SCH_PRD, Y.READY_FOR_QA,
X.DATA_VAL ENV, NVL(Z.REJECTS, 0) AS REJECT,
X.CREATED_DATE AS CREATED_DATE, X.REQ_DATE, X.REQ_START_TIM E,
X.EST_COMP_DATE , X.EST_COMP_TIME , X.MIN_MODIFIED_ DATE,
D.DATA_VAL AS STATUS,
X.SCM_DATE SCM_DATE,
CHAR(QUARTER(DE PSTAT.MODIFIED_ DATE)) Q,
CHAR(MONTH(DEPS TAT.MODIFIED_DA TE)) MON,
CHAR(DATE((DEPS TAT.MODIFIED_DA TE + (8 -
DAYOFWEEK(DEPST AT.MODIFIED_DAT E)) DAYS)),USA) WEEKEND,
CHAR(YEAR(DEPST AT.MODIFIED_DAT E)) YR
FROM RM_RELEASE_INFO RI
INNER JOIN
(SELECT ENV.RELEASE_ID, ENV.DEPLOY_REQ_ ID,
DATA.DATA_VAL, ENV.CREATED_DAT E, ENV.REQ_DATE,
ENV.REQ_START_T IME, ENV.EST_COMP_DA TE,
ENV.EST_COMP_TI ME, A.SCM_DATE, A.MIN_MODIFIED_ DATE
FROM RM_LABELS_DATA DATA, RM_LABELS LABEL,
RM_DEPLOY_REQ_I NFO ENV,
(SELECT R2.DEPLOY_REQ_I D,
R1.SCM_DATE,
R2.MIN_MODIFIED _DATE
FROM (
SELECT DEPLOY_REQ_ID, MAX(MODIFIED_DA TE) SCM_DATE
FROM RM_DEPLOY_REQ_S TATUS
WHERE DEPLOY_STATUS = 8
GROUP BY DEPLOY_REQ_ID
) R1 LEFT OUTER JOIN (
SELECT DEPLOY_REQ_ID,
MIN(MODIFIED_DA TE) MIN_MODIFIED_DA TE
FROM RM_DEPLOY_REQ_S TATUS
GROUP BY DEPLOY_REQ_ID
) R2
ON R1.DEPLOY_REQ_I D = R2.DEPLOY_REQ_I D
) A
WHERE LABEL.LABEL_ID = DATA.LABEL_LABE L_ID
AND LABEL_ID = 8
AND DATA.DATA_ID = ENV.TARGET_ENV
AND ENV.DEPLOY_REQ_ ID = A.DEPLOY_REQ_ID

) X
ON RI.RELEASE_ID = X.RELEASE_ID
LEFT OUTER JOIN (
SELECT RELEASE_ID, MAX(SENT_DATE) AS READY_FOR_QA
FROM RM_EMAIL_HISTOR Y
WHERE EMAIL_TYPE = 1
GROUP BY RELEASE_ID
) Y
ON RI.RELEASE_ID = Y.RELEASE_ID
LEFT OUTER JOIN (
SELECT RELEASE_ID, COUNT(*) AS REJECTS
FROM RM_EMAIL_HISTOR Y
WHERE EMAIL_TYPE = 3
GROUP BY RELEASE_ID
) Z
ON RI.RELEASE_ID = Z.RELEASE_ID
LEFT OUTER JOIN (
SELECT TARGET_REL_ID, COUNT(*) AS DROPCOUNT
FROM RM_RELEASE_INFO
WHERE REL_DROP IS NOT NULL
GROUP BY TARGET_REL_ID
) B
ON RI.TARGET_REL_I D = B.TARGET_REL_ID
INNER JOIN
(
SELECT INFO.RELEASE_ID , DATA.DATA_VAL
FROM RM_RELEASE_INFO INFO, RM_LABELS_DATA DATA
WHERE INFO.STATE = DATA.LABEL_LABE L_ID
AND INFO.STATUS = DATA.DATA_ID
) D
ON RI.RELEASE_ID = D.RELEASE_ID
)

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

I got it and without your help I'd still be stuck.

Thanks so much.

Nov 12 '05 #3

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

Similar topics

0
2802
by: Matt | last post by:
Short Description: The Translation Hub is not picking up the TNS names file. I'm using Oracle 9ids. It doesn't work for any users and it has never worked since it's been installed. Long Description: The translation hub will work if the following entry is modified in the registry:
7
5122
by: Steven T. Hatton | last post by:
Is there anything that gives a good description of how source code is converted into a translation unit, then object code, and then linked. I'm particularly interested in understanding why putting normal functions in header files results in multiple definition errors even when include guards are used. -- STH Hatton's Law: "There is only One inviolable Law" KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com Mozilla:...
2
1702
by: gimme_this_gimme_that | last post by:
Might some kind soul take on this Oracle statement and translate it into DB2? Yes ... I know the equivalent of SYSDATE is CURRENT TIMESTAMP, and that DUAL is SYSIBM.SYSDUMMY1. But I'm puzzled by the 'Q' (Quarter), and NEXT_DAY translations. Thanks. SELECT TO_CHAR(SYSDATE, 'Q') Q, TO_CHAR(SYSDATE, 'MM') MON, TO_CHAR(NEXT_DAY(SYSDATE,'SUNDAY' ),'MM/DD/YYYY') WEEKEND,
39
3936
by: Arvind Varma Kalidindi | last post by:
Hi, I was asked this question in an interview recently. "How do you move to the 6th byte in a file?" ... My thinking would be to find the data types in the file, set a base pointer and advance it by 6. I mean, ptr+6. Another way to ask the same question is how do you move to the 3rd record in a file (considering that the file is made up of records). I told the interviewer that we could do a seek to move to the specific byte. At that...
1
6273
by: lovkeshanand | last post by:
Dear All, I am using the oracle transparent gateway connectivity with sql server using tg4msql,as far as settings are concerned those were set and Connectivity is working Fine, and getting the response from that server. here is description what I done as:-There is a View on Sqlserver which is Join of 6 tables and have
11
16331
by: funky | last post by:
hello, I've got a big problem ad i'm not able to resolve it. We have a server running oracle 10g version 10.1.0. We usually use access as front end and connect database tables for data extraction. We have been using oracle client 10.1.0.2 with it's odbc for a while without problem. The problem arose when we decided to reconnect all the tables and save password. Some query became suddenly very slow. Then I've discovered that the tables...
5
4518
by: Sascha.Moellering | last post by:
Hello, I want to tanslate the following Oracle-SQL to DB2, but I'm stuck, any hints? Thank you in advance. UPDATE TBZL0361CSFLQ_AGG CF INNER JOIN (SELECT * FROM TBS_AGG WHERE tbs_name = CASE WHEN CF.solve_name = 'ZAB'
0
1315
by: kellykj | last post by:
I am using PeopleSoft 8.9 with Oracle 10. Using peoplecode, I have created a select statement with a from and where clause. I stored the sql statement in app designer. On the where clause I am using %join which, when resolved, will expand and I end up with a nice complete SQL statement. I want to use the full....expanded....resolved statment in batch....SQR. Is there an Oracle command....or better syntax.....which achieves the same...
1
3216
by: Steffen Stellwag | last post by:
Truely is often better to scan a table in full passing by an index , but if you can force the optimizer to use an index via a hint for testing and comparing the results. But the index in the above example is not used , because the hint is malformed, if tables in a Select statment are named by aliases you have to specify the alias name in the hint statment , not the table name /*+ INDEX (ICWOIMP PK_ICWOIMP) */ change to /*+ INDEX (A...
0
9621
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8937
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.