SQLPreview event
Description
Occurs immediately before a SQL statement
is submitted to the DBMS. Methods that trigger DBMS activity are Retrieve, Update,
and ReselectRow.
PowerBuilder event information
Event ID: pbm_dwnsql
|
Argument |
Description |
|---|---|
|
request |
SQLPreviewFunction by For a list of valid values, see SQLPreviewFunction. |
|
sqltype |
SQLPreviewType by For a list of valid values, see SQLPreviewType . |
|
sqlsyntax |
String by value. The full text of the SQL statement. |
|
buffer |
DWBuffer by value. The buffer containing For a list of valid values, see DWBuffer. |
|
row |
Long by value. The number of the row |
Web ActiveX event information
Event name: beforeSQLPreview
|
Argument |
Description |
|---|---|
|
Request |
Number. A number identifying the function For a list of valid values, see SQLPreviewFunction. |
|
SQLType |
Number. A number identifying the type For a list of valid values, see SQLPreviewType . |
|
SQLSyntax |
String. The full text of the SQL statement. |
|
dwBuffer |
Number. A number identifying the buffer For a list of valid values, see DWBuffer. |
|
Row |
Number. The number of the row involved |
Return Values
Set the return code to affect the outcome of the event:
-
0 Continue processing
-
1 Stop processing
-
2 Skip this request and execute the next
request
For information on setting the return code in a particular
environment, see “About return values for
DataWindow events”.
Usage
Some uses for the sqlsyntax argument are:
-
Changing the SQL to be executed (you can get the
value of sqlsyntax, modify it, and call SetSQLPreview) -
Keeping a record (you can write the SQL statement to a log file)
Reported row number
The row number stored in row is the number
of the row in the buffer, not the number the row had when it was
retrieved into the DataWindow object.
If the row that caused the error is in the Filter buffer,
you must unfilter it if you want the user to correct the problem.
GetSQLPreview andbinding
When binding is enabled for your database, the SQL returned in the GetSQLPreview method
may not be complete—the input arguments are not replaced
with the actual values. For example, when binding is enabled, GetSQLPreview might return
the following SQL statement:
|
1 |
INSERT INTO "cust_order" ( "ordnum", "custnum", |
|
1 |
"duedate", "balance" ) VALUES ( ?, ?, ?, ? ) |
When binding is disabled, it returns:
|
1 |
INSERT INTO "cust_order" ( "ordnum", "balance", |
|
1 |
"duedate", "custnum" ) VALUES ( '12345', 900, |
|
1 |
'3/1/94', '111' ) |
If you require the complete SQL statement
for logging purposes, you should disable binding in your DBMS.
For more information about binding, see Connecting
to Your Database.
Obsolete methods in PowerBuilder
Information formerly provided by GetSQLPreview and GetUpdateStatus is
available in the arguments sqlsyntax, row,
and buffer.
Examples
This statement in the SQLPreview event
sets the current SQL string
for the DataWindow dw_1:
|
1 |
dw_1.SetSQLPreview( & |
|
1 |
"INSERT INTO billings VALUES(100, " + & |
|
1 |
String(Current_balance) + ")") |