Updated on 2023-10-23 GMT+08:00

type Stmt

The following table describes type Stmt.

Method

Description

Return Value

(s *Stmt)Close()

Closes a specified prepared statement.

error

(s *Stmt)Exec(args ...interface{})

Executes a prepared statement with specified parameters and returns a Result value.

Result and error

(s *Stmt)ExecContext(ctx context.Context,

args ...interface{})

Executes a prepared statement with specified parameters in a specified context and returns a Result value.

Result and error

(s *Stmt)Query(args ...interface{})

Executes a prepared statement with specified parameters and returns *Rows as the query result.

*Rows and error

(s *Stmt)QueryContext(ctx context.Context,

args ...interface{})

Executes a prepared statement with specified parameters in a specified context and returns *Rows as the query result.

*Rows and error

(s *Stmt)QueryRow(args ...interface{})

Executes a prepared statement with specified parameters and returns *Row as the result.

*Row

(s *Stmt)QueryRowContext (ctx context.Context,

args ...interface{})

Executes a prepared statement with specified parameters in a specified context and returns *Row as the result.

*Row

Parameter Description

Parameter

Description

ctx

Specified context

query

Executed SQL statement

args

Parameter that needs to be bound to the executed SQL statement. Binding by location and binding by name are supported. For details, see the example in type DB.