473,670 Members | 2,353 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Migrate Sybase outer join query to UDB DB2 8.2

I need the below sybase code to be migrated in UDB :

select distinct
c.partnumber as I_PART,
case
when d.IntegratorID = 'DCX05' then 'U'
when d.IntegratorID = 'DCX04' then 'M'
when d.IntegratorID = 'DCX03' then 'E'
else ' ' end as 'C_LU_SRCE_PCHS NG',
o.SupplierCode as I_SUPLR_LOC,
c.ecn as I_PCHNG,
c.Revision as I_PART_CHNG_LVL ,
a.ProjectNumber as I_PROJ,
q.N_SUPLR,
a.CustomerManag er as N_MGR_CUST,
a.SupplierManag er as N_MGR_SUPLR,
a.IndustryDescr iption as X_INDUS_DESC,
a.Description as X_PROJ_DESC,
a.Title as X_TI,
a.DesignRespons ibility as X_RESPLTY_DSGN,
a.MRD as D_MATL_REDQ,
a.CreationDate as D_CREATN,
a.RiskDescripti on as C_RISK,
a.ProjectType as C_PROJ_TYP,
a.CustomerStatu s as C_PROJ_STAT,
a.CustomerOpini on as C_PROJ_CUST_OP,
a.SupplierStatu s as C_SUPLR_STAT,
a.SupplierOpini on as C_PROJ_SUPLR_OP ,
a.RiskToPending Date as D_PEND_RISKTO,
a.MethodologyNa me as N_METHD,
a.MethodologyRe visionNumber as A_REV_METH,
c.Name as N_PART,
c.Status as C_PART_STAT,
c.Catagory as C_PART_CATGY,
c.effectivedate as D_EFF_IN,
c.expirationdat e as D_EFF_OUT,
"X_PART_DES C" = rtrim(c.Name) + ' - ' +
rtrim(c.Descrip tion),
c.weight as Q_PART_WGT,
c.weightUOM as C_WGT_UM,
c.ChangeReason as C_PART_CHNG_REA S,
c.ModelYearOrde red as I_MOD_YR_1,
c.ModelYearRequ ired as I_MOD_YR_2,
c.PartType as C_PART_TYP,
h.ExpectedDate as D_DIM_EXPCTD,
h.PromiseDate as D_DIM_PROM,
h.ActualDate as D_DIM_ACTL,
h.Disposition as C_DIM_DISP,
h.ThirdPartyLab as C_DIM_PTY_THRD,
i.ExpectedDate as D_LAB_EXPCTD,
i.PromiseDate as D_LAB_PROM,
i.ActualDate as D_LAB_ACTL,
i.Disposition as C_LAB_DISP,
i.ThirdPartyLab as C_LAB_PTY_THRD,
j.ExpectedDate as D_MATL_EXPCTD,
j.PromiseDate as D_MATL_PROM,
j.ActualDate as D_MATL_ATCL,
j.Disposition as C_MATL_DISP,
j.ThirdPartyLab as C_MATL_PTY_THRD ,
k.ExpectedDate as D_PART_EXPCTD,
k.PromiseDate as D_PART_PROM,
k.ActualDate as D_PART_ACTL,
k.Disposition as C_PART_DISP,
k.ThirdPartyLab as C_PART_PTY_THRD ,
m.ExpectedDate as D_APPRNC_EXPCTD ,
m.PromiseDate as D_APPRNC_PROM,
m.ActualDate as D_APPRNC_ACTL,
m.Disposition as C_APPRNC_DISP,
m.ThirdPartyLab as C_APPRNC_PTY_TH RD,
"L_DIML_LAB_REQ D" = ' '
from E12WS..Project a,
E12WS..ProjectP art2 b,
E12WS..Part c,
E12WS..Tenant d,
E12WS..PPAP h,
E12WS..PPAP i,
E12WS..PPAP j,
E12WS..PWTMP1 l,
E12WS..PPAP k,
E12WS..PPAP m,
E125S..EPQPTSP_ TBL n,
E12WS..ProjectS upplier o,
E127S..EPQSUPL_ TBL q
where a.ProjectNumber = b.ProjectNumber
and b.PartID = c.PartID
and b.PartNumberID = c.PartNumberID
and b.PartNumberID *= h.PartNumberID
and b.PartNumberID *= i.PartNumberID
and b.PartNumberID *= j.PartNumberID
and b.PartNumberID *= k.PartNumberID
and b.PartNumberID *= m.PartNumberID
and a.CustomerID = d.TenantID
and c.partnumber = n.I_PART
and o.SupplierCode = n.I_SUPLR_LOC
and o.SupplierCode = q.I_SUPLR_LOC
and a.ProjectNumber *= h.ProjectNumber
and a.ProjectNumber *= i.ProjectNumber
and a.ProjectNumber *= j.ProjectNumber
and a.ProjectNumber *= k.ProjectNumber
and a.ProjectNumber *= m.ProjectNumber
and a.ProjectNumber = o.ProjectNumber
and l.Dim_Test *= h.TestType
and l.Lab_Test *= i.TestType
and l.Matl_Test *= j.TestType
and l.Part_Test *= k.TestType
and l.App_Test *= m.TestType

