Good day!! I'm new to REXX programming. Trying to learn the basics. I ve a rexx code witch fetches records from the DB2 tables. But i don know where do i go wrong. Pls help me out. My code goes this way.
/* REXX */
SQLSTMT= "SELECT * FROM SYSIBM.SYSRESAUTH WHERE GRANTEE='XXXXXX'"
ADDRESS TSO "SUBCOM DSNREXX"
IF RC = 0 THEN
S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')
ADDRESS DSNREXX "CONNECT DSN1"
IF SQLCODE ¬=0 THEN CALL SQLCA
ADDRESS DSNREXX "EXECSQL DECLARE C1 CURSOR FOR S1"
IF SQLCODE ¬=0 THEN CALL SQLCA
ADDRESS DSNREXX "EXECSQL PREPARE S1 FROM :SQLSTMT1"
IF SQLCODE ¬=0 THEN CALL SQLCA
ADDRESS DSNREXX "EXECSQL DESCRIBE S1 INTO :OUTSQLDA"
IF SQLCODE ¬=0 THEN CALL SQLCA
ADDRESS DSNREXX "EXECSQL OPEN C1"
IF SQLCODE ¬=0 THEN CALL SQLCA
DO UNTIL(SQLCODE ¬=0)
ADDRESS DSNREXX "EXECSQL FETCH C1 USING DESCRIPTOR :OUTSQLDA"
IF SQLCODE=0 THEN
DO
DO I=1 TO OUTSQLDA.SQLD
SAY"> COLUMN NUMBER: " I
SAY" COLUMN NAME:"OUTSQLDA.I.SQLNAME"
SAY" COLUMN TYPE:"OUTSQLDA.I.SQLTYPE"
END
END
END
RETURN
SQLCA:
SAY " SQLCODE:" SQLCODE
SAY " SQLSTATE:" SQLSTATE
SAY " SQLLERRMC:" SQLLERRMC
EXIT
SQLSTMT= "SELECT * FROM SYSIBM.SYSRESAUTH WHERE GRANTEE='XXXXXX'"
ADDRESS TSO "SUBCOM DSNREXX"
IF RC = 0 THEN
S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')
ADDRESS DSNREXX "CONNECT DSN1"
IF SQLCODE ¬=0 THEN CALL SQLCA
ADDRESS DSNREXX "EXECSQL DECLARE C1 CURSOR FOR S1"
IF SQLCODE ¬=0 THEN CALL SQLCA
ADDRESS DSNREXX "EXECSQL PREPARE S1 FROM :SQLSTMT1"
IF SQLCODE ¬=0 THEN CALL SQLCA
ADDRESS DSNREXX "EXECSQL DESCRIBE S1 INTO :OUTSQLDA"
IF SQLCODE ¬=0 THEN CALL SQLCA
ADDRESS DSNREXX "EXECSQL OPEN C1"
IF SQLCODE ¬=0 THEN CALL SQLCA
DO UNTIL(SQLCODE ¬=0)
ADDRESS DSNREXX "EXECSQL FETCH C1 USING DESCRIPTOR :OUTSQLDA"
IF SQLCODE=0 THEN
DO
DO I=1 TO OUTSQLDA.SQLD
SAY"> COLUMN NUMBER: " I
SAY" COLUMN NAME:"OUTSQLDA.I.SQLNAME"
SAY" COLUMN TYPE:"OUTSQLDA.I.SQLTYPE"
END
END
END
RETURN
SQLCA:
SAY " SQLCODE:" SQLCODE
SAY " SQLSTATE:" SQLSTATE
SAY " SQLLERRMC:" SQLLERRMC
EXIT
Apologies if 'm wrong.
Regards,
Viswa.