SQL script processing occurs when the application executes the SQL script variant of the Determine Actual logic command. It is controlled by each SQL script and defines the order in which the built-in SQL script methods are called.
The following diagram is of the basic SQL script process:
This process occurs upon invocation of a Determine Actual logic command specifying the SQL script:
Any internal variables, such as error result codes, are initialized.
The SQL statements in the SQL script's construct method are executed.
The SQLCODE return code is verified, and sets the JumpTo built-in segment attribute.
If errors are detected, rollback occurs and the Determine Actual logic command loop is exited.
If no record is retrieved, the Glb.Status built-in segment attribute is set to “*****” and logic control passes to the end of the Determine Actual logic command loop to execute the SQL script's destruct method (Refer to step 7).
The SQL statements in the SQL script's main method are executed.
The SQLCODE return code is verified, and sets the Glb.MainSQLCode built-in segment attribute.
If errors are detected, rollback occurs and the Determine Actual logic command loop is exited.
If no record is retrieved and it is also the first iteration through the Determine Actual logic command loop, the Glb.Status built-in segment attribute is set to “*****” and logic control passes to the end of the loop to execute the SQL script's destruct method (Refer to step 7), otherwise the Glb.Status built-in segment attribute is set to spaces.
Logic command statements within the Determine Actual logic command loop are executed.
If the Determine Actual logic command loop is exited using a Break or EndExit logic command, control passes to the end of the Determine Actual logic command loop to execute the SQL script's destruct method. If exited using a Break All logic command variant, control passes to the end of the outermost loop. If exited using an EndExit logic command, control passes to the end of the current method.
If the Determine Actual logic command loop is exited using a JumpTo logic command, control passes to the end of the Determine Actual logic command loop to execute the SQL script's destruct method before transferring control to the Label destination of the JumpTo logic command.
If the Determine Actual logic command loop is not exited using a Break or JumpTo logic command, execution returns to step 4 above.
The SQL statements in the SQL script's destruct method are executed.
The SQLCODE return code from the destruct method sets the Glb.PostSQLCode built-in segment attribute.
Examples
Selective Data Retrieval with Join Example
Selective Update Example
Database Issues
Database Issues a Refer to Determine Actual and SQL Script Variant for more infomration on SQL script usage.