-- run 1_datatype_data.sql before running this script
ALTER SESSION SET CURRENT_SCHEMA = SqlScriptDocumentation;
drop procedure dynamic_sql_proc;
CREATE PROCEDURE dynamic_sql_proc LANGUAGE SQLSCRIPT AS
v_sql1 VARCHAR(1024);
v_sql2 VARCHAR(1024);
v_msg VARCHAR(200);
BEGIN
init_proc();
v_sql1 := 'INSERT INTO "MESSAGE_BOX" VALUES (''First message from Dynamic SQL'', SYSTIMESTAMP)';
EXEC :v_sql1;
v_sql2 := 'INSERT INTO message_box VALUES (''Second message from Dynamic SQL'', SYSTIMESTAMP)';
EXEC :v_sql2;
v_sql1 := 'Third message from Dynamic SQL';
EXEC 'INSERT INTO message_box VALUES (''' || :v_sql1 || ''', SYSTIMESTAMP)';
END;
call dynamic_sql_proc();
select message from message_box;