It necessary to add the steplib ddname in the REXX where you wish to connect and work in DB2.
"STEPLIB ADD DA('<Db2 Subsystem>.DBMS.LNK', 'SYSC.<Db2 Subsystem>.SDSNLOAD') nomsg"
Db2 Subsystem value be according to your DB2 installation in your organization.
Please note that these libraries are necessary to working with DB2 in REXX.
ADDRESS DSNREXX 'CONNECT' SUBSYS
SUBSYS is a variable which contains your Db2 Subsytem name.
SQLSTMT ="SELECT * FROM " DBNAME"."TABLENAME
here DBNAME is a variable which contains your Table Qualifier
and TABLENAME is a variable which contains your Table Name.
ADDRESS DSNREXX
"EXECSQL PREPARE S1 FROM :SQLSTMT"
"EXECSQL DECLARE C1 CURSOR FOR S1"
"EXECSQL OPEN C1"
"EXECSQL FETCH C1 INTO :Your-Variable"
Your-Variable will contain the value after the execution of the SQL statement.
"EXECSQL CLOSE C1"
"STEPLIB REMOVE DA('<DB2 Subsystem>.DBMS.LNK',
'SYSC.<DB2 Subsystem>.SDSNLOAD') nomsg"
Please use the double quotes(" ") and single quotes(' ') as given above. In case of queries, please feel free to ask in the comments.
No comments:
Post a Comment