Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > DB2

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 05:41 AM
kumar_rangan1976@yahoo.co.in
 
Posts: n/a
Default 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_PCHSNG',
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.CustomerManager as N_MGR_CUST,
a.SupplierManager as N_MGR_SUPLR,
a.IndustryDescription as X_INDUS_DESC,
a.Description as X_PROJ_DESC,
a.Title as X_TI,
a.DesignResponsibility as X_RESPLTY_DSGN,
a.MRD as D_MATL_REDQ,
a.CreationDate as D_CREATN,
a.RiskDescription as C_RISK,
a.ProjectType as C_PROJ_TYP,
a.CustomerStatus as C_PROJ_STAT,
a.CustomerOpinion as C_PROJ_CUST_OP,
a.SupplierStatus as C_SUPLR_STAT,
a.SupplierOpinion as C_PROJ_SUPLR_OP,
a.RiskToPendingDate as D_PEND_RISKTO,
a.MethodologyName as N_METHD,
a.MethodologyRevisionNumber 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.expirationdate as D_EFF_OUT,
"X_PART_DESC" = rtrim(c.Name) + ' - ' +
rtrim(c.Description),
c.weight as Q_PART_WGT,
c.weightUOM as C_WGT_UM,
c.ChangeReason as C_PART_CHNG_REAS,
c.ModelYearOrdered as I_MOD_YR_1,
c.ModelYearRequired 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_THRD,
"L_DIML_LAB_REQD" = ' '
from E12WS..Project a,
E12WS..ProjectPart2 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..ProjectSupplier 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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 05:41 AM
Tonkuma
 
Posts: n/a
Default Re: Migrate Sybase outer join query to UDB DB2 8.2

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?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 05:41 AM
Tonkuma
 
Posts: n/a
Default Re: Migrate Sybase outer join query to UDB DB2 8.2

Put aside my previous questions.

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

Sybase: "X_PART_DESC" = rtrim(c.Name) + ' - ' +
rtrim(c.Description),
DB2: rtrim(c.Name) || ' - ' || rtrim(c.Description) AS "X_PART_DESC",

Sybase: "L_DIML_LAB_REQD" = ' '
DB2: ' ' AS "L_DIML_LAB_REQD"

My idea for FROM clause is here:

FROM E12WS.Project a
INNER JOIN
E12WS.ProjectPart2 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.ProjectSupplier o
ON a.ProjectNumber = o.ProjectNumber
INNER JOIN
E125S.EPQPTSP_TBL n
ON c.partnumber = n.I_PART
AND o.SupplierCode = n.I_SUPLR_LOC
INNER JOIN
E127S.EPQSUPL_TBL 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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 05:41 AM
kumar_rangan1976@yahoo.co.in
 
Posts: n/a
Default Re: Migrate Sybase outer join query to UDB DB2 8.2

Thanks a lot... Could you please provide DB2 code the below query.
select .....
from
E126S.dbo.EPQSTRU_TBL T1,
E126S.dbo.EPQPATT_TBL T2,
E126S.dbo.EPQPOSP_TBL T3,
E126S.dbo.EPQSUPL_TBL T4 ,
E126S.dbo.EPQPSCF_TBL T5 ,
E126S.dbo.EPQPTCY_TBL T8,
E126S.dbo.EPQCOMP_TBL T7,
E126S.dbo.EPQTOOL_TBL Tpo ,
E126S.dbo.EPQREPT_TBL T10,
E126S.dbo.EPQTLDT_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_PCHSNG *= T7.C_LU_SRCE_PCHSNG 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_PCHSNG = T8.C_LU_SRCE_PCHSNG and
T3.C_LU_SRCE_PCHSNG = T10.C_LU_SRCE_PCHSNG 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.EPQPOSP_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.EPQBUYR_TBL T12
where
T12.C_LU_SRCE_PCHSNG = T3.C_LU_SRCE_PCHSNG ) or
T1.I_PART in (select T12.I_PART from E126S.dbo.EPQBUYR_TBL T12
where T12.C_LU_SRCE_PCHSNG = T3.C_LU_SRCE_PCHSNG 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.EPQPGPP_TBL T11
where T11.I_MOD_YR = T1.I_MOD_YR and T11.C_FAM = T1.C_FAM) and
T10.L_ACTV = 'Y'

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-27-2008, 05:41 AM
Tonkuma
 
Posts: n/a
Default Re: Migrate Sybase outer join query to UDB DB2 8.2

select .....
from
E126S.dbo.EPQSTRU_TBL T1
INNER JOIN
E126S.dbo.EPQPATT_TBL T2
ON T1.I_PART = T2.I_PART
INNER JOIN
E126S.dbo.EPQPOSP_TBL T3
ON T1.I_PART = T3.I_PART
INNER JOIN
E126S.dbo.EPQSUPL_TBL T4
ON T3.I_SUPLR_MFG = T4.I_SUPLR_LOC
INNER JOIN
E126S.dbo.EPQPTCY_TBL T8
ON T1.I_PART = T8.I_PART
AND T3.C_LU_SRCE_PCHSNG = T8.C_LU_SRCE_PCHSNG
INNER JOIN
E126S.dbo.EPQREPT_TBL T10
ON T1.I_PART = T10.I_PART
AND T3.I_PART = T10.I_PART
AND T3.C_LU_SRCE_PCHSNG = T10.C_LU_SRCE_PCHSNG
LEFT OUTER JOIN
E126S.dbo.EPQPSCF_TBL T5
ON T1.I_PART = T5.I_PART
AND T1.I_MOD_YR = T5.I_MOD_YR
LEFT OUTER JOIN
E126S.dbo.EPQCOMP_TBL T7
ON T1.I_PART = T7.I_PART
AND T3.C_LU_SRCE_PCHSNG = T7.C_LU_SRCE_PCHSNG
LEFT OUTER JOIN
E126S.dbo.EPQTOOL_TBL Tpo
ON substr(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
LEFT OUTER JOIN
E126S.dbo.EPQTLDT_TBL Tt
ON T1.I_PART = Tt.I_PART
where
T3.I_MOD_YR
= (select min(T6.I_MOD_YR)
from E126S.dbo.EPQPOSP_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.EPQBUYR_TBL T12
where T12.C_LU_SRCE_PCHSNG = T3.C_LU_SRCE_PCHSNG
)
or
T1.I_PART in
(select T12.I_PART
from E126S.dbo.EPQBUYR_TBL T12
where T12.C_LU_SRCE_PCHSNG = T3.C_LU_SRCE_PCHSNG
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.EPQPGPP_TBL T11
where T11.I_MOD_YR = T1.I_MOD_YR
and T11.C_FAM = T1.C_FAM
)
and T10.L_ACTV = 'Y'

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-27-2008, 05:41 AM
kumar_rangan1976@yahoo.co.in
 
Posts: n/a
Default Re: Migrate Sybase outer join query to UDB DB2 8.2

It works. Thanks for your help.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:39 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846