I am writing a cursor to select values from 3 tables. I want to store these values in a txt file which I will be sending via ftp. I am able to store the results of simple select queries to the txt file. but I am not sure how to store the values when using a cursor. I have given the sql query below. I will be executing this in a db2 database. could someone please help me out?
FOR CRTID AS CUR1 CURSOR FOR
SELECT CTRCTID FROM LM_ACCT_RTRVL_RQST WHERE STATUS = 'R'
DO
SELECT A.CTRCTBALAMT,
A.CTRCTEFFDATE,
A.CUSTSTCD,
B.POST_DT,
B.AMOUNT,
B.EFF_DT,
B.EXPIR_DT,
B.TXN_TYPE_CD
FROM CBSAR. SCLM9973 A, CBSAR. SCLM9967 B
WHERE A.CTRCTID = CRTID.CTRCTID AND A.CTRCTID = B.CTRCT_ID
END FOR;