Progress
Embedded SQL-92
Guide and Reference


Interrupting the Execution of an SQL Statement

During the execution of an SQL statement an interrupt can occur. When this happens the statement being executed fails and the database returns an error code in the SQLCA. The database rolls back any changes made by this particular statement. The database returns to the state it held before execution of the SQL statement.

EXAMPLE

In this sequence of operations, if the interrupt occurs during the execution of the UPDATE statement, then the UPDATE statement returns an error and all the changes made by the UPDATE statement are undone. The changes made by the INSERT statement are retained. If the statement execution proceeds to the COMMIT statement, then only the INSERT operation is made permanent, as shown in the following example:

SQL CONNECT TO DEFAULT ;
   .
   .
   .
 
EXEC SQL
     INSERT INTO orders
     VALUES (:no_v, :date_v, :prod_v, :qty_v) ;
 
/*
** If execution of the UPDATE statement is interrupted,
** the database rolls back any database modifications 
** completed by the UPDATE statement before the interrupt.
** 
** Database modifications completed by the
** INSERT statement are NOT undone.
**
** The application program should evaluate the success of each
** operation and take appropriate action.
*/
EXEC SQL
     UPDATE orders
     SET product = :prod_x
     WHERE order_date > :ord_date ;
 
/* End Transaction */
EXEC SQL COMMIT WORK ;
EXEC SQL DISCONNECT DEFAULT ; 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095