SqliteStatement

Inherits from: Object

A prepared SQL statement for repeated execution against a SqliteDatabase.

Prepared statements are created via SqliteDatabase>>prepare: and can be executed multiple times with different parameters. Always close statements when done.

Example
| stmt <SqliteStatement> |
stmt := db prepare: 'INSERT INTO users (name, age) VALUES (?, ?)'.
stmt executeWith: #('Alice' 30).
stmt executeWith: #('Bob' 25).
stmt close

Instance Methods

primitives

primClose
primExecute
primExecuteWith:
primQuery
primQueryWith:
primSql

uncategorized

close

Close the prepared statement and release resources.

execute

Execute the prepared statement with no parameters. Returns the number of rows affected.

executeWith:

Execute the prepared statement with positional parameters. Returns the number of rows affected.

Example
stmt executeWith: #('Alice' 30)
printString
query

Query with the prepared statement (no parameters). Returns a SqliteRows cursor.

queryWith:

Query with the prepared statement and parameters. Returns a SqliteRows cursor.

Example
| rows <SqliteRows> |
rows := stmt queryWith: #('Alice').
[rows next] whileTrue: [rows asDict].
rows close
sql

Get the SQL string used to create this statement.