jeudi 16 juin 2016

Select column pairs into a variable pl/sql

I am having a tupleset that I re-use multiple times:

with ICC_DATA_REQS AS
(
 select ml_tran_id, tran_type, msg_type, icc_data as icc_data_req from TRANEMV2G where msg_type = 'CQ' and (BUSINESS_DT, ML_TRAN_ID) IN (
                SELECT BUSINESS_DT, ML_TRAN_ID
                FROM TRANRSP2G
                WHERE SETTLE_FILE_ID = -1)
),

ICC_DATA_RESP AS 
(
select ml_tran_id, tran_type, msg_type, icc_data as icc_data_rsp from TRANEMV2G where msg_type = 'CS' and (BUSINESS_DT, ML_TRAN_ID) IN (
                SELECT BUSINESS_DT, ML_TRAN_ID
                FROM TRANRSP2G
                WHERE SETTLE_FILE_ID = -1)
),
ICC_DATA_ADVC AS 
(
select ml_tran_id, tran_type, msg_type, orig_ml_tran_id, icc_data as icc_data_adv from TRANEMV2G where msg_type = 'CA' and (BUSINESS_DT, ORIG_ML_TRAN_ID) IN (
                SELECT BUSINESS_DT, ML_TRAN_ID
                FROM TRANRSP2G
                WHERE SETTLE_FILE_ID = -1)
)

What I am trying to do is :

SELECT BUSINESS_DT, ML_TRAN_ID INTO vpairs
                FROM TRANRSP2G
                WHERE SETTLE_FILE_ID = -1

And then use the vpairs in the other queries. Is this possible? I keep running into unknown variable errors.

Also, the reason I am doing this whole thing is the table TRANEMV2G has 3 records, and I need data from 3 records as 3 columns. I couldn't find a better way of doing this.

Aucun commentaire:

Enregistrer un commentaire