0

I am able to write a REXX code that generates FREE PACKAGE statements. After generation I use that file in a JCL to execute the FREE PACKAGE statements. Is there a way to execute the FREE PACKAGE statements directly via rexx? I tried executing it like a normal query in REXX, but it throws -104 error. I believe I should not try executing it like a query. Any help would be appreciated.

  • 1
    Of course. All you have to do is allocate all the datasets required and invoke the program that will process those statements. However, if the DB2 system is not on the same LPAR as you, or your online session does not have the authority then it would fail. As you did not specify the code you used to try and get those statements executed and you did not give useful debugging information such as the error message number or the text then no further help can be given. And it did not "throw" a -104 error it "issued" a -104 code. Things are not "thrown" on a mainframe outside of USS. – NicC Dec 18 '20 at 13:00
  • The simplest method would be to submit your batch job from your Rexx program. "SUBMIT mypds(myjob)" – NicC Dec 19 '20 at 10:15

1 Answers1

3

Since it appears you have SQL working with REXX, you could use SYSPROC.ADMIN_COMMAND_DSN to perform BIND/REBIND/FREE operations. You could call this from REXX.

Here is an example CALL I used via Db2 Command Line Processor to rebind all the packages in a collection: CALL SYSPROC.ADMIN_COMMAND_DSN ('REBIND PACKAGE (DSNESPCS..())',?) #

So you would replace the 'REBIND PACKAGE...' with your BIND/REBIND/FREE commands.

There are administrative procedures delivered with Db2 for z/OS enable you to run commands, and many other administrative operations: https://www.ibm.com/support/knowledgecenter/en/SSEPEK_12.0.0/sqlref/src/tpc/db2z_suppliedstoredprocedures.html

It's mentioned above not running on the same LPAR could be a challenge. An alternate approach if you need to run commands remotely would be to create Db2 for z/OS Native Rest Services for Db2 stored procedures. So another viable option would be creating a rest service on SYSPROC.ADMIN_COMMAND_DSN, pass in the bind parameter, and execute BIND/REBIND/FREE via REST API. Then you could run the commands remotely using Java, Python, Node, etc.