oci8

package module
v0.0.0-...-63c4a72 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2018 License: MIT Imports: 16 Imported by: 0

README

go-oci8

GoDoc Reference Build Status

Description

Oracle driver conforming to the built-in database/sql interface

Installation

This package can be installed with the go get command:

go get github.com/mattn/go-oci8

You need to put oci8.pc like into your $PKG_CONFIG_PATH. oci8.pc should be like below.

Example for Windows
prefix=/devel/target/XXXXXXXXXXXXXXXXXXXXXXXXXX
exec_prefix=${prefix}
libdir=c:/oraclexe/app/oracle/product/11.2.0/server/oci/lib/msvc
includedir=c:/oraclexe/app/oracle/product/11.2.0/server/oci/include/include

glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums

Name: oci8
Description: oci8 library
Libs: -L${libdir} -loci
Cflags: -I${includedir}
Version: 11.2
Example for Linux
prefix=/devel/target/XXXXXXXXXXXXXXXXXXXXXXXXXX
exec_prefix=${prefix}
libdir=/usr/lib/oracle/11.2/client64/lib
includedir=/usr/include/oracle/11.2/client64

glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums

Name: oci8
Description: oci8 library
Libs: -L${libdir} -lclntsh
Cflags: -I${includedir}
Version: 11.2
Example for MacOs

Please install pkg-config with brew if not already present. Download the instant client and the sdk and unpack it e.g. in your Downloads folder and create therein a file names oci8.pc. Please replace <username> with your actual username.

prefixdir=/Users/<username>/Downloads/instantclient_12_2/
libdir=${prefixdir}
includedir=${prefixdir}/sdk/include

Name: OCI
Description: Oracle database driver
Version: 12.2
Libs: -L${libdir} -lclntsh
Cflags: -I${includedir}

You also have to set these environment variables (e.g. permanently by adding them to your .bashrc)

export LD_LIBRARY_PATH=/Users/<username>/Downloads/instantclient_12_2
export PKG_CONFIG_PATH=/Users/<username>/Downloads/instantclient_12_2

Examples

Examples can be found under the ./_example directory

ToDo

  • LastInserted is not int64
  • Fetch number is more improvable

Author

Yasuhiro Matsumoto (a.k.a mattn)

Special Thanks

Jamil Djadala

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CByte

func CByte(b []byte) *C.char

func GetLastInsertId

func GetLastInsertId(id int64) string

func QueryEscape

func QueryEscape(s string) string

QueryEscape escapes the string so it can be safely placed inside a URL query.

func QueryUnescape

func QueryUnescape(s string) (string, error)

QueryUnescape does the inverse transformation of QueryEscape, converting %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits.

Types

type DSN

type DSN struct {
	Connect  string
	Username string
	Password string

	Location *time.Location
	// contains filtered or unexported fields
}

func ParseDSN

func ParseDSN(dsnString string) (dsn *DSN, err error)

ParseDSN parses a DSN used to connect to Oracle It expects to receive a string in the form: [username/[password]@]host[:port][/instance_name][?param1=value1&...&paramN=valueN]

Currently the parameters supported is: 1 'loc' which sets the timezone to read times in as and to marshal to when writing times to Oracle date, 2 'isolation' =READONLY,SERIALIZABLE,DEFAULT 3 'prefetch_rows' 4 'prefetch_memory' 5 'questionph' =YES,NO,TRUE,FALSE enable question-mark placeholders, default to false

type EscapeError

type EscapeError string

func (EscapeError) Error

func (e EscapeError) Error() string

type OCI8Conn

type OCI8Conn struct {
	// contains filtered or unexported fields
}

func (*OCI8Conn) Begin

func (c *OCI8Conn) Begin() (driver.Tx, error)

func (*OCI8Conn) BeginTx

func (c *OCI8Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)

BeginTx implement ConnBeginTx.

func (*OCI8Conn) CheckNamedValue

func (c *OCI8Conn) CheckNamedValue(nv *driver.NamedValue) error

func (*OCI8Conn) Close

func (c *OCI8Conn) Close() error

func (*OCI8Conn) Exec

func (c *OCI8Conn) Exec(query string, args []driver.Value) (driver.Result, error)

func (*OCI8Conn) ExecContext

func (c *OCI8Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)

ExecContext implement ExecerContext.

