Execute non-SELECT statements

The term non-SELECT statement refers to any SQL statement that can be prepared, except SELECT and EXECUTE FUNCTION. This term includes the EXECUTE PROCEDURE statement.

Important: The INSERT statement is an exception to the rules for non-SELECT statements. If the INSERT inserts a single row, use PREPARE and EXECUTE to execute it. However, if the INSERT is associated with an insert cursor, you must declare the insert cursor.

For a list of SQL statements that cannot be prepared, see the entry for the PREPARE statement in the HCL OneDB™ Guide to SQL: Syntax.

You can execute a non-SELECT statement in the following ways:
  • If the statement is to be executed more than once, use the PREPARE and EXECUTE statements.
  • If the statement is to be executed only once, use the EXECUTE IMMEDIATE statement. This statement does have some restrictions on the statements it can execute.