INSERT v15
You can use the INSERT
command available in the SQL language in SPL programs.
You can use an expression in the SPL language wherever an expression is allowed in the SQL INSERT
command. Thus, you can use SPL variables and parameters to supply values to the insert operation.
This example is a procedure that inserts a new employee using data passed from a calling program:
If an exception occurs, all database changes made in the procedure are rolled back. In this example, the EXCEPTION
section with the WHEN OTHERS
clause catches all exceptions. Two variables are displayed. SQLCODE
is a number that identifies the specific exception that occurred. SQLERRM
is a text message explaining the error. See Exception handling for more information.
The following shows the output when this procedure is executed:
Note
You can include the INSERT
command in a FORALL
statement. A FORALL
statement allows a single INSERT
command to insert multiple rows from values supplied in one or more collections. See Using the FORALL statement for more information.