Documentation ¶
Overview ¶
Package ase contains code of the go-ase driver for the database/sql package of Go (golang) to provide access to SAP ASE instances.
Index ¶
- Constants
- Variables
- func AddEEDHooks(fns ...tds.EEDHook) error
- func AddEnvChangeHooks(fns ...tds.EnvChangeHook) error
- func DefaultTxOptions() driver.TxOptions
- func NewConnector(info *Info) (driver.Connector, error)
- func NewConnectorWithHooks(info *Info, envChangeHooks []tds.EnvChangeHook, eedHooks []tds.EEDHook) (driver.Connector, error)
- type Conn
- func (c *Conn) Begin() (driver.Tx, error)
- func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)
- func (conn *Conn) CheckNamedValue(nv *driver.NamedValue) error
- func (c *Conn) Close() error
- func (c *Conn) DirectExec(ctx context.Context, query string, args ...interface{}) (driver.Rows, driver.Result, error)
- func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (c *Conn) GenericExec(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, driver.Result, error)
- func (c *Conn) NewCursor(ctx context.Context, query string, args ...interface{}) (*Cursor, error)
- func (c *Conn) NewCursorWithValues(ctx context.Context, query string, args []driver.NamedValue) (*Cursor, error)
- func (conn *Conn) NewRows() *Rows
- func (c *Conn) NewStmt(ctx context.Context, name, query string, create_proc bool) (*Stmt, error)
- func (c *Conn) NewTransaction(ctx context.Context, opts driver.TxOptions, name string) (*Transaction, error)
- func (c Conn) Ping(ctx context.Context) error
- func (c *Conn) Prepare(query string) (driver.Stmt, error)
- func (c *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)
- func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- type Connector
- type Cursor
- type CursorRows
- func (rows *CursorRows) Close() error
- func (rows CursorRows) ColumnTypeDatabaseTypeName(index int) string
- func (rows CursorRows) ColumnTypeDisplayLength(index int) (int64, bool)
- func (rows CursorRows) ColumnTypeLength(index int) (int64, bool)
- func (rows CursorRows) ColumnTypeNullable(index int) (bool, bool)
- func (rows CursorRows) ColumnTypePrecisionScale(index int) (int64, int64, bool)
- func (rows CursorRows) ColumnTypeScanType(index int) reflect.Type
- func (rows CursorRows) Columns() []string
- func (rows *CursorRows) Next(dst []driver.Value) error
- type Driver
- type Info
- type NoQueryCursor
- type Result
- type Rows
- func (rows *Rows) Close() error
- func (rows Rows) ColumnTypeDatabaseTypeName(index int) string
- func (rows Rows) ColumnTypeDisplayLength(index int) (int64, bool)
- func (rows Rows) ColumnTypeLength(index int) (int64, bool)
- func (rows Rows) ColumnTypeNullable(index int) (bool, bool)
- func (rows Rows) ColumnTypePrecisionScale(index int) (int64, int64, bool)
- func (rows Rows) ColumnTypeScanType(index int) reflect.Type
- func (rows Rows) Columns() []string
- func (rows *Rows) HasNextResultSet() bool
- func (rows *Rows) Next(dst []driver.Value) error
- func (rows *Rows) NextResultSet() error
- type Stmt
- func (stmt Stmt) CheckNamedValue(nv *driver.NamedValue) error
- func (stmt *Stmt) Close() error
- func (stmt Stmt) DirectExec(ctx context.Context, args ...interface{}) (driver.Rows, driver.Result, error)
- func (stmt Stmt) Exec(args []driver.Value) (driver.Result, error)
- func (stmt Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
- func (stmt Stmt) GenericExec(ctx context.Context, args []driver.NamedValue) (driver.Rows, driver.Result, error)
- func (stmt Stmt) NumInput() int
- func (stmt Stmt) Query(args []driver.Value) (driver.Rows, error)
- func (stmt Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)
- func (stmt *Stmt) Reset()
- type Transaction
Constants ¶
const DriverName = "ase"
DriverName is the driver name to use with sql.Open for ase databases.
Variables ¶
var (
ErrCurNoMoreRows = errors.New("no more rows in cursor")
)
Functions ¶
func AddEEDHooks ¶
AddEEDHooks registers functions as hooks. The hooks are executed when the driver receives EED packages.
func AddEnvChangeHooks ¶
func AddEnvChangeHooks(fns ...tds.EnvChangeHook) error
AddEnvChangeHooks registers funtions as hooks. The hooks are executed when the driver receives EnvChange packages.
func DefaultTxOptions ¶
DefaultTxOptions returns default driver.TxOptions.
func NewConnector ¶
NewConnector returns a new connector with the passed configuration.
func NewConnectorWithHooks ¶
func NewConnectorWithHooks(info *Info, envChangeHooks []tds.EnvChangeHook, eedHooks []tds.EEDHook) (driver.Connector, error)
NewConnectorWithHooks returns a new connector with the passed configuration.
Types ¶
type Conn ¶
type Conn struct { Conn *tds.Conn Channel *tds.Channel Info *Info // contains filtered or unexported fields }
Conn implements the driver.Conn interface.
func NewConnWithHooks ¶
func NewConnWithHooks(ctx context.Context, info *Info, envChangeHooks []tds.EnvChangeHook, eedHooks []tds.EEDHook) (*Conn, error)
NewConnWithHooks returns a connection with the passed configuration.
func (*Conn) CheckNamedValue ¶
func (conn *Conn) CheckNamedValue(nv *driver.NamedValue) error
CheckNamedValue implements the driver.NamedValueChecker interface.
func (*Conn) DirectExec ¶
func (c *Conn) DirectExec(ctx context.Context, query string, args ...interface{}) (driver.Rows, driver.Result, error)
DirectExec is a wrapper for GenericExec and meant to be used when directly accessing this library, rather than using database/sql.
The primary advantage are the variadic args, which can be normal values and are automatically transformed to driver.NamedValues for GenericExec.
func (*Conn) ExecContext ¶
func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
ExecContext implements the driver.ExecerContext.
func (*Conn) GenericExec ¶
func (c *Conn) GenericExec(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, driver.Result, error)
GenericExec is the central method through which SQL statements are sent to ASE.
func (*Conn) NewCursor ¶
NewCursor creates a new cursor.
NewCursor is a wrapper around NewCursorWithValues that converts arguments into driver.NamedValues.
func (*Conn) NewCursorWithValues ¶
func (c *Conn) NewCursorWithValues(ctx context.Context, query string, args []driver.NamedValue) (*Cursor, error)
NewCursorWithValues creates a new cursor.
func (*Conn) NewTransaction ¶
func (c *Conn) NewTransaction(ctx context.Context, opts driver.TxOptions, name string) (*Transaction, error)
NewTransaction creates a new transaction.
func (*Conn) PrepareContext ¶
PrepareContext implements the driver.ConnPrepareContext interface.
func (*Conn) QueryContext ¶
func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
QueryContext implements the driver.QueryerContext.
QueryContext utilizes cursors unless c.Info.NoQueryCursor is set or the context has the value "NoQueryContext" set to true.
If the context has NoQueryCursor set it overrides c.Info.NoQueryCursor.
type Connector ¶
type Connector struct { Info *Info EnvChangeHooks []tds.EnvChangeHook EEDHooks []tds.EEDHook }
Connector implements the driver.Connector interface.
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
Cursor is used to interact with a cursor on the ASE server.
func (*Cursor) Fetch ¶
func (cursor *Cursor) Fetch(ctx context.Context) (*CursorRows, error)
Fetch returns CursorRows to iterate over the rows selected by a cursor.
func (*Cursor) NewCursorRows ¶
func (cursor *Cursor) NewCursorRows() (*CursorRows, error)
NewCursorRows returns CursorRows for a Cursor.
It does not immediately fetch a result set from the remote. See .Fetch.
type CursorRows ¶
type CursorRows struct {
// contains filtered or unexported fields
}
CursorRows is used to iterate over the result set of a cursor.
func (*CursorRows) Close ¶
func (rows *CursorRows) Close() error
Close closes CursorRows and its associated Cursor.
func (CursorRows) ColumnTypeDatabaseTypeName ¶
ColumnTypeDatabaseTypeName implements the driver.RowsColumnTypeDatabaseTypeName interface.
func (CursorRows) ColumnTypeDisplayLength ¶
ColumnTypeDisplayLength returns a best guess of the maximum length required to display the values of the column.
func (CursorRows) ColumnTypeLength ¶
ColumnTypeLength implements the driver.RowsColumnTypeLength interface.
func (CursorRows) ColumnTypeNullable ¶
ColumnTypeNullable implements the driver.RowsColumnTypeNullable interface.
func (CursorRows) ColumnTypePrecisionScale ¶
ColumnTypePrecisionScale implements the driver.RowsColumnTypePrecisionScale interface.
func (CursorRows) ColumnTypeScanType ¶
ColumnTypeScanType implements the driver.RowsColumnTypeScanType interface.
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver implements the driver.Driver interface.
type Info ¶
type Info struct { tds.Info AppName string `json:"appname" doc:"Application Name to transmit to ASE"` NoQueryCursor bool `json:"no-query-cursor" doc:"Prevents the use of cursors for database/sql query methods. See README for details."` CursorCacheRows int `json:"cursor-cache-rows" doc:"How many rows to cache at once when reading the result set of a cursor"` }
func NewInfoWithEnv ¶
NewInfoWithEnv is a convenience function returning an Info with values filled from the environment with the prefix 'ASE'.
type NoQueryCursor ¶
type NoQueryCursor bool
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result implements the driver.Result interface.
func (Result) LastInsertId ¶
LastInsertId implements the driver.Result interface.
func (Result) RowsAffected ¶
RowsAffected implements the driver.Result interface.
type Rows ¶
type Rows struct { Conn *Conn RowFmt *tds.RowFmtPackage // contains filtered or unexported fields }
Rows implements the driver.Rows interface.
func (Rows) ColumnTypeDatabaseTypeName ¶
ColumnTypeDatabaseTypeName implements the driver.RowsColumnTypeDatabaseTypeName interface.
func (Rows) ColumnTypeDisplayLength ¶
ColumnTypeDisplayLength returns a best guess of the maximum length required to display the values of the column.
func (Rows) ColumnTypeLength ¶
ColumnTypeLength implements the driver.RowsColumnTypeLength interface.
func (Rows) ColumnTypeNullable ¶
ColumnTypeNullable implements the driver.RowsColumnTypeNullable interface.
func (Rows) ColumnTypePrecisionScale ¶
ColumnTypePrecisionScale implements the driver.RowsColumnTypePrecisionScale interface.
func (Rows) ColumnTypeScanType ¶
ColumnTypeScanType implements the driver.RowsColumnTypeScanType interface.
func (Rows) Columns ¶
func (rows Rows) Columns() []string
Columns implements the driver.Rows interface.
func (*Rows) HasNextResultSet ¶
HasNextResultSet implements the driver.RowsNextResultSet interface.
func (*Rows) NextResultSet ¶
NextResultSet implements the driver.RowsNextResultSet interface.
type Stmt ¶
type Stmt struct {
// contains filtered or unexported fields
}
Stmt implements the driver.Stmt interface.
func (Stmt) CheckNamedValue ¶
func (stmt Stmt) CheckNamedValue(nv *driver.NamedValue) error
CheckNamedValue implements the driver.NamedValueChecker interface.
func (Stmt) DirectExec ¶
func (stmt Stmt) DirectExec(ctx context.Context, args ...interface{}) (driver.Rows, driver.Result, error)
DirectExec is a wrapper for GenericExec and meant to be used when directly accessing this library, rather than using database/sql.
The primary advantage are the variadic args, which can be normal values and are automatically transformed to driver.NamedValues for GenericExec.
func (Stmt) ExecContext ¶
ExecContext implements the driver.StmtExecContext interface.
func (Stmt) GenericExec ¶
func (stmt Stmt) GenericExec(ctx context.Context, args []driver.NamedValue) (driver.Rows, driver.Result, error)
GenericExec is the central method through which SQL statements are sent to ASE.
func (Stmt) QueryContext ¶
QueryContext implements the driver.StmtQueryContext interface.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction implements the driver.Tx interface.
func (Transaction) Commit ¶
func (tx Transaction) Commit() error
Commit implements the driver.Tx interface.
func (Transaction) Name ¶
func (tx Transaction) Name() string
Name returns the name of the transaction.
func (Transaction) NewTransaction ¶
func (tx Transaction) NewTransaction(ctx context.Context, opts driver.TxOptions) (*Transaction, error)
NewTransaction creates a new transaction.
func (Transaction) Rollback ¶
func (tx Transaction) Rollback() error
Rollback implements the driver.Tx interface.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
columnTypes
This example shows how to retrieve column type information.
|
This example shows how to retrieve column type information. |
cursor
This example shows how to use cursor with the go-ase driver.
|
This example shows how to use cursor with the go-ase driver. |
directExec
This example shows how to utilize the DirectExecer interface to receive both the driver.Rows and driver.Result of a SQL query.
|
This example shows how to utilize the DirectExecer interface to receive both the driver.Rows and driver.Result of a SQL query. |
eedexample
This example shows how to retrieve the wrapped tds.EEDError to access messages sent by the TDS server in the context of an SQL statement.
|
This example shows how to retrieve the wrapped tds.EEDError to access messages sent by the TDS server in the context of an SQL statement. |
noQueryCursor
go-ase uses cursor by default for all SQL queries.
|
go-ase uses cursor by default for all SQL queries. |
preparedStatement
This example shows a simple interaction with a TDS server using the database/sql interface, prepared statements and the pure go driver.
|
This example shows a simple interaction with a TDS server using the database/sql interface, prepared statements and the pure go driver. |
recorder
This example shows how tds.EEDHooks can be utilized to record and inspect a number of tds.EEDPackages received during a transaction.
|
This example shows how tds.EEDHooks can be utilized to record and inspect a number of tds.EEDPackages received during a transaction. |
simple
This example shows a simple interaction with a TDS server using the database/sql interface and the pure go driver.
|
This example shows a simple interaction with a TDS server using the database/sql interface and the pure go driver. |
template
TODO describe what the example does or shows here
|
TODO describe what the example does or shows here |
transaction
This example shows the use of transactions using the database/sql interface and the pure go driver.
|
This example shows the use of transactions using the database/sql interface and the pure go driver. |