Hi,
I've got a long query which needs a difficult table that is structured like so:
UB,1,000123,1,"99973245"
... in order to get the correct row, I need to use a subselect and a crap conversion to get the number into a valid date format.
The problem is ... some records will not have an entry in CREC at all, so I need to make it an outer join.... but I cant because of the subselect.
I thought about compiling the subselect into a view ... but I need to pass a parameter into it. How else could I do this ?
Maybe I could try wrap this in a function... pass in the part number and the date... it could execute the SQL and return a result if there is one, or just null if there isnt <shrug>...
I've got a long query which needs a difficult table that is structured like so:
UB,1,000123,1,"99973245"
... in order to get the correct row, I need to use a subselect and a crap conversion to get the number into a valid date format.
The problem is ... some records will not have an entry in CREC at all, so I need to make it an outer join.... but I cant because of the subselect.
I thought about compiling the subselect into a view ... but I need to pass a parameter into it. How else could I do this ?
Maybe I could try wrap this in a function... pass in the part number and the date... it could execute the SQL and return a result if there is one, or just null if there isnt <shrug>...
Code:
and crec.crec1_co_site(+) = iLine.invs1_co_site
and crec.crec1_rec_type(+) = 1
and crec.crec1_ref(+) = iLine.invspart
and crec.crec1_path(+) = 1
and crec.crec1_date = (
select min(z.crec1_date)
from mtms.crec_data@PROD_DB z
where z.crec1_co_site = crec.crec1_co_site
and z.crec1_rec_type = crec.crec1_rec_type
and z.crec1_ref = crec.crec1_ref
and z.crec1_path = crec.crec1_path
and to_date(to_char(((10000000 - z.crec1_date) - 2000000),'000000'),'YYMMDD') < iHead.invsdate_post
);