select * from ptcreq where po=:po_no;
create or replace view ptcreq as
(select "SCODE","PO","STYLENO","CONTNO","DELNO","OFFNO","LNAME","COMBONO","TCOLOR","SZCODE","TSZNAME","TRIMNO","TRCODE","CSDEP","LDEP","QTY","UNIT","CLUB","SOURCE","SUPNO","DESC1" from ptcreqb1)
union
(select "SCODE","PO","STYLENO","CONTNO","DELNO","OFFNO","LNAME","COMBONO","TCOLOR","SZCODE","TSZNAME","TRIMNO","TRCODE","CSDEP","LDEP","QTY","UNIT","CLUB","SOURCE","SUPNO","DESC1" from ptcreqc3)
union
(select "SCODE","PO","STYLENO","CONTNO","DELNO","OFFNO","LNAME","COMBONO","TCOLOR","SZCODE","TSZNAME","TRIMNO","TRCODE","CSDEP","LDEP","QTY","UNIT","CLUB","SOURCE","SUPNO","DESC1" from ptcreqn3)
union
(select "SCODE","PO","STYLENO","CONTNO","DELNO","OFFNO","LNAME","COMBONO","TCOLOR","SZCODE","TSZNAME","TRIMNO","TRCODE","CSDEP","LDEP","QTY","UNIT","CLUB","SOURCE","SUPNO","DESC1" from ptcreqs3);
-------for ptcreqs3 ----------
1.
create or replace view ptcreqs3 as
select t.scode,
t.po,
t.styleno,
t.contno,
t.delno,
t.offno,
t.lname,
t.combono,
t.tcolor,
t.szcode,
t.tszname,
t.trimno,
t.trcode,
t.desc1,
t.csdep,
t.ldep,
decode(umd,
'M',
t.qty * factor,
'D',
t.qty / decode(factor, 0, 1, factor)) qty,
t2utord unit,
t.club,
t.source,
t.supno
from ptcreqs2 t, trim, t2mst, unitref
where t.trcode = trim.trcode
and trim.t2code = t2mst.t2code
and unitref.ucode = t.unit
and unitref.cucode = t2mst.t2utord;
2.
create or replace view ptcreqs2 as
select scode,
po,
t.styleno,
contno,
delno,
offno,
lname,
0 combono,
null tcolor,
t.szcode,
tszname,
s.trimno,
s.trcode,
s.desc1,
csdep,
ldep,
((nvl(cons.consumption, 0) / decode(cons.gmtpcs, 0, 1, cons.gmtpcs)) +
((nvl(cons.consumption, 0) / decode(cons.gmtpcs, 0, 1, cons.gmtpcs)) *
(nvl(cons.wastage, 0) / 100))) * qty qty,
cons.unit,
club,
source,
supno
from ptcreqS1 t, strim s, trimconsumption cons, tsize sz
where t.styleno = s.styleno
and csdep = 'S'
and s.styleno = cons.styleno
and s.trimno = cons.trimno
and s.trcode = cons.trcode
and t.szcode = decode(cons.szcode, null, t.szcode, cons.szcode)
and s.styleno = sz.styleno
and s.trimno = sz.trimno
and t.szcode = sz.szcode;
3.
create or replace view ptcreqs1 as
select s.scode,
s.po,
c1.styleno,
c1.contno,
c1.delno,
c2.offno,
lname,
off.szcode,
sum(no_of_off * off.qty) qty
from style s, contract1 c1, contract2 c2, off, label l, delivery d
where s.styleno > 50500
and s.styleno = c1.styleno
and c1.styleno = c2.styleno
and c1.contno = c2.contno
and c2.styleno = off.styleno
and c2.offno = off.offno
and c2.lcode = l.lcode
and c1.styleno = d.styleno
and c1.delno = d.delno
and NVL(d.flag, 'U') != 'C'
--and exists (select 'Y' from pomst pm where pm.pocode=s.po and pm.podate>=trunc(sysdate)-1440)
group by s.scode,
s.po,
c1.styleno,
c1.contno,
c1.delno,
c2.offno,
lname,
off.szcode;
--------------for ptcreqn3
1.
create or replace view ptcreqn3 as
select t.scode,
t.po,
t.styleno,
t.contno,
t.delno,
t.offno,
t.lname,
t.combono,
t.tcolor,
t.szcode,
t.tszname,
t.trimno,
t.trcode,
t.desc1,
t.csdep,
t.ldep,
decode(umd,
'M',
t.qty * factor,
'D',
t.qty / decode(factor, 0, 1, factor)) qty,
t2utord unit,
t.club,
t.source,
t.supno
from ptcreqn2 t, trim, t2mst, unitref
where t.trcode = trim.trcode
and trim.t2code = t2mst.t2code
and unitref.ucode = t.unit
and unitref.cucode = t2mst.t2utord;
2.
create or replace view ptcreqn2 as
select scode,
po,
t.styleno,
contno,
delno,
offno,
lname,
0 combono,
null tcolor,
0 szcode,
null tszname,
s.trimno,
s.trcode,
s.desc1,
csdep,
ldep,
((nvl(cons.consumption, 0) / decode(cons.gmtpcs, 0, 1, cons.gmtpcs)) +
((nvl(cons.consumption, 0) / decode(cons.gmtpcs, 0, 1, cons.gmtpcs)) *
(nvl(cons.wastage, 0) / 100))) * qty qty,
cons.unit,
club,
source,
supno
from ptcreqN1 t, strim s, trimconsumption cons
where t.styleno = s.styleno
and csdep = 'N'
and s.styleno = cons.styleno
and s.trimno = cons.trimno
and s.trcode = cons.trcode;
3.
create or replace view ptcreqn1 as
select s.scode,
s.po,
c1.styleno,
c1.contno,
c1.delno,
c2.offno,
lname,
sum(no_of_off * off.qty) qty
from style s, contract1 c1, contract2 c2, off, label l, delivery d
where s.styleno > 50500
and s.styleno = c1.styleno
and c1.styleno = c2.styleno
and c1.contno = c2.contno
and c2.lcode = l.lcode
and c2.styleno = off.styleno
and c2.offno = off.offno
and c1.styleno = d.styleno
and c1.delno = d.delno
and NVL(d.flag, 'U') != 'C'
--and exists (select 'Y' from pomst pm where pm.pocode=s.po and pm.podate>=trunc(sysdate)-1440)
group by s.scode, s.po, c1.styleno, c1.contno, c1.delno, c2.offno, lname;
---------for ptcreqc3
1.
create or replace view ptcreqc3 as
select t.scode,
t.po,
t.styleno,
t.contno,
t.delno,
t.offno,
t.lname,
t.combono,
t.tcolor,
t.szcode,
t.tszname,
t.trimno,
t.trcode,
t.desc1,
t.csdep,
t.ldep,
decode(umd,
'M',
t.qty * factor,
'D',
t.qty / decode(factor, 0, 1, factor)) qty,
t2utord unit,
t.club,
t.source,
t.supno
from unitref, t2mst, trim, ptcreqc2 t
where t.trcode = trim.trcode
and trim.t2code = t2mst.t2code
and unitref.ucode = t.unit
and unitref.cucode = t2mst.t2utord;
2.
create or replace view ptcreqc2 as
select scode,
po,
t.styleno,
contno,
delno,
offno,
lname,
t.combono,
tcolor,
0 szcode,
null tszname,
s.trimno,
s.trcode,
s.desc1,
csdep,
ldep,
((nvl(cons.consumption, 0) / decode(cons.gmtpcs, 0, 1, cons.gmtpcs)) +
((nvl(cons.consumption, 0) / decode(cons.gmtpcs, 0, 1, cons.gmtpcs)) *
(nvl(cons.wastage, 0) / 100))) * qty qty,
cons.unit,
club,
source,
supno
from ptcreqC1 t, strim s, trimconsumption cons, tcolor c
where t.styleno = s.styleno
and csdep = 'C'
and s.styleno = cons.styleno
and s.trimno = cons.trimno
and s.trcode = cons.trcode
and s.styleno = c.styleno
and s.trimno = c.trimno
and t.combono = c.combono
---and exists (select 'Y' from pomst pm,style stl where pm.pocode=stl.po and stl.styleno=s.styleno and pm.podate>=trunc(sysdate)-1440)
;
3.
create or replace view ptcreqc1 as
select s.scode,
s.po,
c1.styleno,
c1.contno,
c1.delno,
c2.offno,
lname,
off.combono,
sum(no_of_off * off.qty) qty
from style s, contract1 c1, contract2 c2, off, label l, delivery d
where S.STYLENO = D.STYLENO
AND D.STYLENO = C1.STYLENO
AND D.DELNO = C1.DELNO
AND C1.STYLENO = C2.STYLENO
AND C1.CONTNO = C2.CONTNO
AND C2.STYLENO = OFF.STYLENO
AND C2.OFFNO = OFF.OFFNO
AND C2.LCODE = L.LCODE
AND NVL(D.FLAG, ' ') != 'C'
AND S.STYLENO > 50500
--and exists (select 'Y' from pomst pm where pm.pocode=s.po and pm.podate>=trunc(sysdate)-1440)
group by s.scode,
s.po,
c1.styleno,
c1.contno,
c1.delno,
c2.offno,
lname,
off.combono;
--------for ptcreqb1
1.
create or replace view ptcreqb1 as
select t.scode,
t.po,
t.styleno,
t.contno,
t.delno,
t.offno,
t.lname,
t.combono,
t.tcolor,
t.szcode,
t.tszname,
t.trimno,
t.trcode,
t.desc1,
t.csdep,
t.ldep,
decode(umd,
'M',
t.qty * factor,
'D',
t.qty / decode(factor, 0, 1, factor)) qty,
t2utord unit,
t.club,
t.source,
t.supno
from ptcreqb t, trim, t2mst, unitref
where t.trcode = trim.trcode
and trim.t2code = t2mst.t2code
and unitref.ucode = t.unit
and unitref.cucode = t2mst.t2utord;
2.
create or replace view ptcreqb as
select scode,
po,
t.styleno,
contno,
delno,
offno,
lname,
t.combono,
tcolor,
t.szcode,
tszname,
s.trimno,
s.trcode,
csdep,
ldep,
((nvl(cons.consumption, 0) / decode(cons.gmtpcs, 0, 1, cons.gmtpcs)) +
((nvl(cons.consumption, 0) / decode(cons.gmtpcs, 0, 1, cons.gmtpcs)) *
(nvl(cons.wastage, 0) / 100))) * qty qty,
cons.unit,
club,
source,
supno,
desc1
from ptcreq1 t, strim s, trimconsumption cons, tcolor c, tsize sz
where t.styleno = s.styleno
and csdep = 'B'
and s.styleno = cons.styleno
and s.trimno = cons.trimno
and s.trcode = cons.trcode
and t.szcode = decode(cons.szcode, null, t.szcode, cons.szcode)
and s.styleno = c.styleno
and s.trimno = c.trimno
and t.combono = c.combono
and s.styleno = sz.styleno
and s.trimno = sz.trimno
and t.szcode = sz.szcode
--and exists(select 'Y' from pomst pm,style stl where pm.pocode=stl.po and stl.styleno=t.styleno and stl.styleno=s.styleno and pm.pocode = stl.po and pm.podate >=TRUNC(SYSDATE)-1440)
;
3.
create or replace view ptcreq1 as
select s.scode,
s.po,
c1.styleno,
c1.contno,
c1.delno,
c2.offno,
lname,
off.combono,
off.szcode,
sum(off.qty) qty
from --style s, contract1 c1, contract2 c2, off, label l, delivery d
label l,style s, delivery d, contract1 c1, contract2 c2,off
where S.STYLENO = D.STYLENO
AND D.STYLENO = C1.STYLENO
AND D.DELNO = C1.DELNO
AND C1.STYLENO = C2.STYLENO
AND C1.CONTNO = C2.CONTNO
AND C2.STYLENO = OFF.STYLENO
AND C2.OFFNO = OFF.OFFNO
AND C2.LCODE = L.LCODE
AND NVL(D.FLAG, ' ') != 'C'
AND S.STYLENO > 50500
--and exists(select 'Y' from pomst pm where pm.pocode = s.po and pm.podate >=TRUNC(SYSDATE)-1440)
GROUP BY s.scode,
s.po,
c1.styleno,
c1.contno,
c1.delno,
c2.offno,
lname,
off.combono,
off.szcode;