Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1079851
  • 博文数量: 106
  • 博客积分: 9093
  • 博客等级: 中将
  • 技术积分: 2770
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-01 17:22
文章分类

全部博文(106)

文章存档

2014年(1)

2012年(29)

2011年(32)

2010年(20)

2008年(24)

分类:

2011-06-28 16:30:35

/******************************* 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) |
给主人留下些什么吧!~~