func (*OCI8Conn) Ping

func (c *OCI8Conn) Ping(ctx context.Context) error

Ping implement Pinger.

func (*OCI8Conn) Prepare

func (c *OCI8Conn) Prepare(query string) (driver.Stmt, error)

func (*OCI8Conn) PrepareContext

func (c *OCI8Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)

PrepareContext implement ConnPrepareContext.

func (*OCI8Conn) QueryContext

func (c *OCI8Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)

QueryContext implement QueryerContext.

type OCI8Driver

type OCI8Driver struct {
}

func (*OCI8Driver) Open

func (d *OCI8Driver) Open(dsnString string) (connection driver.Conn, err error)

type OCI8Result

type OCI8Result struct {
	// contains filtered or unexported fields
}

func (*OCI8Result) LastInsertId

func (r *OCI8Result) LastInsertId() (int64, error)

func (*OCI8Result) RowsAffected

func (r *OCI8Result) RowsAffected() (int64, error)

type OCI8Rows

type OCI8Rows struct {
	// contains filtered or unexported fields
}

func (*OCI8Rows) Close

func (rc *OCI8Rows) Close() error

func (*OCI8Rows) ColumnTypeDatabaseTypeName

func (rc *OCI8Rows) ColumnTypeDatabaseTypeName(i int) string

ColumnTypeDatabaseTypeName implement RowsColumnTypeDatabaseTypeName.

func (*OCI8Rows) ColumnTypeLength

func (rc *OCI8Rows) ColumnTypeLength(i int) (length int64, ok bool)

func (*OCI8Rows) ColumnTypeNullable

func (rc *OCI8Rows) ColumnTypeNullable(i int) (nullable, ok bool)

ColumnTypeNullable implement RowsColumnTypeNullable.

func (*OCI8Rows) ColumnTypeScanType

func (rc *OCI8Rows) ColumnTypeScanType(i int) reflect.Type

ColumnTypeScanType implement RowsColumnTypeScanType.

func (*OCI8Rows) Columns

func (rc *OCI8Rows) Columns() []string

func (*OCI8Rows) Next

func (rc *OCI8Rows) Next(dest []driver.Value) error

type OCI8Stmt

type OCI8Stmt struct {
	// contains filtered or unexported fields
}

func (*OCI8Stmt) Close

func (s *OCI8Stmt) Close() error

func (*OCI8Stmt) Exec

func (s *OCI8Stmt) Exec(args []driver.Value) (r driver.Result, err error)

func (*OCI8Stmt) ExecContext

func (s *OCI8Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)

ExecContext implement ExecerContext.

func (*OCI8Stmt) NumInput

func (s *OCI8Stmt) NumInput() int

func (*OCI8Stmt) Query

func (s *OCI8Stmt) Query(args []driver.Value) (rows driver.Rows, err error)

func (*OCI8Stmt) QueryContext

func (s *OCI8Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)

QueryContext implement QueryerContext.

type OCI8Tx

type OCI8Tx struct {
	// contains filtered or unexported fields
}

func (*OCI8Tx) Commit

func (tx *OCI8Tx) Commit() error

func (*OCI8Tx) Rollback

func (tx *OCI8Tx) Rollback() error

type Values

type Values map[string][]string

Values maps a string key to a list of values. It is typically used for query parameters and form values. Unlike in the http.Header map, the keys in a Values map are case-sensitive.

func ParseQuery

func ParseQuery(query string) (m Values, err error)

ParseQuery parses the URL-encoded query string and returns a map listing the values specified for each key. ParseQuery always returns a non-nil map containing all the valid query parameters found; err describes the first decoding error encountered, if any.

func (Values) Add

func (v Values) Add(key, value string)

Add adds the value to key. It appends to any existing values associated with key.

func (Values) Del

func (v Values) Del(key string)

Del deletes the values associated with key.

func (Values) Encode

func (v Values) Encode() string

Encode encodes the values into “URL encoded” form ("bar=baz&foo=quux") not sorted by key

func (Values) Get

func (v Values) Get(key string) string

Get gets the first value associated with the given key. If there are no values associated with the key, Get returns the empty string. To access multiple values, use the map directly.

func (Values) Set

func (v Values) Set(key, value string)

Set sets the key to value. It replaces any existing values.

Directories

Path Synopsis
_example
nls

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL