Examples—Execute Immediate Statement
Create a table defined at runtime by the user:
/* User input assigned to variable new_table */
new_table = 'Create table expired_accts(acctno =
integer, name = varchar(50) not null)';
...
execute immediate new_table;
Execute a statement in a string object:
/* Declare the string object variable */
stmt_string = StringObject;
/* Prompt user for input */
status = CurFrame.ReplyPopup
(messagetext = 'Enter an SQL statement',
reply = stmt_string):
/* Execute the statement */
execute immediate stmt_string;
Execute a select statement:
/* Declarations */
emp_no = integer not null;
emp_name = varchar(256) not null;
selstring = varchar(256) not null;
/* Executing code */
selstring = 'select e_no, e_name from emp_table';
execute immediate selstring into emp_no, emp_name
begin
processing statements
end