Dec 26 '05 #1
5 3604
I'm sorry, if the following statements are difficult to understand
because of my poor English.
My experience of Sybase is only that I developed one system more than 5
years ago.
So, I may misundestand or not know some special function of join of
Sybase.
But, if meaning of "*=" is usual left outer join and there is no side
effect nor extra functionality, I have some questions for original
Sybase SQL.
1) Table h, i, j, k and m are actualy same table E12WS..PPAP and
conditions for these tables are same and columns in select list are
also same.
Why need repeat completely same things.
2) Table E12WS..PWTMP1 l has no relation with other tables except
outer table in left outer join with h, i, j, k and m.
All rows of outer table of outer join will be selected into result set,
if there is no condition in WHERE clause. So, all rows of table
E12WS..PWTMP1 l will be selected and make cartesian product with result
of joining tables a, b, c, d, n ,o and q.
Original SQL's select list use distinct and no column of table l
appears in the select list.
That means It is no need to join E12WS..PWTMP1 l.
3) If some rows in E12WS..PPAP will be selected for one row of
combination a, c, d, o and q, all permutation of the selected rows of
E12WS..PPAP for each row of combination of a, c, d, o and q will appear
in result set. Is it really neccesary results?

Dec 26 '05 #2
Put aside my previous questions.

It may be not necessary to modify select list on DB2 except two.

Sybase: "X_PART_DES C" = rtrim(c.Name) + ' - ' +
rtrim(c.Descrip tion),
DB2: rtrim(c.Name) || ' - ' || rtrim(c.Descrip tion) AS "X_PART_DES C",

Sybase: "L_DIML_LAB_REQ D" = ' '
DB2: ' ' AS "L_DIML_LAB_REQ D"

My idea for FROM clause is here:

FROM E12WS.Project a
INNER JOIN
E12WS.ProjectPa rt2 b
ON a.ProjectNumber = b.ProjectNumber
INNER JOIN
E12WS.Part c
ON b.PartID = c.PartID
AND b.PartNumberID = c.PartNumberID
INNER JOIN
E12WS.Tenant d
ON a.CustomerID = d.TenantID
INNER JOIN
E12WS.ProjectSu pplier o
ON a.ProjectNumber = o.ProjectNumber
INNER JOIN
E125S.EPQPTSP_T BL n
ON c.partnumber = n.I_PART
AND o.SupplierCode = n.I_SUPLR_LOC
INNER JOIN
E127S.EPQSUPL_T BL q
ON o.SupplierCode = q.I_SUPLR_LOC
INNER JOIN
E12WS.PWTMP1 l
ON 0=0
LEFT OUTER JOIN
E12WS.PPAP h
ON a.ProjectNumber = h.ProjectNumber
AND b.PartNumberID = h.PartNumberID
AND l.Dim_Test = h.TestType
LEFT OUTER JOIN
E12WS.PPAP i
ON a.ProjectNumber = i.ProjectNumber
AND b.PartNumberID = i.PartNumberID
AND l.Dim_Test = i.TestType
LEFT OUTER JOIN
E12WS.PPAP j
ON a.ProjectNumber = j.ProjectNumber
AND b.PartNumberID = j.PartNumberID
AND l.Dim_Test = j.TestType
LEFT OUTER JOIN
E12WS.PPAP k
ON a.ProjectNumber = k.ProjectNumber
AND b.PartNumberID = k.PartNumberID
AND l.Dim_Test = k.TestType
LEFT OUTER JOIN
E12WS.PPAP m
ON a.ProjectNumber = m.ProjectNumber
AND b.PartNumberID = m.PartNumberID
AND l.Dim_Test = m.TestType

