8. OpenSQL Statements : Declare Statement : DECLARE STATEMENT Example
 
Share this page                  
DECLARE STATEMENT Example
Declare one statement name for a dynamic statement that is executed ten times:
  EXEC SQL DECLARE ten_times STATEMENT;

  loop while more input
       print
        'Type in statement to be executed 10 times?';
       read statement_buffer;

  EXEC SQL PREPARE ten_times
       FROM :statement_buffer;
  loop 10 times
       EXEC SQL EXECUTE ten_times;
  end loop;
end loop;