slStmExecMany

Executes a single SQL statement multiple times.

Syntax:

slStmExecMany ( stm-handle, values [, first-row [, row-cout] ] )

Parameters:

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

(a) values: A one or two dimension array of SQL statement parameter values.

(i) first-row: [optional] Zero based index of the first row to process (defaults row 0.)

(i) row-count: [optional] Number of rows to process (Defaults to -1 meaning process all remaining rows.)

Returns:

(i) The number of values array rows processed.

This function provides a short-cut for loading an entire two dimension WIL array into an SQLite database. The function executes a prepared SQL statement multiple times placing one row of array values into the prepared SQL statement parameters with each iteration. The function restores the statement to its initial state and clears all parameter bindings before returning. Since slStmExecMany does not return result sets, it is useful for inserting data into a database but cannot be used to successfully query a database to obtain result-sets.

 

Note: you can place the  slStmExecMany function between an slExecute(db, "BEGIN TRANSACTION") and slExecute(db, "COMMIT") statements when inserting large arrays into a database. Doing so greatly increases the function's performance. It is of no benefit when inserting small arrays.

 

Stm-handle

The unique identifier to a prepared SQL statement returned from a call to the slStatement function.

  

Values

An array of SQL statement parameter values. Each column of a two dimension (rank two) array is bound to a SQL statement parameter with the syntax "?N" were "N" is the array column + 1 column contents  used as a value for the SQL statement parameter. If the this function argument contains a single dimension (rank one) array, the elements of the array are treated as a single row. Using a single dimension (rank 1) array is equivalent to calling slStatement with an array of arguments and then calling slStmExec on the statement.

 

First-row

An optional parameter used to indicate the zero-based first row of values to use from the array. If the number passed to the function is less than zero or greater than or equal to the number of rows in the values array, the function generates an error. This parameter defaults to zero (0) when this parameter is not used.

 

Row-count

An optional parameter used to indicate the number of rows to use in the values array. If this parameter is less than zero(0) or greater than the number of rows in the values array, the function processes all values array rows. The parameter defaults to -1 when it is not used.

 

Example:
  AddExtender('ilcsl44i.dll', 0, 'ilcsl64i.dll')
  
  ; Create a memory db object
  db = slConnect(":memory:")
  ; Add a table to the memory db
  SQL = "CREATE TABLE FileInfo( [Name], [Size], [Modify Date], [Access Date], [Create Date], [Attributes], [Attribute Mask]);"
  slExecute(db, SQL)
  ; Fill the table with .wbt file information
  hStm = slStatement(db,"INSERT INTO FileInfo VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)")
  ; Note: assumes a default WinBatch installation with samples option
  files = FileInfoToArray(DirHome():"..\samples\*.wbt", 4)
  ; Set start-row to 1 to skip header information
  slExecute(db, "BEGIN TRANSACTION")
  nResult = slStmExecMany(hStm, files, 1, -1)
  slExecute(db, "COMMIT")
  ; Count the number of long scripts
  out = slExecute(db,"SELECT COUNT(*) from FileInfo WHERE Size > 15000")
  Message("Number of Windy Sample Scripts", out[0,0]:" Samples more than 15000 bytes long")
  
  slClose()
See Also:

slConnect,  slStatementslStmExecslStmExecAllslStmReset