EXECUTE IMMEDIATE Example
This example reads an SQL statement from the terminal into a host string variable, statement_buffer. If the user enters quit, the program ends. If an error occurs, the program informs the user.
exec sql include sqlca;
read statement_buffer from terminal;
loop while (statement_buffer <> 'QUIT')
exec sql execute immediate :statement_buffer;
if (sqlcode = 0) then
exec sql commit;
else if (sqlcode = 100) then
print 'No qualifying rows for statement:';
print statement_buffer;
else
print 'Error :', sqlcode;
print 'Statement :', statement_buffer;
end if;
read statement_buffer from terminal;
end loop;
Last modified date: 08/28/2024