Dec 26 '05 #3
Thanks a lot... Could you please provide DB2 code the below query.
select .....
from
E126S.dbo.EPQST RU_TBL T1,
E126S.dbo.EPQPA TT_TBL T2,
E126S.dbo.EPQPO SP_TBL T3,
E126S.dbo.EPQSU PL_TBL T4 ,
E126S.dbo.EPQPS CF_TBL T5 ,
E126S.dbo.EPQPT CY_TBL T8,
E126S.dbo.EPQCO MP_TBL T7,
E126S.dbo.EPQTO OL_TBL Tpo ,
E126S.dbo.EPQRE PT_TBL T10,
E126S.dbo.EPQTL DT_TBL Tt
where T1.I_PART *= Tt.I_PART and
T1.I_PART = T2.I_PART and
T1.I_PART = T3.I_PART and
T1.I_PART *= T7.I_PART and
T3.C_LU_SRCE_PC HSNG *= T7.C_LU_SRCE_PC HSNG and
T1.I_PART = T8.I_PART and
T1.I_PART = T10.I_PART and
T3.I_PART = T10.I_PART and
T3.C_LU_SRCE_PC HSNG = T8.C_LU_SRCE_PC HSNG and
T3.C_LU_SRCE_PC HSNG = T10.C_LU_SRCE_P CHSNG and
substring(T1.I_ PART,1,8) *= Tpo.I_PART_1_8 and
T1.I_MOD_YR *= Tpo.I_MOD_YR and
T1.C_FAM *= Tpo.C_FAM and
T1.I_PART *= T5.I_PART and
T1.I_MOD_YR *= T5.I_MOD_YR and
T3.I_MOD_YR = (select min(T6.I_MOD_YR ) from E126S.dbo.EPQPO SP_TBL T6
where T6.I_PART = T1.I_PART) and
T3.I_SUPLR_MFG = T4.I_SUPLR_LOC and
T1.I_MOD_YR > 2004 and
T1.L_DEASGD = ' ' and
T1.C_STAGE_DVLP ='3' and
(T1.C_LU_PROC_1 in ('00','06','07' ,'21','35','14' ,'01','28','15' ) or
T1.C_LU_PROC_2 in ('00','06','07' ,'21','35','14' ,'01','28','15' )) and
((T1.C_LU_SRCE_ 1 like 'V%' and T1.C_LU_SRCE_1 not like 'VR%' ) or
(T1.C_LU_SRCE_2 like 'V%' and T1.C_LU_SRCE_2 not like 'VR%') ) and
T10.C_LU_PROC + T10.C_LU_SRCE + T10.C_LU_DEST <> '00VAMR' and
(T1.I_PART not in (select T12.I_PART from E126S.dbo.EPQBU YR_TBL T12
where
T12.C_LU_SRCE_P CHSNG = T3.C_LU_SRCE_PC HSNG ) or
T1.I_PART in (select T12.I_PART from E126S.dbo.EPQBU YR_TBL T12
where T12.C_LU_SRCE_P CHSNG = T3.C_LU_SRCE_PC HSNG and
T12.I_DECK_1_2 in ('AB','BB','EB' ,'MB','UB','VB' ) ) ) and
T1.I_PART in (select T11.I_PART from E126S.dbo.EPQPG PP_TBL T11
where T11.I_MOD_YR = T1.I_MOD_YR and T11.C_FAM = T1.C_FAM) and
T10.L_ACTV = 'Y'

