Creating database callback functions

Database callback functions manipulate data received from each result row of a SQL statement object. The function executes after each result row has gathered events and data in the new row.

The callback function traps events after the execution of a SQL query or stored procedure using the database interface object. You can place additional ODL logic within callbacks to execute against a query or stored procedure.To create a database callback function:

  1. In the MSG-IDE Browse window, select Function in the object list on the left, then click Add. The Edit Function window opens.

  2. Click DBcallback. The return type appears in the Returns field and the callback function argument appears in the Arguments field, supplied by the MSG-IDE tool:

    _cdecl char *_cop, short event, long row
    
  3. Enter the name for this database callback function; for example, dbi_callback1.

  4. In the text editor pane, enter the body of the callback function, which generally checks the event code (and/or current result set row), then takes appropriate actions based on those values. For example:


Associating a database callback function with a database interface object

To associate a callback function with an database interface object,

  1. Create the database interface object using the instructions in “Defining database interface objects” in the e-Biz Impact MSG-IDE Guide, Chapter 3, “Use MSG-IDE.”

  2. Referencing the instructions in the above-referenced section, subsection “SQL statement result options,” define a SQL statement result option.

  3. In the SQL Statement Result Options dialog box, click the down arrow in the Callback field and select an existing function to execute against each result row, or click the ellipsis button (three dots) to build a new function using the instructions in “Creating database callback functions”.