static/jsvm/interfaces/sql.Stmt.html
Stmt is a prepared statement. A Stmt is safe for concurrent use by multiple goroutines.
If a Stmt is prepared on a [Tx] or [Conn], it will be bound to a single underlying connection forever. If the [Tx] or [Conn] closes, the Stmt will become unusable and all operations will return an error. If a Stmt is prepared on a [DB], it will remain usable for the lifetime of the [DB]. When the Stmt needs to execute on a new underlying connection, it will prepare itself on the new connection automatically.
closeexecexecContextqueryqueryContextqueryRowqueryRowContext
Close closes the statement.
Exec executes a prepared statement with the given arguments and returns a [Result] summarizing the effect of the statement.
Exec uses [context.Background] internally; to specify the context, use [Stmt.ExecContext].
Rest ...args: any[]ExecContext executes a prepared statement with the given arguments and returns a [Result] summarizing the effect of the statement.
Rest ...args: any[]Query executes a prepared query statement with the given arguments and returns the query results as a *Rows.
Query uses [context.Background] internally; to specify the context, use [Stmt.QueryContext].
Rest ...args: any[]QueryContext executes a prepared query statement with the given arguments and returns the query results as a [*Rows].
Rest ...args: any[]QueryRow executes a prepared query statement with the given arguments. If an error occurs during the execution of the statement, that error will be returned by a call to Scan on the returned [*Row], which is always non-nil. If the query selects no rows, the [*Row.Scan] will return [ErrNoRows]. Otherwise, the [*Row.Scan] scans the first selected row and discards the rest.
Example usage:
var name string err := nameByUseridStmt.QueryRow(id).Scan(&name)Copy
QueryRow uses [context.Background] internally; to specify the context, use [Stmt.QueryRowContext].
Rest ...args: any[]QueryRowContext executes a prepared query statement with the given arguments. If an error occurs during the execution of the statement, that error will be returned by a call to Scan on the returned [*Row], which is always non-nil. If the query selects no rows, the [*Row.Scan] will return [ErrNoRows]. Otherwise, the [*Row.Scan] scans the first selected row and discards the rest.
Rest ...args: any[]OSLightDark
Generated using TypeDoc