exec



Executes the specified SQL statement(s). A callback is invoked for each result row coming out of the evaluated SQL statements. This callback can either be a callback internal to the ooSQLite framework, or a callback to a method in an object supplied by the programmer.

Arguments: The arguments are:
sql [required] A string containing the SQL statement, or statements, to execute. More than 1 statement can be executed by including semi-colons in the string. Each SQL statement is ended with a semi-colon.
useCB [optional] True or false to indicate if the callback feature should be used or not. If this argument is false, thesqlis simply executed and a result code returned. The other arguments are ignored. The default if this argument is omitted is false. If this argument is true, then the callback feature is used. If thecbObjarg is omitted then an internal callback of the ooSQLite framework is used and a result set is returned. The result set could be empty if the sql does not produce a result set. The format for the returned result set will the format specified by the recordFormat (Attribute) attribute of this database connection. However, the default format can be overridden for this invocation of exec() through the optionalformatargument. Otherwise, ifcbObjis not omitted, then the call back method of that object is invoked for each result row coming out of the evaluated SQL statements. In this case the return is the result code from the database engine's execution.
format [optional] This argument can be used to specify the format of the result row(s) coming out of the evaluated SQL statements. If this argument is omitted the default recordFormat (Attribute) value for this connection is used. If specified, it must be one of the ooSQLite Result Set Format ooSQLite Specific Constants that define how a result set is formatted. The format effects the result set if a result set is returned, and the format of the result row sent to a user defined callback when a user defined callback is used.
cbObj [optional] Specifies that a user defined callback should be used rather than the ooSQLite internal callback. A callback method in this object is inovked for each row coming out of the evaluated SQL statement(s). By default the method invoked in the object will beexecCallBack. However the optionalmthNameargument can be used to change this. If this argument omitted, the internal ooSQLite callback is used. This argument is ignored ifuseCBis false.
mthName [optional] Names the method to be invoked incbObj. This argument is ignored ifcbObjis omitted, oruseCBis false. By default the method invoked incbObjisexecCallBack.
uData [optional] User data that is passed to the user defined callback method. This can be any Rexx object the programmer wishes to use. The object is passed as the third argument to the callback method. This argument is ignored ifuseCBis false, or ifcbObjis omitted.
Return value: The return value is dependent on whether the internal ooSQLite callback is used or not. When the internal callback is used, a result set is returned containing all the result rows produced by the SQL statement(s). In all other cases a result Result Code Constants is returned.
Remarks: The easiest approach to using this method is to use the internal callback of the ooSQLite framework. However, it is possible that more control might be desired in the processing of the result rows than the internal callback provides. In this case, a user defined callback can be used. The execCallBack method explains the details of a user defined callback method.
Details: The functionality of theexecmethod is similar to that of the sqlite3_exec SQLite API.
Example: This example shows theexecmethod invoction to use the internal callback of the ooSQLite framework. The format of the returned result set is specified to be an array of arrays:
dbName = 'ooFoods.rdbx'
dbConn = .ooSQLiteConnection~new(dbName, .ooSQLite~OPEN_READWRITE)
sql = 'SELECT * FROM foods ORDER BY name;'
resultSet = dbConn~exec(sql, .true, .ooSQLite~OO_ARRAY_OF_ARRAYS)
z = printResultSet(resultSet)