Sybase 2 Barcode Reader User Manual


 
CHAPTER 6 Controlling Updates in DataWindow Objects
DataWindow Designer User’s Guide 199
To use stored procedures to update the database
1 In the DataWindow painter, select Rows>Stored Procedure Update to
display the Stored Procedure Update dialog box.
2 Select the tab for the SQL update method (Delete, Insert, or Update) with
which you want to associate a stored procedure.
3 Click the Procedure button, select the stored procedure you want to have
execute when the SQL update method is generated, and click OK.
The parameters used in the stored procedure are displayed in the Argument
Name list in the order in which they are defined in the procedure. Column
Name lists the columns used in your DataWindow object.
4 Associate a column in the DataWindow object or an expression with a
procedure parameter.
If a stored procedure uses parameters that are not matched to column
names, you can substitute the value from a DataWindow object computed
field or expression.
Matching a column to a procedure parameter
You must be careful to correctly match a column in the DataWindow
object to a procedure parameter, since DataWindow Designer is able to
verify only that datatypes match.
5 If the parameter is to receive a column value, indicate whether the
parameter will receive the updated column value entered through the
DataWindow object or retain the original column value from the database.
Typically, you select Use Original when the parameter is used in a
WHERE
clause in an
UPDATE or DELETE SQL statement. If you do not select Use
Original, the parameter will use the new value entered for that column.
Typically, you would use the new value when the parameter is used in an
INSERT or UPDATE SQL statement.
What happens when
the stored procedure
is executed
The stored procedure you associate with a SQL update method in the Stored
Procedure Update dialog box is executed when the DataWindow control calls
the
UpdateData method. The DataWindow control examines the table in the
DataWindow object, determines the appropriate SQL statement for each row,
and submits the appropriate stored procedure (as defined in the Stored
Procedure Update dialog box) with the appropriate column values substituted
for the procedure arguments.