Oracle Objects for OLE
Release 9.2

Part Number A95895-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents

Master Index

Feedback

Coding the CommitGrid_Click() Procedure

See Also
Quick Tour
Batch Insert Form

The CommitGrid_Click() procedure inserts the grid data into the database. To do so, this procedure creates a parameter array object for each column in the EMP table, which corresponds to a column in the grid. We use the parameter AddTable() method to define each parameter array. For example, we define a parameter array called "EMPNO_ARR" to hold all Employee Number column elements.

After defining the parameter arrays, we populate them with grid column elements using the Put_Value method.

To commit the parameter array elements to the database, this procedure uses the CreateSQL() method with a SQL INSERT statement containing the parameter arrays. Since the CreateSQL() method executes the SQL INSERT statement in addition to creating a SQL statement object, all column elements (parameter array elements) are inserted into the EMP table with this one statement.

When an error occurs executing a SQL INSERT statement containing parameter arrays, the SQL statement object is still created with no explicitly raised error. To identify such errors, we always check the OraDatabase.LastServerErr and OraDatabase.LastServerErrText properties immediately after executing CreateSQL.

The CreateSQL method updates the database directly and has no effect on the dynaset EmpDynaset. We must refresh this dynaset to reflect the newly inserted records by executing DbRefresh.

The CommitGrid_Click() event procedure does the following:

  1. Defines a parameter array for each grid (database) column, using AddTable.

  2. Copies grid column elements into parameter arrays, using the Put_Value method within a nested loop.

  3. Creates a SQL statement object using CreateSQL to insert parameter array elements into the EMP table.

  4. Checks the LastServerErrText and LastServerErr properties to catch SQL statement execution errors.

  5. Refreshes the global dyanset to reflect newly inserted records, using DbRefresh.