I have a column in our database that holds 4 fields as a "\" delimited string.
I have split the fields as I need them seperatly in my report.
I also need to use these fields individually as where criteria against another table.
Things I've tried: Temporary table:
CREATE GLOBAL TEMPORARY TABLE pfcc
ON COMMIT PRESERVE ROWS
AS select REGEXP_SUBSTR(s, '[^\]+', 1, 1) colA,
REGEXP_SUBSTR(s, '[^\]+', 1, 2) colB,
REGEXP_SUBSTR(s, '[^\]+', 1, 3) colC,
REGEXP_SUBSTR(s, '[^\]+', 1, 4) colD
from (select delimited s from products
where productid = 1)
And then Joining this against the other table.
select * from pfcc tmp
inner join lineitems gch
on gch.Line = tmp.colA
AND gch.productB = tmp.colB
AND gch.productC = tmp.colC
I also tried to join right off without storing values in a table:
select REGEXP_SUBSTR(s, '[^\]+', 1, 1) colA,
REGEXP_SUBSTR(s, '[^\]+', 1, 2) colB,
REGEXP_SUBSTR(s, '[^\]+', 1, 3) colC,
REGEXP_SUBSTR(s, '[^\]+', 1, 4) colD
from (select delimited s from products
where productid = 1) tmp
inner join lineitems gch
on gch.Line = tmp.colA
AND gch.productB = tmp.colB
AND gch.productC = tmp.colC
I would like to AVOID using the temporary table, and have it done similar to the second way. If this is unavoidable then so be it.
Does anyone have a solution for this?
Thanks, JFIT