A more powerful way to execute arbitrary SQL statements is to prepare them once and execute the prepared statement as often as you like. It is also possible to prepare a generalized version of a statement and then execute specific versions of it by substituting parameters. When preparing the statement, write question marks where you want to substitute parameters later. For example:
EXEC SQL BEGIN DECLARE SECTION END-EXEC. 01 STMT PIC X(40) VARYING. EXEC SQL END DECLARE SECTION END-EXEC. MOVE "INSERT INTO test1 VALUES(?, ?);" TO ARR OF STMT. COMPUTE LEN OF STMT = FUNCTION STORED-CHAR-LENGTH (ARR OF STMT). EXEC SQL PREPARE MYSTMT FROM :STMT END-EXEC. ... EXEC SQL EXECUTE MYSTMT USING 42, 'foobar' END-EXEC.
When you don't need the prepared statement anymore, you should deallocate it:
EXEC SQL DEALLOCATE PREPARE name END-EXEC.