How can I run a stored procedure from a CL program? RUNSQLSTM requires a source member, but I just want to build a command so users can pass in variables easily, so this won't work.
You can call the system program QZDFMDB2 and pass it one parameter with the SQL string to execute. In this case the SQL string is the call to your stored procedure:
CALL PGM(QZDFMDB2) PARM('CALL PROCEDURE (''XYZ'', ''ABC'')')
To substitute in your values use a variable for the PARM:
DCL VAR(&CALL) TYPE(*CHAR) LEN(200)
CHGVAR VAR(&CALL)
VALUE('CALL PROCEDURE (''' *CAT &PARM1 *TCAT ''', ''' *CAT &PARM2 *TCAT ''')')
CALL PGM(QZDFMDB2) PARM(&CALL)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With