/******************************* REXX *********************************/
/* this is a sample for connect db2. */
/**********************************************************************/
/* CHECK TO SEE IF THE REXX/DB2 COMMAND ENVIRONMENT IS AVAILABLE */
/* IF IT IS NOT, THEN ESTABLISH IT. */
/* THEN CONNECT TO THE APPROPRIATE DATABASE (SUBSYSTEM) */
"SUBCOM DSNREXX"
IF RC THEN
S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')
/* CHANGE DB2T IN THE LINE BELOW TO YOUR TARGET SUBSYSTEM */
ADDRESS DSNREXX 'CONNECT' DB2T
IF SQLCODE \= '0' THEN DO
SAY 'FAILURE TO CONNECT TO DATABASE'
EXIT 8
END
/* SET A VARIABLE EQUAL TO THE DESIRED SQL STATMENT. */
/* GET ALL IMAGE COPY DATASETS FOR THE TRADELINE INDEX FROM THE */
/* LAST IMAGE COPY TAKEN. SORT THEM BY PARTITION. */
/* */
SQLSTMT="SELECT 'HELLO' FROM SYSIBM.SYSDUMMY1"
/* PREPARE THE STATEMENT FOR EXECUTION BY DECLARING THE CURSOR, */
/* DOING A PREPARE OF THE STATEMENT, AND OPENING THE CURSOR. */
/* */
ADDRESS DSNREXX
"EXECSQL DECLARE C1 CURSOR FOR S1"
IF SQLCODE \= "0" THEN DO
SAY "DECLARE CURSOR FAILED WITH SQLCODE = " SQLCODE
EXIT 8
END
"EXECSQL PREPARE S1 FROM :SQLSTMT"
IF SQLCODE \= "0" THEN DO
SAY "PREPARE FAILED WITH SQLCODE = " SQLCODE
EXIT 8
END
"EXECSQL OPEN C1"
IF SQLCODE \= "0" THEN DO
SAY "OPEN FAILED WITH SQLCODE = " SQLCODE
EXIT 8
END
/* */
/* FETCH LOOP. FOR EACH ROW RETURNED WRITE THE APPROPRATE RECOVERY*/
/* JCL AND CONTROL CARDS. */
/* */
DO UNTIL SQLCODE \= "0"
"EXECSQL FETCH C1 INTO :TESTMSG"
IF SQLCODE == "0" THEN DO
/* FOR EACH START OF A SET OF DATASETS, BEGIN A NEW JOB. */
/* */
SAY TESTMSG
END
END
/* CLEANUP. */
/* DISCONNECT FROM THE DATABASE, AND RELEASE ALLOCATIONS. */
/* */
ADDRESS DSNREXX "DISCONNECT"
S_RC = RXSUBCOM('DELETE','DSNREXX','DSNREXX')
EXIT 0
阅读(1110) | 评论(0) | 转发(1) |