Documentation ¶
Overview ¶
Package odbc implements database/sql driver to access data via odbc interface.
Index ¶
- Variables
- func CURRENT_DATE(x []byte) []byte
- func CURRENT_TIME(x []byte) []byte
- func ConvertAssign(dest, src interface{}) error
- func CreateDb(dbname string, connStr string, options ...string) (bool, error)
- func DropDb(dbname string, connStr string) (bool, error)
- func Dummy(x []byte) []byte
- func GetSepecialValue(name string, param []byte) []byte
- func IsError(ret api.SQLRETURN) bool
- func IsSepecialRegister(name string) bool
- func NewError(apiName string, handle interface{}) error
- func SqltoCtype(sqltype api.SQLSMALLINT) api.SQLSMALLINT
- func ToHandleAndType(handle interface{}) (h api.SQLHANDLE, ht api.SQLSMALLINT)
- type BaseColumn
- type BindableColumn
- type BufferLen
- type Col
- type Column
- type Conn
- func (c *Conn) Begin() (driver.Tx, error)
- func (c *Conn) Close() 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) PrepareODBCStmt(query string) (*ODBCStmt, error)
- func (c *Conn) Query(query string, args []driver.Value) (driver.Rows, error)
- func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- type ContextKey
- type DBP
- type DiagRecord
- type Driver
- type Error
- type NonBindableColumn
- type ODBCStmt
- type Out
- type Parameter
- type Pool
- type ROWID
- type RSRows
- type Result
- type Rows
- func (r *Rows) Close() error
- func (r *Rows) ColumnTypeDatabaseTypeName(index int) string
- func (r *Rows) ColumnTypeLength(index int) (length int64, ok bool)
- func (r *Rows) ColumnTypeNullable(index int) (nullable, ok bool)
- func (r *Rows) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool)
- func (r *Rows) ColumnTypeScanType(index int) reflect.Type
- func (r *Rows) Columns() []string
- func (r *Rows) HasNextResultSet() bool
- func (r *Rows) Next(dest []driver.Value) error
- func (r *Rows) NextResultSet(ctx context.Context) error
- type Stats
- type Stmt
- func (s *Stmt) CheckNamedValue(nv *driver.NamedValue) (err error)
- func (s *Stmt) Close() error
- func (s *Stmt) Exec(args []driver.Value) (driver.Result, error)
- func (s *Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
- func (s *Stmt) NumInput() int
- func (s *Stmt) Query(args []driver.Value) (driver.Rows, error)
- func (s *Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)
- type Tx
Constants ¶
This section is empty.
Variables ¶
var DB2SpecialResigers map[string]func([]byte) []byte = map[string]func([]byte) []byte{ "CURRENT CLIENT_ACCTNG": Dummy, "CLIENT ACCTNG": Dummy, "CURRENT CLIENT_APPLNAME": Dummy, "CLIENT APPLNAME": Dummy, "CURRENT CLIENT_PROGRAMID": Dummy, "CLIENT PROGRAMID": Dummy, "CURRENT CLIENT_USERID": Dummy, "CLIENT USERID": Dummy, "CURRENT CLIENT_WRKSTNNAME": Dummy, "CLIENT WRKSTNNAME": Dummy, "CURRENT DATE": Dummy, "CURRENT_DATE": Dummy, "CURRENT DEBUG MODE": Dummy, "CURRENT DECFLOAT ROUNDING MODE": Dummy, "CURRENT DEGREE": Dummy, "CURRENT IMPLICIT XMLPARSE OPTION": Dummy, "CURRENT PATH": Dummy, "CURRENT_PATH": Dummy, "CURRENT FUNCTION PATH": Dummy, "CURRENT SCHEMA": Dummy, "CURRENT SERVER": Dummy, "CURRENT_SERVER": Dummy, "CURRENT TEMPORAL SYSTEM_TIME": Dummy, "CURRENT TIME": Dummy, "CURRENT_TIME": Dummy, "CURRENT TIMESTAMP": Dummy, "CURRENT_TIMESTAMP": Dummy, "CURRENT TIMEZONE": Dummy, "CURRENT_TIMEZONE": Dummy, "CURRENT USER": Dummy, "CURRENT_USER": Dummy, "SESSION_USER": Dummy, "USER": Dummy, "SYSTEM_USER": Dummy, "CURRENT ACCELERATOR": Dummy, "CURRENT APPLICATION COMPATIBILITY": Dummy, "CURRENT APPLICATION ENCODING SCHEME": Dummy, "CURRENT CLIENT_CORR_TOKEN": Dummy, "CURRENT EXPLAIN MODE": Dummy, "CURRENT GET_ACCEL_ARCHIVE": Dummy, "CURRENT_LC_CTYPE": Dummy, "CURRENT LOCALE LC_CTYPE": Dummy, "CURRENT MAINTAINED": Dummy, "CURRENT MEMBER": Dummy, "CURRENT OPTIMIZATION HINT": Dummy, "CURRENT PACKAGE PATH": Dummy, "CURRENT PACKAGESET": Dummy, "CURRENT PRECISION": Dummy, "CURRENT QUERY ACCELERATION": Dummy, "CURRENT QUERY ACCELERATION WAITFORDATA": Dummy, "CURRENT REFRESH AGE": Dummy, "CURRENT ROUTINE VERSION": Dummy, "CURRENT RULES": Dummy, "CURRENT_SCHEMA": Dummy, "CURRENT SQLID": Dummy, "CURRENT TEMPORAL BUSINESS_TIME": Dummy, "CURRENT TIME ZONE": Dummy, "ENCRYPTION PASSWORD": Dummy, "SESSION TIME ZONE": Dummy, }
var DateFormat string = "2006-01-02"
var SPParamDataTypes map[string]string = map[string]string{
"SMALLINT": "NUMERIC",
"BIGINT": "NUMERIC",
"ROWID": "NUMERIC",
"DECIMAL": "NUMERIC",
"NUMERIC": "NUMERIC",
"INTEGER": "NUMERIC",
"DOUBLE PRECISION": "NUMERIC",
"REAL": "NUMERIC",
"CHARACTER": "STRING",
"BINARY VARYING": "STRING",
"XML": "STRING",
"BINARY LARGE OBJECT": "STRING",
"GRAPHIC VARYING": "STRING",
"CHARACTER VARYING": "STRING",
"BINARY": "STRING",
"CHARACTER LARGE OBJECT": "STRING",
"GRAPHIC": "STRING",
"DOUBLE-BYTE CHARACTER LARGE OBJECT": "STRING",
"TIME": "DATE",
"DATE": "DATE",
"TIMESTAMP": "DATE",
}
var SPParamDateTypes map[string]string = map[string]string{
"TIME": "DATE",
"DATE": "DATE",
"TIMESTAMP": "DATE",
}
var SPParamIntegerTypes map[string]string = map[string]string{
"SMALLINT": "NUMERIC",
"BIGINT": "NUMERIC",
"INTEGER": "NUMERIC",
}
without decimal point
var SPParamNumericTypes map[string]string = map[string]string{
"SMALLINT": "NUMERIC",
"BIGINT": "NUMERIC",
"ROWID": "NUMERIC",
"DECIMAL": "NUMERIC",
"NUMERIC": "NUMERIC",
"INTEGER": "NUMERIC",
"DOUBLE PRECISION": "NUMERIC",
"REAL": "NUMERIC",
}
var SPParamStringTypes map[string]string = map[string]string{
"CHARACTER": "STRING",
"BINARY VARYING": "STRING",
"XML": "STRING",
"BINARY LARGE OBJECT": "STRING",
"GRAPHIC VARYING": "STRING",
"CHARACTER VARYING": "STRING",
"BINARY": "STRING",
"CHARACTER LARGE OBJECT": "STRING",
"GRAPHIC": "STRING",
"DOUBLE-BYTE CHARACTER LARGE OBJECT": "STRING",
}
var TimeFormat string = "15:04:05"
var TimestampFormat string = "2006-01-02 15:04:05.000000"
Functions ¶
func CURRENT_DATE ¶
func CURRENT_TIME ¶
func ConvertAssign ¶
func ConvertAssign(dest, src interface{}) error
ConvertAssign function copies the database data to Dest field in stored procedure.
func CreateDb ¶
CreateDb function will take the db name and user details as parameters and create the database.
func DropDb ¶
DropDb function will take the db name and user details as parameters and drop the database.
func GetSepecialValue ¶
func IsSepecialRegister ¶
func SqltoCtype ¶
func SqltoCtype(sqltype api.SQLSMALLINT) api.SQLSMALLINT
SqltoCtype function will convert the sql type to c type
func ToHandleAndType ¶
func ToHandleAndType(handle interface{}) (h api.SQLHANDLE, ht api.SQLSMALLINT)
Types ¶
type BaseColumn ¶
type BaseColumn struct { CType api.SQLSMALLINT SType api.SQLSMALLINT // contains filtered or unexported fields }
BaseColumn implements common column functionality.
func (*BaseColumn) Name ¶
func (c *BaseColumn) Name() string
func (*BaseColumn) TypeScan ¶
func (c *BaseColumn) TypeScan() reflect.Type
type BindableColumn ¶
type BindableColumn struct { *BaseColumn IsBound bool IsVariableWidth bool Size int Len BufferLen Buffer []byte // contains filtered or unexported fields }
BindableColumn allows access to columns that can have their buffers bound. Once bound at start, they are written to by odbc driver every time it fetches new row. This saves on syscall and, perhaps, some buffer copying. BindableColumn can be left unbound, then it behaves like NonBindableColumn when user reads data from it.
func NewBindableColumn ¶
func NewBindableColumn(b *BaseColumn, ctype api.SQLSMALLINT, bufSize int) *BindableColumn
type Col ¶
func (*Col) AssignValueByType ¶
func (c *Col) AssignValueByType()
type Column ¶
type Column interface { Name() string TypeScan() reflect.Type Bind(h api.SQLHSTMT, idx int) (bool, error) Value(h api.SQLHSTMT, idx int) (driver.Value, error) }
Column provides access to row columns.
func NewVariableWidthColumn ¶
func NewVariableWidthColumn(b *BaseColumn, ctype api.SQLSMALLINT, colWidth api.SQLULEN) Column
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func (*Conn) PrepareContext ¶
type ContextKey ¶
type ContextKey string
const DUMMY_SP_CALL ContextKey = "DUMMY_SP_CALL"
const ESCAPE_QUOTE ContextKey = "ESCAPE_QUOTE"
const LABEL_IN_COL_NAME ContextKey = "LABEL_IN_COL_NAME"
const LOAD_SP_RESULT_SETS ContextKey = "LOAD_SP_RESULT_SETS"
const SQL_TO_PING ContextKey = "SQL_TO_PIGN"
type DBP ¶
DBP struct type contains the timeout, dbinstance and connection string
type DiagRecord ¶
func (*DiagRecord) String ¶
func (r *DiagRecord) String() string
type Error ¶
type Error struct { APIName string Diag []DiagRecord }
type NonBindableColumn ¶
type NonBindableColumn struct {
*BaseColumn
}
NonBindableColumn provide access to columns, that can't be bound. These are of character or binary type, and, usually, there is no limit for their width.
type ODBCStmt ¶
type Out ¶
type Out struct {
// contains filtered or unexported fields
}
Out struct is used to store the value of a OUT parameter in Stored Procedure
func (*Out) ConvertAssign ¶
ConvertAssign function copies the database data to Dest field in stored procedure.
type Parameter ¶
type Parameter struct { SQLType api.SQLSMALLINT Decimal api.SQLSMALLINT Size api.SQLULEN // Following fields store data used later by SQLExecute. // The fields keep data alive and away from gc. Data interface{} StrLen_or_IndPtr api.SQLLEN Outs []*Out // contains filtered or unexported fields }
func ExtractParameters ¶
ExtractParameters will describe all the parameters
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool struct contais the about the pool like size, used and available connections
func (*Pool) Open ¶
Open will check for the connection in the pool If not opens a new connection and stores in the pool
func (*Pool) SetConnMaxLifetime ¶
Set the connMaxLifetime
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
func (*Result) LastInsertId ¶
func (*Result) RowsAffected ¶
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
func (*Rows) ColumnTypeDatabaseTypeName ¶
func (*Rows) ColumnTypeNullable ¶
func (*Rows) ColumnTypePrecisionScale ¶
func (*Rows) HasNextResultSet ¶
type Stmt ¶
type Stmt struct {
// contains filtered or unexported fields
}
func (*Stmt) CheckNamedValue ¶
func (s *Stmt) CheckNamedValue(nv *driver.NamedValue) (err error)
CheckNamedValue implementes driver.NamedValueChecker.
func (*Stmt) ExecContext ¶
ExecContext implements driver.StmtExecContext interface
func (*Stmt) QueryContext ¶
QueryContext implements driver.StmtQueryContext interface