slStmReset

Sets an SQL statement back to its initial state.

Syntax:

slStmReset ( stm-handle [, values] )

Parameters:

(s) stm-handle: SQLite extender prepared statement object handle.

(m/a) values: [optional] An array or a map of statement parameter values.

Returns:

(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:

 

 

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.

Example:
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()
See Also:

slStatementslStmExec, slStmExecAllslStmExecMany