Progress
Embedded SQL-92
Guide and Reference


EXECUTE Statement

The EXECUTE statement takes the statement identifier of a prepared statement and executes it.

EXAMPLE

The following example shows how to use the EXECUTE statement in an ESQL program:

EXEC SQL BEGIN DECLARE SECTION ;
     char sql_str [256] ;
     long cust_no_v ;
EXEC SQL END DECLARE SECTION ;
/*
** Connect to the default database
*/
EXEC SQL CONNECT TO DEFAULT ;
 
strcpy (sql_str, "delete from customer where cust_no = :p1") ; 
 
EXEC SQL PREPARE stmt FROM :sql_str ;
 
cust_no_v = 1001 ;
 
EXEC SQL EXECUTE stmt USING :cust_no_v ;
/*
** COMMIT the DELETE operation
*/
EXEC SQL COMMIT WORK ;
/*
** Disconnect from the default database.
*/
EXEC SQL DISCONNECT DEFAULT ; 

The EXECUTE statement executes the prepared DELETE statement using the values supplied for each host variable. In this example, the host variable is cust_no_v. You PREPARE the SQL statement once, and execute the statement as often as necessary in the same transaction. If you COMMIT or ROLLBACK the current transaction and you want to execute an SQL statement again, you must PREPARE it again before you can execute it.


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