Sets an SQL statement back to its initial state.
slStmReset ( stm-handle [, values] )
(s) stm-handle: SQLite extender prepared statement object handle.
(m/a) values: [optional] An array or a map of statement parameter values.
(i) 1 on successful completion.
This function allows you to reuse a prepared SQL statement by setting the statement to its initial state without recompiling the statement using the slStatement function. Optionally, you can also change the SQL statement parameter values used in the statement by providing a WIL array or WIL map in the function's second parameter. After this function is called on a statement object, the statement object can be passed to the slStmExec, slStmExecAll, or slStmExecMany extender functions.
Stm-handle
The unique identifier to prepared SQL statement returned from a call to the slStatement function.
Values
An optional function argument that contains either an array or map of values used to replace with SQL parameters in the SQL compiled statement.
The SQLite extender supports two types of parameters:
When statement parameter values are contained in a WIL array use the question mark + number syntax for SQL parameter placeholders. For example, the parameter "?1" means substitute the first element of the WIL array for "?1" in the passed-in SQL statement. Since WIL arrays are zero-based and SQLite parameters are one-based, the array element used has an index that is one less than the parameter number.
When statement parameter values are contained in a WIL map use the colon + name syntax as parameter placeholders. For example, the parameter ":somekey" means substitute the map value associated map key named "somekey" in the passed-in SQL statement.
SQLite allows a parameter wherever a string literal, blob literal, numeric constant, or NULL is allowed in queries or data modification statements. Parameters may not be used for column or table names, or as values for constraints or default values.
Note: if you call slStmReset without the values parameter, the SQL statement represented by stm-handle retains any existing parameter values.
AddExtender('ilcsl44i.dll', 0, 'ilcsl64i.dll') ; Create a virtual table using the extender's built in ; SQLite fts5 file text searching extension db = slConnect(":memory:") SQL = "CREATE VIRTUAL TABLE Scripts USING fts5([File Path], Contents);" slExecute(db, SQL) ; Get file names and place into a WIL array path = DirHome():"..\samples\" files = FileItemize(path:"*.wbt") files = Arrayize(files, @tab) nMax = ArrInfo(files, 1) - 1 ; Prepare an parameterized insert statement without any values SQL = "INSERT INTO Scripts VALUES (:Path, :Bulk );" stm = slStatement(db, SQL) For i = 0 To nMax vals["Path"] = FileFullname(path:files[i]) vals["Bulk"] = FileGet(vals["Path"]) ; Reset the statement with values slStmReset(stm, vals) ; Insert script into a virtual table slStmExec(stm) Next ; Now find any sample scripts that create COM Automation objects SQL = "SELECT [File Path] FROM Scripts WHERE Contents MATCH ""ObjectCreate"";" scripts = slExecute(db, SQL) ; Display the result scripts = ArrayItemize(scripts, @lf) AskItemlist("Sample Script Using COM",scripts,@lf,@sorted,@single,@false) slClose()