Arguments: |
The arguments sent to the callback method are:
row |
The current result row produced by executing the SQL statement(s) passed to theexecmethod. The exact format of this argument is dependent on the result set format in use.
See the remarks for details.
|
rowNum |
The current result row number.
|
userData |
The user data object specified by the programmer as the sixth argument to theexec
method. If the programmer did not specify a user data argument, this argument is omitted when invoking the callback.
|
|
Return value: |
The programmer must return a value from the callback. This value can by any of the ooSQLite result Result Code Constants constants, but if it is not theOKconstant,
then the SQLite database engine aborts without invoking the callback again and without running any subsequent SQL
statements. Note that returning some other result code thanOKallows the callback to
halt the processing of the result rows at an early stage.
|
Remarks: |
The value of therowargument is dependent on the default result set format in use for
the invocation of the exec method that generates the callback invocation. These are the
possible formats:
OO_ARRAY_OF_ARRAYS: |
Therowargume will be an array with exactly 2 indexes. Index 1 will be an array of
the column names for the result row. Index 2 will be an array for the corresponding values of the column.
|
OO_ARRAY_OF_DIRECTORIES: |
Therowargument will be aDirectoryobject where
the indexes of the directory are the column names and the value of the index is the value of the column.
|
OO_STEM_OF_STEMS: |
Therowargument will be aStemobject where
the indexes of the stem are the column names and the value of the index is the value of the column.
|
|
Example: |
This example is just used to show the principles of a user defined callback. The actual processing has no benefit over
usin the internal callback. A user class is defined with a callback method. This is passed to theexecmethod. The default record format is OO_OO_ARRAY_OF_DIRECTORIES. In the callback method,
each record is added to the user data object, which in this case is an array. On return from theexecmethod, if there were no errors, theresultObjarray
will contain all the result rows produced by executing the SQL statement:
dbConn = .ooSQLiteConnection~new(dbName, .ooSQLite~OPEN_READWRITE) |
|
resultObj = .array~new(500) |
cbObj = .UserCallBack~new |
|
sql = 'SELECT * FROM foods ORDER BY name;' |
ret = dbConn~exec(sql, .true, , cbObj, , resultObj) |
|
,,, |
|
|
::class 'UserCallBack' inherit ooSQLiteConstants |
|
::method execCallBack |
use arg row, rowNum, userObj |
|
userObj[rowNum] = row |
|
return self~OK
|
|