The Redbook DB2 for z/OS and OS/390 : Squeezing the Most Out of Dynamic SQL has it all
/* REXX */
ADDRESS TSO "SUBCOM DSNREXX"
SQLSTMT = "UPDATE AGENT SET ADDRESS = ? WHERE AGENTID = ?"
SAY 'ENTER YOUR ID'
SAY 'ENTER YOUR NEW ADDRESS'
"EXECSQL DECLARE C1 CURSOR FOR S1"
"EXECSQL PREPARE S1 FROM :SQLSTMT"
"EXECSQL EXECUTE S1 USING :ADDA, :AGENTIDA"
IF SQLCODE = 0 THEN
SAY 'UPDATE SUCCESSFUL'
SAY 'UPDATE OPERATION FAILED. ERROR DETAILS ARE'
SAY 'SQLCODE' SQLCODE 'AND SQLSTATE' SQLSTATE
I am sorry for asking for the code before trying anything..
I am now happy I know Dynamic SQL (I have read that 290 page book and only then started coding).