SQLPreview

Description

Occurs immediately before a SQL statement is submitted to the DBMS.

Event ID

Event ID

Objects

None

Transaction objects


Arguments

Argument

Description

sqlfunc

The SQLFunction system enumeration passed by value. This enumeration indicates the function that initiated database activity. Values for this enumeration are: SQLDBInsert! SQLDBUpdate!, SQLDBDelete!, SQLDBSelect!, SQLDBProcedure!, SQLDBRPC!, and SQLDBOthers!.

sqlsyntax

String by value. The full text of the SQL statement.


Return Values

Long. Set the return code to affect the outcome of the event:

0 -- Continue processing

1 -- Stop processing

Usage

Use with embedded SQL

This event is triggered before SQL statements are passed to the DBMS.

Use with DataWindow/DataStore

When using this event of the Transaction object with a DataWindow that also defines a SQLPreview event, the DataWindow's event is fired first. If the return value of DataWindow SQLPreview event is 0 (continue processing), the Transaction object's SQLPreview event is triggered next.

Examples

In this embedded SQL cursor example, the SQLPreview event is invoked just before the OPEN Emp_cur; statement is executed:

DECLARE Emp_cur CURSOR FOR SELECT employee.emp_number,
  employee.emp_name FROM employee 
WHERE employee.emp_salary > :Sal_var ;
OPEN Emp_cur ;

In this dynamic SQL example, the SQLPreview event is invoked just before the EXECUTE DYNAMIC my_proc DESCRIPTOR SQLDA statement is executed:

PREPARE SQLSA FROM  "execute @rc = myproc @parm1=?,
   @parm2=? OUTPUT ";
DESCRIBE SQLSA INTO SQLDA ;
DECLARE my_proc DYNAMIC PROCEDURE FOR SQLSA ;
SetDynamicParm(SQLDA, 1, var1)
SetDynamicParm(SQLDA, 2, var2)
EXECUTE DYNAMIC my_proc DESCRIPTOR SQLDA ;

See also

DBError

SQLPreview in the section called “SQLPreview” in DataWindow Reference