Dec 26 '05 #4
select .....
from
E126S.dbo.EPQST RU_TBL T1
INNER JOIN
E126S.dbo.EPQPA TT_TBL T2
ON T1.I_PART = T2.I_PART
INNER JOIN
E126S.dbo.EPQPO SP_TBL T3
ON T1.I_PART = T3.I_PART
INNER JOIN
E126S.dbo.EPQSU PL_TBL T4
ON T3.I_SUPLR_MFG = T4.I_SUPLR_LOC
INNER JOIN
E126S.dbo.EPQPT CY_TBL T8
ON T1.I_PART = T8.I_PART
AND T3.C_LU_SRCE_PC HSNG = T8.C_LU_SRCE_PC HSNG
INNER JOIN
E126S.dbo.EPQRE PT_TBL T10
ON T1.I_PART = T10.I_PART
AND T3.I_PART = T10.I_PART
AND T3.C_LU_SRCE_PC HSNG = T10.C_LU_SRCE_P CHSNG
LEFT OUTER JOIN
E126S.dbo.EPQPS CF_TBL T5
ON T1.I_PART = T5.I_PART
AND T1.I_MOD_YR = T5.I_MOD_YR
LEFT OUTER JOIN
E126S.dbo.EPQCO MP_TBL T7
ON T1.I_PART = T7.I_PART
AND T3.C_LU_SRCE_PC HSNG = T7.C_LU_SRCE_PC HSNG
LEFT OUTER JOIN
E126S.dbo.EPQTO OL_TBL Tpo
ON substr(T1.I_PAR T,1,8) = Tpo.I_PART_1_8
AND T1.I_MOD_YR = Tpo.I_MOD_YR
AND T1.C_FAM = Tpo.C_FAM
LEFT OUTER JOIN
E126S.dbo.EPQTL DT_TBL Tt
ON T1.I_PART = Tt.I_PART
where
T3.I_MOD_YR
= (select min(T6.I_MOD_YR )
from E126S.dbo.EPQPO SP_TBL T6
where T6.I_PART = T1.I_PART
)
and T1.I_MOD_YR > 2004
and T1.L_DEASGD = ' '
and T1.C_STAGE_DVLP ='3'
and (T1.C_LU_PROC_1 in
('00','06','07' ,'21','35','14' ,'01','28','15' )
or
T1.C_LU_PROC_2 in
('00','06','07' ,'21','35','14' ,'01','28','15' )
)
and (SUBSTR(T1.C_LU _SRCE_1,1,1) = 'V' and SUBSTR(T1.C_LU_ SRCE_1,1,2)
<> 'VR'
or
SUBSTR(T1.C_LU_ SRCE_2,1,1) = 'V' and SUBSTR(T1.C_LU_ SRCE_2,1,2)
<> 'VR'
)
and T10.C_LU_PROC || T10.C_LU_SRCE || T10.C_LU_DEST <> '00VAMR'
and (T1.I_PART not in
(select T12.I_PART
from E126S.dbo.EPQBU YR_TBL T12
where T12.C_LU_SRCE_P CHSNG = T3.C_LU_SRCE_PC HSNG
)
or
T1.I_PART in
(select T12.I_PART
from E126S.dbo.EPQBU YR_TBL T12
where T12.C_LU_SRCE_P CHSNG = T3.C_LU_SRCE_PC HSNG
and T12.I_DECK_1_2 in ('AB','BB','EB' ,'MB','UB','VB' )
)
)
and T1.I_PART in
(select T11.I_PART
from E126S.dbo.EPQPG PP_TBL T11
where T11.I_MOD_YR = T1.I_MOD_YR
and T11.C_FAM = T1.C_FAM
)
and T10.L_ACTV = 'Y'

Dec 27 '05 #5
It works. Thanks for your help.

Dec 28 '05 #6

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

Similar topics

1
11683
by: Dave | last post by:
Hi I have the following 4 tables and I need to do a fully outerjoin on them. create table A (a number, b number, c char(10), primary key (a,b)) create table B (a number, b number, c char(10), primary key (a,b)) create table C (a number, b number, c char(10), priamry key (a,b)) create table D (a number, b number, c char(10), priamry key (a,b)) In oracle 9i, the following query returns correct results set, if I were to
1
4209
by: Steve | last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three "Left Outer Joins" in order to return every transaction for a specific set of criteria. Using three "Left Outer Joins" slows the system down considerably. I've tried creating a temp db, but I can't figure out how to execute two select commands. (It throws the exception "The column prefix 'tempdb' does not match with a table name or alias name used in the query.")
7
31549
by: Steve | last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three "Left Outer Joins" in order to return every transaction for a specific set of criteria. Using three "Left Outer Joins" slows the system down considerably. I've tried creating a temp db, but I can't figure out how to execute two select commands. (It throws the exception "The column prefix 'tempdb' does not match with a table name or alias name used in the query.")
4
8852
by: Anthony Robinson | last post by:
I was actually just wondering if someone could possibly take a look and tell me what I may be doing wrong in this query? I keep getting ambiguous column errors and have no idea why...? Thanks in advance!!! SELECT AIM.AIMRETRIEVAL.AIMRETRIEVALID, AIM.AIMRETRIEVAL.DESCRIPTION, AIM.ARCHIVERETRIEVAL.ARCHIVERETRIEVALID, AIM.ARCHIVERETRIEVAL.STATUSID,
3
23088
by: Ian Boyd | last post by:
i know nothing about DB2, but i'm sure this must be possible. i'm trying to get a client to create a view (which it turns out is called a "Logical" in DB2). The query needs a LEFT OUTER JOIN, but he doesn't know how to do that, or even if he can, and i don't have to time to learn DB2 from scratch right now. The following SQL Query is a trimmed sample of the full View (i.e. Logical) definition - and i would create it on an SQL based...
3
1402
by: sandip | last post by:
Hi all, I am facing a problem while migrating a Sybase SQL query to DB2 UDB. The query involves left outer joins. The Sybase query syntax is as follows : select * from A, B, C where A.id1 *= C.id1 and B.id2 *= C.id2
3
7544
by: deko | last post by:
From what I understand, an Inner Join narrow the rows selected to the table with the least results... and an Outer Join does the opposite... SELECT qryTxToQ1.Q1Total, qryTxToQ2.Q2Total, qryTxToQ3.Q3Total, qryTxToQ4.Q4Total FROM qryTxToQ4 OUTER JOIN (qryTxToQ3 OUTER JOIN (qryTxToQ1 OUTER JOIN qryTxToQ2 ON qryTxToQ1.TxAcct_ID = qryTxToQ2.TxAcct_ID) ON qryTxToQ3.TxAcct_ID = qryTxToQ2.TxAcct_ID) ON qryTxToQ4.TxAcct_ID = qryTxToQ3.TxAcct_ID;
3
17833
by: Doug | last post by:
Hi, I'm more familiar with MSSQL than Access syntax and have run into a problem with correctly putting ( )'s around the joins in a 3 table query. I want to INNER JOIN lenders and accounts and LEFT OUTER JOIN that result with prospects. (I want to receive all the results of the inner join and any pertinent info from table 3 that is available.) The way it was written in MSSQL was basically..
3
49493
by: nico3334 | last post by:
I currently have a query that Joins 2 Tables (Table1 and Table2) using LEFT OUTER JOIN. Here is an example of that query: SELECT a.supply, a.state, b.cost FROM Table1 a LEFT OUTER JOIN Table2 b ON a.supply = b.supply AND a.state = b.state
0
8471
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
8907
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8593
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
8663
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6218
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
5687
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();...
0
4215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4396
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.