Switch to: V11V10V9V8V7V6V5

VSqliteStatement Class: Methods

VSqliteStatement.Prepare()

Declaration:

Prepare()

Description:

Prepare the vSqliteStatement. Must be called once, before executing.

Example:

sqliteStatement.Prepare()

VSqliteStatement.SqlBind()

Declaration:

SqlBind( inBinds() as StringOrVariant )

Parameters:

  • inBinds - The array of bind parameters. Usually this is an array of Strings or array of VARIANTs. See API Reference specific to your language.

Description:

Bind values to the statement.

Example:

sqliteStatement = db.CreateStatement( 'INSERT INTO t1 VALUES ( ?, ? )' )
sqliteStatement.Prepare()
 
dim Binds(-1) as String
Binds.append 'john'
Binds.append 'jehn'
 
sqliteStatement.SqlBind( Binds )

VSqliteStatement.SqlMultiRowBind()

Declaration:

SqlMultiRowBind( inBinds()() as StringOrVariant )

Parameters:

  • inBinds - The array of arrays of bind parameters. Each item means “set of values for single row”.

Description:

Bind multi-row values to the statement.

Example:

sqliteStatement = db.CreateStatement( 'INSERT INTO t1 VALUES ( ?, ? )' )
sqliteStatement.Prepare()
 
dim Binds(-1) as StringArray
 
dim RowBind1(-1) as String
RowBind1.append 'First row value1'
RowBind1.append 'First row value2'
Binds.append RowBind1
 
dim RowBind2(-1) as String
RowBind2.append 'Second row value1'
RowBind2.append 'Second row value2'
Binds.append RowBind2
 
sqliteStatement.SqlMultiRowBind( Binds )

VSqliteStatement.SqlExecute()

Declaration:

SqlExecute() as integer

Description:

Execute SQL statement of any kind except SELECT. Returns the number of affected rows.

Example:

var = sqliteStatement.SqlExecute()

VSqliteStatement.SqlSelect()

Declaration:

SqlSelect( inCursorLocation = kClient as ECursorLocation ) as vSqliteCursor

Parameters:

  • inCursorLocation - Cursor location - kServer or kClient.

Description:

Execute SQL statement of SELECT kind. Returns a cursor. You should call CloseCursor() after all, otherwise, cursor will be alive until this statement object exists.

Example:

var = sqliteStatement.SqlSelect( kClient )

VSqliteStatement.SqlQuery()

Declaration:

SqlQuery( inCursorLocation = kClient as ECursorLocation ) as vSqliteQueryResult

Parameters:

  • inCursorLocation - Cursor location - kServer or kClient.

Description:

Execute SQL statement of any kind. This method is combination of SqlExecute() and SqlSelect(). Returns either cursor or the last inserted row id, number of affected rows. Effective to work with remote Valentina SQLite Server.

Example:

var = sqliteStatement.SqlQuery( kClient )

VSqliteStatement.SqlSelectAsJSON()

Declaration:

SqlSelectAsJSON() as string

Description:

Execute SQL statement, of SELECT kind. Returns result records as a JSON string.

Example:

var = sqliteStatement.SqlSelectAsJSON()

VSqliteStatement.PrepareAndExecuteOneCommand()

Declaration:

PrepareAndExecuteOneCommand() as boolean

Description:

Prepares and Executes a single statement from the whole query. Returns TRUE if unused part of the query remains.

Example:

sqliteStatement = db.CreateStatement( 'INSERT INTO t1 VALUES ( 1 ); INSERT INTO t1 VALUES ( 2 )' )
var = sqliteStatement.PrepareAndExecuteOneCommand()
-- var == true
-- "INSERT INTO t1 VALUES ( 1 )" was executed only.

VSqliteStatement.PrepareAndExecuteAllCommands()

Declaration:

PrepareAndExecuteAllCommands()

Description:

Prepares and Executes all statements in the query.

Example:

sqliteStatement = db.CreateStatement( 'INSERT INTO t1 VALUES ( 1 ); INSERT INTO t1 VALUES ( 2 )' )
sqliteStatement.PrepareAndExecuteAllCommands()

VSqliteStatement.CloseCursor()

Declaration:

CloseCursor( inCursor as vSqliteCursor )

Description:

Free cursor. You will get an error if cursor does not belong to this statement.

Example:

var = sqliteStatement.SqlSelect( kClient )
sqliteStatement.CloseCursor( var )