Progress
SQL-92
Guide and Reference
Executing an SQL-92 Statement
If an SQL-92 statement does not generate a result set, stored procedures can execute the statement in one of two ways:
Table 5–3 shows the SQL statements that do not generate result sets. You can execute these statements in a stored procedure using either the SQLIStatement or the SQLPStatement class.
Immediate Execution
Use immediate execution when a procedure needs to execute an SQL statement only once.
EXAMPLEThis stored procedure in this sample script inserts a row in a table. The constructor for SQLIStatement takes the SQL INSERT statement as its only argument. In this example, the statement includes five parameter markers:
Prepared Execution
Use prepared execution when you need to execute the same SQL statement repeatedly. Prepared execution avoids the overhead of creating multiple SQLIStatement objects for a single statement.
There is an advantage to prepared execution when you execute the same SQL statement from within a loop. Instead of creating an object with each iteration of the loop, prepared execution creates an object once and supplies input parameters for each execution of the statement.
Once a stored procedure creates an SQLPStatement object, you can execute the object multiple times, supplying different values for each execution.
EXAMPLEThis code fragment extends the previous example to use prepared execution:
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |