Yllirion
5th July 2016, 16:15
Hi to all!
I trying to get some data with this query:
select t3.* |cag_name, cag_num, docdate, leac, deb_sum, cred_sum, descr, cor_leac, ttyp, docnum, btno, cr_user
from
(select t2.NAMA as cag_name, t.BPID as cag_num, t.DCDT as docdate, t.LEAC as leac,
(case t.DBCR when 1 then t.AMTH(1)*t.SIGN when 2 then 0 end) as deb_sum,
(case t.DBCR when 2 then t.AMTH(1)*t.SIGN when 1 then 0 end) as cred_sum,
t.REFR as descr, t.COR_LEAC as cor_leac, t.TTYP as ttyp, t.DOCN as docnum, t.BTNO as btno, t.USER as cr_user
from tfcoa102 t, tccom100 t2
where t.FYER = 2016 and t.FPRD = 6 and (t.LEAC = "161001" or t.LEAC = "161000")
and t.BPID = T2.BPID
union all
select t2.NAMA, t.BPID, t.DCDT, t.COR_LEAC,
(case t.COR_DBCR when 1 then t.AMTH(1)*t.COR_SIGN when 2 then 0 end) as deb_sum,
(case t.COR_DBCR when 2 then t.AMTH(1)*t.COR_SIGN when 1 then 0 end) as cred_sum,
t.REFR, t.LEAC, t.TTYP, t.DOCN, t.BTNO, t.USER
from tfcoa102 t, tccom100 t2
where t.FYER = 2016 and t.FPRD = 6 and (t.COR_LEAC = "161001" or t.COR_LEAC = "161000")
and t.BPID = t2.BPID
union all
select t2.NAMA, t.BPID, t.DCDT, t.LEAC,
(case t.DBCR when 1 then t.AMTH(1)*t.SIGN when 2 then 0 end) as deb_sum,
(case t.DBCR when 2 then t.AMTH(1)*t.SIGN when 1 then 0 end) as cred_sum,
t.REFR, t.COR_LEAC, t.OTYP, t.ODOC, t.OBAT, t.USER
from tfcoa106 t, tccom100 t2
where t.FYER = 2016 and t.FPRD = 6 and (t.LEAC = "161001" or t.LEAC = "161000")
and t.BPID = T2.BPID
union all
select t2.NAMA, t.BPID, t.DCDT, t.COR_LEAC,
(case t.COR_DBCR when 1 then t.AMTH(1)*t.COR_SIGN when 2 then 0 end) as deb_sum,
(case t.COR_DBCR when 2 then t.AMTH(1)*t.COR_SIGN when 1 then 0 end) as cred_sum,
t.REFR, t.LEAC, t.OTYP, t.ODOC, t.OBAT, t.USER
from tfcoa106 t, tccom100 t2
where t.FYER = 2016 and t.FPRD = 6 and (t.COR_LEAC = "161001" or t.COR_LEAC = "161000")
and t.BPID = t2.BPID
) as t3
|order by cag_num
selectdo
----do somethink---
endselect
and having this error by compiler:
Error SQL: SQLState HYL06: select item 1 must be bound explicitly (302)
If I change code:
select cag_name, cag_num, docdate, leac, deb_sum, cred_sum, descr, cor_leac, ttyp, docnum, btno, cr_user
from
(select t2.NAMA as cag_name, t.BPID as cag_num, t.DCDT as docdate, t.LEAC as leac,
(case t.DBCR when 1 then t.AMTH(1)*t.SIGN when 2 then 0 end) as deb_sum,
(case t.DBCR when 2 then t.AMTH(1)*t.SIGN when 1 then 0 end) as cred_sum,
t.REFR as descr, t.COR_LEAC as cor_leac, t.TTYP as ttyp, t.DOCN as docnum, t.BTNO as btno, t.USER as cr_user
from tfcoa102 t, tccom100 t2
where t.FYER = 2016 and t.FPRD = 6 and (t.LEAC = "161001" or t.LEAC = "161000")
and t.BPID = T2.BPID
union all
select t2.NAMA, t.BPID, t.DCDT, t.COR_LEAC,
(case t.COR_DBCR when 1 then t.AMTH(1)*t.COR_SIGN when 2 then 0 end) as deb_sum,
(case t.COR_DBCR when 2 then t.AMTH(1)*t.COR_SIGN when 1 then 0 end) as cred_sum,
t.REFR, t.LEAC, t.TTYP, t.DOCN, t.BTNO, t.USER
from tfcoa102 t, tccom100 t2
where t.FYER = 2016 and t.FPRD = 6 and (t.COR_LEAC = "161001" or t.COR_LEAC = "161000")
and t.BPID = t2.BPID
union all
select t2.NAMA, t.BPID, t.DCDT, t.LEAC,
(case t.DBCR when 1 then t.AMTH(1)*t.SIGN when 2 then 0 end) as deb_sum,
(case t.DBCR when 2 then t.AMTH(1)*t.SIGN when 1 then 0 end) as cred_sum,
t.REFR, t.COR_LEAC, t.OTYP, t.ODOC, t.OBAT, t.USER
from tfcoa106 t, tccom100 t2
where t.FYER = 2016 and t.FPRD = 6 and (t.LEAC = "161001" or t.LEAC = "161000")
and t.BPID = T2.BPID
union all
select t2.NAMA, t.BPID, t.DCDT, t.COR_LEAC,
(case t.COR_DBCR when 1 then t.AMTH(1)*t.COR_SIGN when 2 then 0 end) as deb_sum,
(case t.COR_DBCR when 2 then t.AMTH(1)*t.COR_SIGN when 1 then 0 end) as cred_sum,
t.REFR, t.LEAC, t.OTYP, t.ODOC, t.OBAT, t.USER
from tfcoa106 t, tccom100 t2
where t.FYER = 2016 and t.FPRD = 6 and (t.COR_LEAC = "161001" or t.COR_LEAC = "161000")
and t.BPID = t2.BPID
)
order by cag_num
selectdo
endselect
Error SQL: SQLState 42I00: Unexpected token 'order' (error 302)
Original Oracle query works fine:
select cag_name, cag_num, docdate, leac, deb_sum, cred_sum, descr, cor_leac, ttyp, docnum, btno, cr_user
from
(select t2.T$NAMA as cag_name, t.T$BPID as cag_num, t.T$DCDT as docdate, t.T$LEAC as leac,
case t.T$DBCR when 1 then t.T$AMTH$1*t.T$SIGN when 2 then 0 end as deb_sum,
case t.T$DBCR when 2 then t.T$AMTH$1*t.T$SIGN when 1 then 0 end as cred_sum,
t.T$REFR as descr, t.T$COR_LEAC as cor_leac, t.T$TTYP as ttyp, t.T$DOCN as docnum, t.T$BTNO as btno, t.T$USER as cr_user
from baandb.ttfcoa102552 t, baandb.ttccom100552 t2
where t.T$FYER = 2016 and t.T$FPRD = 6 and (t.T$LEAC = '161001' or t.T$LEAC = '161000')
and t.T$BPID = T2.T$BPID
union all
select t2.T$NAMA, t.T$BPID, t.T$DCDT, t.T$COR_LEAC,
case t.T$COR_DBCR when 1 then t.T$AMTH$1*t.T$COR_SIGN when 2 then 0 end as deb_sum,
case t.T$COR_DBCR when 2 then t.T$AMTH$1*t.T$COR_SIGN when 1 then 0 end as cred_sum,
t.T$REFR, t.T$LEAC, t.T$TTYP, t.T$DOCN, t.T$BTNO, t.T$USER
from baandb.ttfcoa102552 t, baandb.ttccom100552 t2
where t.T$FYER = 2016 and t.T$FPRD = 6 and (t.T$COR_LEAC = '161001' or t.T$COR_LEAC = '161000')
and t.T$BPID = t2.T$BPID
union all
select t2.T$NAMA, t.T$BPID, t.T$DCDT, t.T$LEAC,
case t.T$DBCR when 1 then t.T$AMTH$1*t.T$SIGN when 2 then 0 end as deb_sum,
case t.T$DBCR when 2 then t.T$AMTH$1*t.T$SIGN when 1 then 0 end as cred_sum,
t.T$REFR, t.T$COR_LEAC, t.T$OTYP, t.T$ODOC, t.T$OBAT, t.T$USER
from baandb.ttfcoa106552 t, baandb.ttccom100552 t2
where t.T$FYER = 2016 and t.T$FPRD = 6 and (t.T$LEAC = '161001' or t.T$LEAC = '161000')
and t.T$BPID = T2.T$BPID
union all
select t2.T$NAMA, t.T$BPID, t.T$DCDT, t.T$COR_LEAC,
case t.T$COR_DBCR when 1 then t.T$AMTH$1*t.T$COR_SIGN when 2 then 0 end as deb_sum,
case t.T$COR_DBCR when 2 then t.T$AMTH$1*t.T$COR_SIGN when 1 then 0 end as cred_sum,
t.T$REFR, t.T$LEAC, t.T$OTYP, t.T$ODOC, t.T$OBAT, t.T$USER
from baandb.ttfcoa106552 t, baandb.ttccom100552 t2
where t.T$FYER = 2016 and t.T$FPRD = 6 and (t.T$COR_LEAC = '161001' or t.T$COR_LEAC = '161000')
and t.T$BPID = t2.T$BPID
)
order by cag_num
selectdo
----do somethink---
endselect
How i can solve this problem?
I trying to get some data with this query:
select t3.* |cag_name, cag_num, docdate, leac, deb_sum, cred_sum, descr, cor_leac, ttyp, docnum, btno, cr_user
from
(select t2.NAMA as cag_name, t.BPID as cag_num, t.DCDT as docdate, t.LEAC as leac,
(case t.DBCR when 1 then t.AMTH(1)*t.SIGN when 2 then 0 end) as deb_sum,
(case t.DBCR when 2 then t.AMTH(1)*t.SIGN when 1 then 0 end) as cred_sum,
t.REFR as descr, t.COR_LEAC as cor_leac, t.TTYP as ttyp, t.DOCN as docnum, t.BTNO as btno, t.USER as cr_user
from tfcoa102 t, tccom100 t2
where t.FYER = 2016 and t.FPRD = 6 and (t.LEAC = "161001" or t.LEAC = "161000")
and t.BPID = T2.BPID
union all
select t2.NAMA, t.BPID, t.DCDT, t.COR_LEAC,
(case t.COR_DBCR when 1 then t.AMTH(1)*t.COR_SIGN when 2 then 0 end) as deb_sum,
(case t.COR_DBCR when 2 then t.AMTH(1)*t.COR_SIGN when 1 then 0 end) as cred_sum,
t.REFR, t.LEAC, t.TTYP, t.DOCN, t.BTNO, t.USER
from tfcoa102 t, tccom100 t2
where t.FYER = 2016 and t.FPRD = 6 and (t.COR_LEAC = "161001" or t.COR_LEAC = "161000")
and t.BPID = t2.BPID
union all
select t2.NAMA, t.BPID, t.DCDT, t.LEAC,
(case t.DBCR when 1 then t.AMTH(1)*t.SIGN when 2 then 0 end) as deb_sum,
(case t.DBCR when 2 then t.AMTH(1)*t.SIGN when 1 then 0 end) as cred_sum,
t.REFR, t.COR_LEAC, t.OTYP, t.ODOC, t.OBAT, t.USER
from tfcoa106 t, tccom100 t2
where t.FYER = 2016 and t.FPRD = 6 and (t.LEAC = "161001" or t.LEAC = "161000")
and t.BPID = T2.BPID
union all
select t2.NAMA, t.BPID, t.DCDT, t.COR_LEAC,
(case t.COR_DBCR when 1 then t.AMTH(1)*t.COR_SIGN when 2 then 0 end) as deb_sum,
(case t.COR_DBCR when 2 then t.AMTH(1)*t.COR_SIGN when 1 then 0 end) as cred_sum,
t.REFR, t.LEAC, t.OTYP, t.ODOC, t.OBAT, t.USER
from tfcoa106 t, tccom100 t2
where t.FYER = 2016 and t.FPRD = 6 and (t.COR_LEAC = "161001" or t.COR_LEAC = "161000")
and t.BPID = t2.BPID
) as t3
|order by cag_num
selectdo
----do somethink---
endselect
and having this error by compiler:
Error SQL: SQLState HYL06: select item 1 must be bound explicitly (302)
If I change code:
select cag_name, cag_num, docdate, leac, deb_sum, cred_sum, descr, cor_leac, ttyp, docnum, btno, cr_user
from
(select t2.NAMA as cag_name, t.BPID as cag_num, t.DCDT as docdate, t.LEAC as leac,
(case t.DBCR when 1 then t.AMTH(1)*t.SIGN when 2 then 0 end) as deb_sum,
(case t.DBCR when 2 then t.AMTH(1)*t.SIGN when 1 then 0 end) as cred_sum,
t.REFR as descr, t.COR_LEAC as cor_leac, t.TTYP as ttyp, t.DOCN as docnum, t.BTNO as btno, t.USER as cr_user
from tfcoa102 t, tccom100 t2
where t.FYER = 2016 and t.FPRD = 6 and (t.LEAC = "161001" or t.LEAC = "161000")
and t.BPID = T2.BPID
union all
select t2.NAMA, t.BPID, t.DCDT, t.COR_LEAC,
(case t.COR_DBCR when 1 then t.AMTH(1)*t.COR_SIGN when 2 then 0 end) as deb_sum,
(case t.COR_DBCR when 2 then t.AMTH(1)*t.COR_SIGN when 1 then 0 end) as cred_sum,
t.REFR, t.LEAC, t.TTYP, t.DOCN, t.BTNO, t.USER
from tfcoa102 t, tccom100 t2
where t.FYER = 2016 and t.FPRD = 6 and (t.COR_LEAC = "161001" or t.COR_LEAC = "161000")
and t.BPID = t2.BPID
union all
select t2.NAMA, t.BPID, t.DCDT, t.LEAC,
(case t.DBCR when 1 then t.AMTH(1)*t.SIGN when 2 then 0 end) as deb_sum,
(case t.DBCR when 2 then t.AMTH(1)*t.SIGN when 1 then 0 end) as cred_sum,
t.REFR, t.COR_LEAC, t.OTYP, t.ODOC, t.OBAT, t.USER
from tfcoa106 t, tccom100 t2
where t.FYER = 2016 and t.FPRD = 6 and (t.LEAC = "161001" or t.LEAC = "161000")
and t.BPID = T2.BPID
union all
select t2.NAMA, t.BPID, t.DCDT, t.COR_LEAC,
(case t.COR_DBCR when 1 then t.AMTH(1)*t.COR_SIGN when 2 then 0 end) as deb_sum,
(case t.COR_DBCR when 2 then t.AMTH(1)*t.COR_SIGN when 1 then 0 end) as cred_sum,
t.REFR, t.LEAC, t.OTYP, t.ODOC, t.OBAT, t.USER
from tfcoa106 t, tccom100 t2
where t.FYER = 2016 and t.FPRD = 6 and (t.COR_LEAC = "161001" or t.COR_LEAC = "161000")
and t.BPID = t2.BPID
)
order by cag_num
selectdo
endselect
Error SQL: SQLState 42I00: Unexpected token 'order' (error 302)
Original Oracle query works fine:
select cag_name, cag_num, docdate, leac, deb_sum, cred_sum, descr, cor_leac, ttyp, docnum, btno, cr_user
from
(select t2.T$NAMA as cag_name, t.T$BPID as cag_num, t.T$DCDT as docdate, t.T$LEAC as leac,
case t.T$DBCR when 1 then t.T$AMTH$1*t.T$SIGN when 2 then 0 end as deb_sum,
case t.T$DBCR when 2 then t.T$AMTH$1*t.T$SIGN when 1 then 0 end as cred_sum,
t.T$REFR as descr, t.T$COR_LEAC as cor_leac, t.T$TTYP as ttyp, t.T$DOCN as docnum, t.T$BTNO as btno, t.T$USER as cr_user
from baandb.ttfcoa102552 t, baandb.ttccom100552 t2
where t.T$FYER = 2016 and t.T$FPRD = 6 and (t.T$LEAC = '161001' or t.T$LEAC = '161000')
and t.T$BPID = T2.T$BPID
union all
select t2.T$NAMA, t.T$BPID, t.T$DCDT, t.T$COR_LEAC,
case t.T$COR_DBCR when 1 then t.T$AMTH$1*t.T$COR_SIGN when 2 then 0 end as deb_sum,
case t.T$COR_DBCR when 2 then t.T$AMTH$1*t.T$COR_SIGN when 1 then 0 end as cred_sum,
t.T$REFR, t.T$LEAC, t.T$TTYP, t.T$DOCN, t.T$BTNO, t.T$USER
from baandb.ttfcoa102552 t, baandb.ttccom100552 t2
where t.T$FYER = 2016 and t.T$FPRD = 6 and (t.T$COR_LEAC = '161001' or t.T$COR_LEAC = '161000')
and t.T$BPID = t2.T$BPID
union all
select t2.T$NAMA, t.T$BPID, t.T$DCDT, t.T$LEAC,
case t.T$DBCR when 1 then t.T$AMTH$1*t.T$SIGN when 2 then 0 end as deb_sum,
case t.T$DBCR when 2 then t.T$AMTH$1*t.T$SIGN when 1 then 0 end as cred_sum,
t.T$REFR, t.T$COR_LEAC, t.T$OTYP, t.T$ODOC, t.T$OBAT, t.T$USER
from baandb.ttfcoa106552 t, baandb.ttccom100552 t2
where t.T$FYER = 2016 and t.T$FPRD = 6 and (t.T$LEAC = '161001' or t.T$LEAC = '161000')
and t.T$BPID = T2.T$BPID
union all
select t2.T$NAMA, t.T$BPID, t.T$DCDT, t.T$COR_LEAC,
case t.T$COR_DBCR when 1 then t.T$AMTH$1*t.T$COR_SIGN when 2 then 0 end as deb_sum,
case t.T$COR_DBCR when 2 then t.T$AMTH$1*t.T$COR_SIGN when 1 then 0 end as cred_sum,
t.T$REFR, t.T$LEAC, t.T$OTYP, t.T$ODOC, t.T$OBAT, t.T$USER
from baandb.ttfcoa106552 t, baandb.ttccom100552 t2
where t.T$FYER = 2016 and t.T$FPRD = 6 and (t.T$COR_LEAC = '161001' or t.T$COR_LEAC = '161000')
and t.T$BPID = t2.T$BPID
)
order by cag_num
selectdo
----do somethink---
endselect
How i can solve this problem?