Documentation ¶
Overview ¶
Package goracle is a database/sql/driver for Oracle DB.
The connection string for the sql.Open("goracle", connString) call can be the simple
login/password@sid [AS SYSDBA|AS SYSOPER]
type (with sid being the sexp returned by tnsping), or in the form of
ora://login:password@sid/? \ sysdba=0& \ sysoper=0& \ poolMinSessions=1& \ poolMaxSessions=1000& \ poolIncrement=1& \ connectionClass=POOLED& \ standaloneConnection=0& \ enableEvents=0& \ heterogeneousPool=0& \ prelim=0& \ poolWaitTimeout=5m& \ poolSessionMaxLifetime=1h& \ poolSessionTimeout=30s& \ timezone=Local& \ newPassword=
These are the defaults. Many advocate that a static session pool (min=max, incr=0) is better, with 1-10 sessions per CPU thread. See http://docs.oracle.com/cd/E82638_01/JJUCP/optimizing-real-world-performance.htm#JJUCP-GUID-BC09F045-5D80-4AF5-93F5-FEF0531E0E1D You may also use ConnectionParams to configure a connection.
If you specify connectionClass, that'll reuse the same session pool without the connectionClass, but will specify it on each session acquire. Thus you can cluster the session pool with classes, or use POOLED for DRCP.
For what can be used as "sid", see https://docs.oracle.com/en/database/oracle/oracle-database/19/netag/configuring-naming-methods.html#GUID-E5358DEA-D619-4B7B-A799-3D2F802500F1
Index ¶
- Constants
- Variables
- func CallbackSubscr(ctx unsafe.Pointer, message *C.dpiSubscrMessage)
- func ContextWithLog(ctx context.Context, logF func(...interface{}) error) context.Context
- func ContextWithTraceTag(ctx context.Context, tt TraceTag) context.Context
- func ContextWithUserPassw(ctx context.Context, user, password string) context.Context
- func EnableDbmsOutput(ctx context.Context, conn Execer) error
- func MapToSlice(qry string, metParam func(string) interface{}) (string, []interface{})
- func NamedToOrdered(qry string, namedParams map[string]interface{}) (string, []interface{})
- func NewConnector(name string, onInit func(driver.Conn) error) (driver.Connector, error)
- func NewSessionIniter(m map[string]string) func(driver.Conn) error
- func ReadDbmsOutput(ctx context.Context, w io.Writer, conn preparer) error
- func Timezone(ctx context.Context, ex Execer) (*time.Location, error)
- func WrapRows(ctx context.Context, q Querier, rset driver.Rows) (*sql.Rows, error)
- type Column
- type CompileError
- type Conn
- type ConnectionParams
- type Data
- func (d *Data) Get() interface{}
- func (d *Data) GetBool() bool
- func (d *Data) GetBytes() []byte
- func (d *Data) GetFloat32() float32
- func (d *Data) GetFloat64() float64
- func (d *Data) GetInt64() int64
- func (d *Data) GetIntervalDS() time.Duration
- func (d *Data) GetIntervalYM() IntervalYM
- func (d *Data) GetLob() *Lob
- func (d *Data) GetObject() *Object
- func (d *Data) GetStmt() driver.Stmt
- func (d *Data) GetTime() time.Time
- func (d *Data) GetUint64() uint64
- func (d *Data) IsNull() bool
- func (d *Data) IsObject() bool
- func (d *Data) Set(v interface{}) error
- func (d *Data) SetBool(b bool)
- func (d *Data) SetBytes(b []byte)
- func (d *Data) SetFloat32(f float32)
- func (d *Data) SetFloat64(f float64)
- func (d *Data) SetInt64(i int64)
- func (d *Data) SetIntervalDS(dur time.Duration)
- func (d *Data) SetIntervalYM(ym IntervalYM)
- func (d *Data) SetLob(lob *DirectLob)
- func (d *Data) SetNull()
- func (d *Data) SetObject(o *Object)
- func (d *Data) SetStmt(s *statement)
- func (d *Data) SetTime(t time.Time)
- func (d *Data) SetUint64(u uint64)
- type DeliveryMode
- type DeqMode
- type DeqNavigation
- type DeqOptions
- type DirectLob
- type EnqOptions
- type Event
- type EventType
- type Execer
- type IntervalYM
- type Lob
- type Message
- type MessageState
- type Number
- func (n Number) MarshalJSON() ([]byte, error)
- func (n Number) MarshalText() ([]byte, error)
- func (n *Number) Scan(v interface{}) error
- func (n Number) String() string
- func (n *Number) UnmarshalJSON(p []byte) error
- func (n *Number) UnmarshalText(p []byte) error
- func (n Number) Value() (driver.Value, error)
- type Object
- func (O *Object) Close() error
- func (O *Object) Collection() *ObjectCollection
- func (O *Object) Get(name string) (interface{}, error)
- func (O *Object) GetAttribute(data *Data, name string) error
- func (O *Object) ObjectRef() *Object
- func (O *Object) ResetAttributes() error
- func (O *Object) Set(name string, v interface{}) error
- func (O *Object) SetAttribute(name string, data *Data) error
- type ObjectAttribute
- type ObjectCollection
- func (O *ObjectCollection) Append(v interface{}) error
- func (O *ObjectCollection) AppendData(data *Data) error
- func (O *ObjectCollection) AppendObject(obj *Object) error
- func (O *ObjectCollection) AsSlice(dest interface{}) (interface{}, error)
- func (O *ObjectCollection) Delete(i int) error
- func (O *ObjectCollection) First() (int, error)
- func (O *ObjectCollection) Get(i int) (interface{}, error)
- func (O *ObjectCollection) GetItem(data *Data, i int) error
- func (O *ObjectCollection) Last() (int, error)
- func (O *ObjectCollection) Len() (int, error)
- func (O *ObjectCollection) Next(i int) (int, error)
- func (O *ObjectCollection) Set(i int, v interface{}) error
- func (O *ObjectCollection) SetItem(i int, data *Data) error
- func (O *ObjectCollection) Trim(n int) error
- type ObjectScanner
- type ObjectType
- type ObjectWriter
- type Operation
- type Option
- type OraErr
- type Querier
- type QueryColumn
- type QueryEvent
- type Queue
- func (Q *Queue) Close() error
- func (Q *Queue) DeqOptions() (DeqOptions, error)
- func (Q *Queue) Dequeue(messages []Message) (int, error)
- func (Q *Queue) EnqOptions() (EnqOptions, error)
- func (Q *Queue) Enqueue(messages []Message) error
- func (Q *Queue) Name() string
- func (Q *Queue) SetDeqCorrelation(correlation string) error
- func (Q *Queue) SetDeqOptions(D DeqOptions) error
- func (Q *Queue) SetEnqOptions(E EnqOptions) error
- type RowEvent
- type ShutdownMode
- type StartupMode
- type Subscription
- type TableEvent
- type TraceTag
- type VersionInfo
- type Visibility
Constants ¶
const ( // StartupDefault is the default mode for startup which permits database access to all users. StartupDefault = StartupMode(C.DPI_MODE_STARTUP_DEFAULT) // StartupForce shuts down a running instance (using ABORT) before starting a new one. This mode should only be used in unusual circumstances. StartupForce = StartupMode(C.DPI_MODE_STARTUP_FORCE) // StartupRestrict only allows database access to users with both the CREATE SESSION and RESTRICTED SESSION privileges (normally the DBA). StartupRestrict = StartupMode(C.DPI_MODE_STARTUP_RESTRICT) )
const ( // ShutdownDefault - further connections to the database are prohibited. Wait for users to disconnect from the database. ShutdownDefault = ShutdownMode(C.DPI_MODE_SHUTDOWN_DEFAULT) // ShutdownTransactional - further connections to the database are prohibited and no new transactions are allowed to be started. Wait for active transactions to complete. ShutdownTransactional = ShutdownMode(C.DPI_MODE_SHUTDOWN_TRANSACTIONAL) // ShutdownTransactionalLocal - behaves the same way as ShutdownTransactional but only waits for local transactions to complete. ShutdownTransactionalLocal = ShutdownMode(C.DPI_MODE_SHUTDOWN_TRANSACTIONAL_LOCAL) // ShutdownImmediate - all uncommitted transactions are terminated and rolled back and all connections to the database are closed immediately. ShutdownImmediate = ShutdownMode(C.DPI_MODE_SHUTDOWN_IMMEDIATE) // ShutdownAbort - all uncommitted transactions are terminated and are not rolled back. This is the fastest way to shut down the database but the next database startup may require instance recovery. ShutdownAbort = ShutdownMode(C.DPI_MODE_SHUTDOWN_ABORT) // ShutdownFinal shuts down the database. This mode should only be used in the second call to dpiConn_shutdownDatabase(). ShutdownFinal = ShutdownMode(C.DPI_MODE_SHUTDOWN_FINAL) )
const ( // DefaultFetchRowCount is the number of prefetched rows by default (if not changed through FetchRowCount statement option). DefaultFetchRowCount = 1 << 8 // DefaultArraySize is the length of the maximum PL/SQL array by default (if not changed through ArraySize statement option). DefaultArraySize = 1 << 10 )
const ( // DpiMajorVersion is the wanted major version of the underlying ODPI-C library. DpiMajorVersion = C.DPI_MAJOR_VERSION // DpiMinorVersion is the wanted minor version of the underlying ODPI-C library. DpiMinorVersion = C.DPI_MINOR_VERSION // DpiPatchLevel is the patch level version of the underlying ODPI-C library DpiPatchLevel = C.DPI_PATCH_LEVEL // DpiVersionNumber is the underlying ODPI-C version as one number (Major * 10000 + Minor * 100 + Patch) DpiVersionNumber = C.DPI_VERSION_NUMBER // DriverName is set on the connection to be seen in the DB DriverName = "gopkg.in/goracle.v2 : " + Version // DefaultPoolMinSessions specifies the default value for minSessions for pool creation. DefaultPoolMinSessions = 1 // DefaultPoolMaxSessions specifies the default value for maxSessions for pool creation. DefaultPoolMaxSessions = 1000 // DefaultPoolIncrement specifies the default value for increment for pool creation. DefaultPoolIncrement = 1 // DefaultConnectionClass is the default connectionClass DefaultConnectionClass = "GORACLE" // NoConnectionPoolingConnectionClass is a special connection class name to indicate no connection pooling. // It is the same as setting standaloneConnection=1 NoConnectionPoolingConnectionClass = "NO-CONNECTION-POOLING" // DefaultSessionTimeout is the seconds before idle pool sessions get evicted DefaultSessionTimeout = 5 * time.Minute // DefaultWaitTimeout is the milliseconds to wait for a session to become available DefaultWaitTimeout = 30 * time.Second // DefaultMaxLifeTime is the maximum time in seconds till a pooled session may exist DefaultMaxLifeTime = 1 * time.Hour )
const ( NoWait = uint32(0) WaitForever = uint32(1<<31 - 1) )
const ( // MsgStateReady says that "The message is ready to be processed". MsgStateReady = MessageState(C.DPI_MSG_STATE_READY) // MsgStateWaiting says that "The message is waiting for the delay time to expire". MsgStateWaiting = MessageState(C.DPI_MSG_STATE_WAITING) // MsgStateProcessed says that "The message has already been processed and is retained". MsgStateProcessed = MessageState(C.DPI_MSG_STATE_PROCESSED) // MsgStateExpired says that "The message has been moved to the exception queue". MsgStateExpired = MessageState(C.DPI_MSG_STATE_EXPIRED) )
const ( // DeliverPersistent is to Dequeue only persistent messages from the queue. This is the default mode. DeliverPersistent = DeliveryMode(C.DPI_MODE_MSG_PERSISTENT) // DeliverBuffered is to Dequeue only buffered messages from the queue. DeliverBuffered = DeliveryMode(C.DPI_MODE_MSG_BUFFERED) // DeliverPersistentOrBuffered is to Dequeue both persistent and buffered messages from the queue. DeliverPersistentOrBuffered = DeliveryMode(C.DPI_MODE_MSG_PERSISTENT_OR_BUFFERED) )
const ( // VisibleImmediate means that "The message is not part of the current transaction but constitutes a transaction of its own". VisibleImmediate = Visibility(C.DPI_VISIBILITY_IMMEDIATE) // VisibleOnCommit means that "The message is part of the current transaction. This is the default value". VisibleOnCommit = Visibility(C.DPI_VISIBILITY_ON_COMMIT) )
const ( // DeqRemove reads the message and updates or deletes it. This is the default mode. Note that the message may be retained in the queue table based on retention properties. DeqRemove = DeqMode(C.DPI_MODE_DEQ_REMOVE) // DeqBrows reads the message without acquiring a lock on the message (equivalent to a SELECT statement). DeqBrowse = DeqMode(C.DPI_MODE_DEQ_BROWSE) // DeqLocked reads the message and obtain a write lock on the message (equivalent to a SELECT FOR UPDATE statement). DeqLocked = DeqMode(C.DPI_MODE_DEQ_LOCKED) // DeqPeek confirms receipt of the message but does not deliver the actual message content. DeqPeek = DeqMode(C.DPI_MODE_DEQ_REMOVE_NO_DATA) )
const ( DeqNavigation(C.DPI_DEQ_NAV_FIRST_MSG) NavNextTran = DeqNavigation(C.DPI_DEQ_NAV_NEXT_TRANSACTION) NavNext = DeqNavigation(C.DPI_DEQ_NAV_NEXT_MSG) )NavFirst =
const ( EvtStartup = EventType(C.DPI_EVENT_STARTUP) EvtShutdown = EventType(C.DPI_EVENT_SHUTDOWN) EvtShutdownAny = EventType(C.DPI_EVENT_SHUTDOWN_ANY) EvtDereg = EventType(C.DPI_EVENT_DEREG) EvtObjChange = EventType(C.DPI_EVENT_OBJCHANGE) EvtQueryChange = EventType(C.DPI_EVENT_QUERYCHANGE) EvtAQ = EventType(C.DPI_EVENT_AQ) )
Events that can be watched.
const ( // OpAll Indicates that notifications should be sent for all operations on the table or query. OpAll = Operation(C.DPI_OPCODE_ALL_OPS) // OpAllRows Indicates that all rows have been changed in the table or query (or too many rows were changed or row information was not requested). OpAllRows = Operation(C.DPI_OPCODE_ALL_ROWS) // OpInsert Indicates that an insert operation has taken place in the table or query. OpInsert = Operation(C.DPI_OPCODE_INSERT) // OpUpdate Indicates that an update operation has taken place in the table or query. OpUpdate = Operation(C.DPI_OPCODE_UPDATE) // OpDelete Indicates that a delete operation has taken place in the table or query. OpDelete = Operation(C.DPI_OPCODE_DELETE) // OpAlter Indicates that the registered table or query has been altered. OpAlter = Operation(C.DPI_OPCODE_ALTER) // OpDrop Indicates that the registered table or query has been dropped. OpDrop = Operation(C.DPI_OPCODE_DROP) // OpUnknown An unknown operation has taken place. OpUnknown = Operation(C.DPI_OPCODE_UNKNOWN) )
const MsgIDLength = 16
const Version = "v2.24.0"
Version of this driver
Variables ¶
var ( // Int64 for converting to-from int64. Int64 = intType{} // Float64 for converting to-from float64. Float64 = floatType{} // Num for converting to-from Number (string) Num = numType{} )
var DefaultDeqOptions = DeqOptions{ Mode: DeqRemove, DeliveryMode: DeliverPersistent, Navigation: NavFirst, Visibility: VisibleImmediate, Wait: 30, }
DefaultDeqOptions is the default set for NewQueue.
var DefaultEnqOptions = EnqOptions{ Visibility: VisibleImmediate, DeliveryMode: DeliverPersistent, }
DefaultEnqOptions is the default set for NewQueue.
var ErrNoSuchKey = errors.New("no such key")
ErrNoSuchKey is the error for missing key in lookup.
var ErrNotCollection = errors.New("not collection")
ErrNotCollection is returned when the Object is not a collection.
var ErrNotExist = errors.New("not exist")
ErrNotExist is returned when the collection's requested element does not exist.
var ErrNotSupported = errors.New("not supported")
var Log func(...interface{}) error
Log function. By default, it's nil, and thus logs nothing. If you want to change this, change it to a github.com/go-kit/kit/log.Swapper.Log or analog to be race-free.
Functions ¶
func CallbackSubscr ¶ added in v2.0.3
func CallbackSubscr(ctx unsafe.Pointer, message *C.dpiSubscrMessage)
CallbackSubscr is the callback for C code on subscription event.
func ContextWithLog ¶ added in v2.1.3
ContextWithLog returns a context with the given log function.
func ContextWithTraceTag ¶ added in v2.1.12
ContextWithTraceTag returns a context with the specified TraceTag, which will be set on the session used.
func ContextWithUserPassw ¶ added in v2.10.0
ContextWithUserPassw returns a context with the specified user and password, to be used with heterogeneous pools.
func EnableDbmsOutput ¶ added in v2.0.1
EnableDbmsOutput enables DBMS_OUTPUT buffering on the given connection. This is required if you want to retrieve the output with ReadDbmsOutput later.
func MapToSlice ¶ added in v2.0.3
MapToSlice modifies query for map (:paramname) to :%d placeholders + slice of params.
Calls metParam for each parameter met, and returns the slice of their results.
func NamedToOrdered ¶ added in v2.0.3
NamedToOrdered converts the query from named params (:paramname) to :%d placeholders + slice of params, copying the params verbatim.
func NewConnector ¶ added in v2.13.0
NewConnector returns a driver.Connector to be used with sql.OpenDB, which calls the given onInit if the connection is new.
func NewSessionIniter ¶ added in v2.13.0
NewSessionIniter returns a function suitable for use in NewConnector as onInit, which calls "ALTER SESSION SET <key>='<value>'" for each element of the given map.
func ReadDbmsOutput ¶ added in v2.0.1
ReadDbmsOutput copies the DBMS_OUTPUT buffer into the given io.Writer.
Types ¶
type Column ¶
type Column struct { Name string ObjectType *C.dpiObjectType OracleType C.dpiOracleTypeNum NativeType C.dpiNativeTypeNum Size, SizeInChars, DBSize C.uint32_t Precision C.int16_t Scale C.int8_t Nullable bool }
Column holds the info from a column.
type CompileError ¶ added in v2.0.1
type CompileError struct {
Owner, Name, Type string
Line, Position, Code int64
Text string
Warning bool
}
CompileError represents a compile-time error as in user_errors view.
func GetCompileErrors ¶ added in v2.0.1
func GetCompileErrors(queryer queryer, all bool) ([]CompileError, error)
GetCompileErrors returns the slice of the errors in user_errors.
If all is false, only errors are returned; otherwise, warnings, too.
func (CompileError) Error ¶ added in v2.0.1
func (ce CompileError) Error() string
type Conn ¶ added in v2.1.14
type Conn interface { driver.Conn driver.ConnBeginTx driver.ConnPrepareContext driver.Pinger Break() error Commit() error Rollback() error ClientVersion() (VersionInfo, error) ServerVersion() (VersionInfo, error) GetObjectType(name string) (ObjectType, error) NewSubscription(string, func(Event)) (*Subscription, error) Startup(StartupMode) error Shutdown(ShutdownMode) error NewData(baseType interface{}, SliceLen, BufSize int) ([]*Data, error) Timezone() *time.Location }
Conn is the interface for a connection, to be returned by DriverConn.
type ConnectionParams ¶ added in v2.1.4
type ConnectionParams struct {
Username, Password, SID, ConnClass string
// NewPassword is used iff StandaloneConnection is true!
NewPassword string
MinSessions, MaxSessions, PoolIncrement int
WaitTimeout, MaxLifeTime, SessionTimeout time.Duration
IsSysDBA, IsSysOper, IsSysASM, IsPrelim bool
HeterogeneousPool bool
StandaloneConnection bool
EnableEvents bool
Timezone *time.Location
}
ConnectionParams holds the params for a connection (pool). You can use ConnectionParams{...}.StringWithPassword() as a connection string in sql.Open.
func ParseConnString ¶ added in v2.0.1
func ParseConnString(connString string) (ConnectionParams, error)
ParseConnString parses the given connection string into a struct.
func (ConnectionParams) String ¶ added in v2.1.4
func (P ConnectionParams) String() string
String returns the string representation of ConnectionParams. The password is replaced with a "SECRET" string!
func (ConnectionParams) StringNoClass ¶ added in v2.1.4
func (P ConnectionParams) StringNoClass() string
StringNoClass returns the string representation of ConnectionParams, without class info. The password is replaced with a "SECRET" string!
func (ConnectionParams) StringWithPassword ¶ added in v2.5.9
func (P ConnectionParams) StringWithPassword() string
StringWithPassword returns the string representation of ConnectionParams (as String() does), but does NOT obfuscate the password, just prints it as is.
type Data ¶ added in v2.0.3
type Data struct { ObjectType ObjectType NativeTypeNum C.dpiNativeTypeNum // contains filtered or unexported fields }
Data holds the data to/from Oracle.
func NewData ¶ added in v2.18.3
NewData creates a new Data structure for the given type, populated with the given type.
func (*Data) Get ¶ added in v2.0.3
func (d *Data) Get() interface{}
Get returns the contents of Data.
func (*Data) GetFloat32 ¶ added in v2.0.3
GetFloat32 gets float32 from the data.
func (*Data) GetFloat64 ¶ added in v2.0.3
GetFloat64 gets float64 from the data.
func (*Data) GetIntervalDS ¶ added in v2.0.3
GetIntervalDS gets duration as interval date-seconds from data.
func (*Data) GetIntervalYM ¶ added in v2.0.3
func (d *Data) GetIntervalYM() IntervalYM
GetIntervalYM gets IntervalYM from the data.
func (*Data) GetObject ¶ added in v2.0.3
GetObject gets Object from data.
As with all Objects, you MUST call Close on it when not needed anymore!
func (*Data) IsObject ¶ added in v2.9.0
IsObject returns whether the data contains an Object or not.
func (*Data) SetFloat32 ¶ added in v2.0.3
SetFloat32 sets the data as float32.
func (*Data) SetFloat64 ¶ added in v2.0.3
SetFloat64 sets the data as float64.
func (*Data) SetIntervalDS ¶ added in v2.0.3
SetIntervalDS sets the duration as interval date-seconds to data.
func (*Data) SetIntervalYM ¶ added in v2.0.3
func (d *Data) SetIntervalYM(ym IntervalYM)
SetIntervalYM sets IntervalYM to the data.
func (*Data) SetNull ¶ added in v2.16.1
func (d *Data) SetNull()
SetNull sets the value of the data to be the null value.
func (*Data) SetStmt ¶ added in v2.0.3
func (d *Data) SetStmt(s *statement)
SetStmt sets Stmt to data.
type DeliveryMode ¶ added in v2.20.0
type DeliveryMode uint32
DeliveryMode constants for delivery modes.
type DeqNavigation ¶ added in v2.20.0
type DeqNavigation uint32
DeqNavigation constants for navigation.
type DeqOptions ¶ added in v2.20.0
type DeqOptions struct {
Condition, Consumer, Correlation string
MsgID, Transformation string
Mode DeqMode
DeliveryMode DeliveryMode
Visibility Visibility
Wait uint32
}
DeqOptions are the options used to dequeue a message.
type DirectLob ¶
type DirectLob struct {
// contains filtered or unexported fields
}
DirectLob holds a Lob and allows direct (Read/WriteAt, not streaming Read/Write) operations on it.
func (*DirectLob) Set ¶ added in v2.12.6
Set the contents of the LOB to the given byte slice. The LOB is cleared first.
type EnqOptions ¶ added in v2.20.0
type EnqOptions struct { Transformation string Visibility Visibility DeliveryMode DeliveryMode }
EnqOptions are the options used to enqueue a message.
type Event ¶ added in v2.0.3
type Event struct { Tables []TableEvent Queries []QueryEvent DB string Err error Type EventType }
Event for a subscription.
type IntervalYM ¶ added in v2.0.3
type IntervalYM struct {
Years, Months int
}
IntervalYM holds Years and Months as interval.
type Message ¶ added in v2.20.0
type Message struct { DeliveryMode DeliveryMode Enqueued time.Time Delay, Expiration int32 Priority, NumAttempts int32 Correlation, ExceptionQ string MsgID, OriginalMsgID [16]byte State MessageState Raw []byte Object *Object }
Message is a message - either received or being sent.
type MessageState ¶ added in v2.20.0
type MessageState uint32
MessageState constants representing message's state.
type Number ¶ added in v2.0.1
type Number string
Number as string
func (Number) MarshalJSON ¶ added in v2.1.14
MarshalJSON marshals a Number into a JSON string.
func (Number) MarshalText ¶ added in v2.1.14
MarshalText marshals a Number to text.
func (*Number) UnmarshalJSON ¶ added in v2.1.14
UnmarshalJSON parses a JSON string into the Number.
func (*Number) UnmarshalText ¶ added in v2.1.14
UnmarshalText parses text into a Number.
type Object ¶ added in v2.0.3
type Object struct { ObjectType // contains filtered or unexported fields }
Object represents a dpiObject.
func (*Object) Collection ¶ added in v2.16.1
func (O *Object) Collection() *ObjectCollection
Collection returns &ObjectCollection{Object: O} iff the Object is a collection. Otherwise it returns nil.
func (*Object) GetAttribute ¶ added in v2.0.3
GetAttribute gets the i-th attribute into data.
func (*Object) ResetAttributes ¶ added in v2.15.0
ResetAttributes prepare all attributes for use the object as IN parameter
type ObjectAttribute ¶ added in v2.0.3
type ObjectAttribute struct { Name string ObjectType // contains filtered or unexported fields }
ObjectAttribute is an attribute of an Object.
func (ObjectAttribute) Close ¶ added in v2.0.3
func (A ObjectAttribute) Close() error
Close the ObjectAttribute.
type ObjectCollection ¶ added in v2.0.3
type ObjectCollection struct {
*Object
}
ObjectCollection represents a Collection of Objects - itself an Object, too.
func (*ObjectCollection) Append ¶ added in v2.0.3
func (O *ObjectCollection) Append(v interface{}) error
Append v to the collection.
func (*ObjectCollection) AppendData ¶ added in v2.20.0
func (O *ObjectCollection) AppendData(data *Data) error
AppendData to the collection.
func (*ObjectCollection) AppendObject ¶ added in v2.18.3
func (O *ObjectCollection) AppendObject(obj *Object) error
AppendObject adds an Object to the collection.
func (*ObjectCollection) AsSlice ¶ added in v2.9.0
func (O *ObjectCollection) AsSlice(dest interface{}) (interface{}, error)
AsSlice retrieves the collection into a slice.
func (*ObjectCollection) Delete ¶ added in v2.0.3
func (O *ObjectCollection) Delete(i int) error
Delete i-th element of the collection.
func (*ObjectCollection) First ¶ added in v2.0.3
func (O *ObjectCollection) First() (int, error)
First returns the first element's index of the collection.
func (*ObjectCollection) Get ¶ added in v2.0.3
func (O *ObjectCollection) Get(i int) (interface{}, error)
Get the i-th element of the collection.
func (*ObjectCollection) GetItem ¶ added in v2.20.0
func (O *ObjectCollection) GetItem(data *Data, i int) error
GetItem gets the i-th element of the collection into data.
func (*ObjectCollection) Last ¶ added in v2.0.3
func (O *ObjectCollection) Last() (int, error)
Last returns the index of the last element.
func (*ObjectCollection) Len ¶ added in v2.0.3
func (O *ObjectCollection) Len() (int, error)
Len returns the length of the collection.
func (*ObjectCollection) Next ¶ added in v2.0.3
func (O *ObjectCollection) Next(i int) (int, error)
Next returns the succeeding index of i.
func (*ObjectCollection) Set ¶ added in v2.0.3
func (O *ObjectCollection) Set(i int, v interface{}) error
Set the i-th element of the collection with value.
func (*ObjectCollection) SetItem ¶ added in v2.20.0
func (O *ObjectCollection) SetItem(i int, data *Data) error
SetItem sets the i-th element of the collection with data.
func (*ObjectCollection) Trim ¶ added in v2.0.3
func (O *ObjectCollection) Trim(n int) error
Trim the collection to n.
type ObjectScanner ¶ added in v2.15.0
ObjectScanner assigns a value from a database object
type ObjectType ¶ added in v2.0.3
type ObjectType struct {
Schema, Name string
DBSize, ClientSizeInBytes, CharSize int
CollectionOf *ObjectType
Attributes map[string]ObjectAttribute
OracleTypeNum C.dpiOracleTypeNum
NativeTypeNum C.dpiNativeTypeNum
Precision int16
Scale int8
FsPrecision uint8
// contains filtered or unexported fields
}
ObjectType holds type info of an Object.
func GetObjectType ¶ added in v2.0.3
GetObjectType returns the ObjectType for the name.
func (ObjectType) FullName ¶ added in v2.4.4
func (t ObjectType) FullName() string
FullName returns the object's name with the schame prepended.
func (ObjectType) NewCollection ¶ added in v2.18.3
func (t ObjectType) NewCollection() (*ObjectCollection, error)
NewCollection returns a new Collection object with ObjectType type. If the ObjectType is not a Collection, it returns ErrNotCollection error.
func (ObjectType) NewObject ¶ added in v2.0.3
func (t ObjectType) NewObject() (*Object, error)
NewObject returns a new Object with ObjectType type.
As with all Objects, you MUST call Close on it when not needed anymore!
func (ObjectType) String ¶ added in v2.20.0
func (t ObjectType) String() string
type ObjectWriter ¶ added in v2.15.0
type ObjectWriter interface { WriteObject() error // contains filtered or unexported methods }
ObjectWriter update database object before binding
type Option ¶
type Option func(*stmtOptions)
Option holds statement options.
PlSQLArrays is to signal that the slices given in arguments of Exec to be left as is - the default is to treat them as arguments for ExecMany.
func ArraySize ¶ added in v2.1.6
ArraySize returns an option to set the array size to be used, overriding DefaultArraySize.
func CallTimeout ¶ added in v2.8.1
CallTimeout sets the round-trip timeout (OCI_ATTR_CALL_TIMEOUT).
func ClobAsString ¶ added in v2.4.4
func ClobAsString() Option
ClobAsString returns an option to force fetching CLOB columns as strings.
DEPRECATED.
func FetchRowCount ¶ added in v2.1.6
FetchRowCount returns an option to set the rows to be fetched, overriding DefaultFetchRowCount.
func LobAsReader ¶ added in v2.9.0
func LobAsReader() Option
LobAsReader is an option to set query columns of CLOB/BLOB to be returned as a Lob.
LOB as a reader and writer is not the most performant at all. Yes, OCI and ODPI-C provide a way to retrieve this data directly. Effectively, all you need to do is tell ODPI-C that you want a "long string" or "long raw" returned. You can do that by telling ODPI-C you want a variable with oracleTypeNum=DPI_ORACLE_TYPE_LONG_VARCHAR or DPI_ORACLE_TYPE_LONG_RAW and nativeTypeNum=DPI_NATIVE_TYPE_BYTES. ODPI-C will handle all of the dynamic fetching and allocation that is required. :-) You can also use DPI_ORACLE_TYPE_VARCHAR and DPI_ORACLE_TYPE_RAW as long as you set the size > 32767 -- whichever way you wish to use.
With the use of LOBs, there is one round-trip to get the LOB locators, then a round-trip for each read() that is performed. If you request the length there is another round-trip required. So if you fetch 100 rows with 2 CLOB columns, that means you get 401 round-trips. Using string/[]bytes directly means only one round trip. So you can see that if your database is remote with high latency you can have a significant performance penalty!
func MagicTypeConversion ¶ added in v2.6.0
func MagicTypeConversion() Option
MagicTypeConversion returns an option to force converting named scalar types (e.g. "type underlying int64") to their scalar underlying type.
func NumberAsString ¶ added in v2.16.0
func NumberAsString() Option
NumberAsString returns an option to return numbers as string, not Number.
type OraErr ¶ added in v2.1.13
type OraErr struct {
// contains filtered or unexported fields
}
OraErr is an error holding the ORA-01234 code and the message.
type QueryColumn ¶ added in v2.0.1
QueryColumn is the described column.
func DescribeQuery ¶ added in v2.0.1
DescribeQuery describes the columns in the qry.
This can help using unknown-at-compile-time, a.k.a. dynamic queries.
type QueryEvent ¶ added in v2.0.3
type QueryEvent struct { Tables []TableEvent ID uint64 Operation }
QueryEvent is an event of a Query.
type Queue ¶ added in v2.20.0
type Queue struct { PayloadObjectType ObjectType // contains filtered or unexported fields }
Queue represents an Oracle Advanced Queue.
func NewQueue ¶ added in v2.20.0
func NewQueue(ctx context.Context, execer Execer, name string, payloadObjectTypeName string) (*Queue, error)
NewQueue creates a new Queue.
WARNING: the connection given to it must not be closed before the Queue is closed! So use an sql.Conn for it.
func (*Queue) DeqOptions ¶ added in v2.20.0
func (Q *Queue) DeqOptions() (DeqOptions, error)
DeqOptions returns the queue's dequeue options in effect.
func (*Queue) Dequeue ¶ added in v2.20.0
Dequeues messages into the given slice. Returns the number of messages filled in the given slice.
func (*Queue) EnqOptions ¶ added in v2.20.0
func (Q *Queue) EnqOptions() (EnqOptions, error)
EnqOptions returns the queue's enqueue options in effect.
func (*Queue) Enqueue ¶ added in v2.20.0
Enqueue all the messages given.
WARNING: calling this function in parallel on different connections acquired from the same pool may fail due to Oracle bug 29928074. Ensure that this function is not run in parallel, use standalone connections or connections from different pools, or make multiple calls to Queue.enqOne() instead. The function Queue.Dequeue() call is not affected.
func (*Queue) SetDeqCorrelation ¶ added in v2.21.3
SetDeqCorrelation is a convenience function setting the Correlation DeqOption
func (*Queue) SetDeqOptions ¶ added in v2.21.3
func (Q *Queue) SetDeqOptions(D DeqOptions) error
SetDeqOptions sets all the dequeue options
func (*Queue) SetEnqOptions ¶ added in v2.21.3
func (Q *Queue) SetEnqOptions(E EnqOptions) error
SetEnqOptions sets all the enqueue options
type ShutdownMode ¶ added in v2.11.0
type ShutdownMode C.dpiShutdownMode
ShutdownMode for the database.
type Subscription ¶ added in v2.0.3
type Subscription struct {
// contains filtered or unexported fields
}
Subscription for events in the DB.
func (*Subscription) Close ¶ added in v2.0.3
func (s *Subscription) Close() error
Close the subscription.
This code is EXPERIMENTAL yet!
func (*Subscription) Register ¶ added in v2.0.3
func (s *Subscription) Register(qry string, params ...interface{}) error
Register a query for Change Notification.
This code is EXPERIMENTAL yet!
type TableEvent ¶ added in v2.0.3
TableEvent is for a Table-related event.
type TraceTag ¶ added in v2.1.12
type TraceTag struct { // ClientIdentifier - specifies an end user based on the logon ID, such as HR.HR ClientIdentifier string // ClientInfo - client-specific info ClientInfo string // DbOp - database operation DbOp string // Module - specifies a functional block, such as Accounts Receivable or General Ledger, of an application Module string // Action - specifies an action, such as an INSERT or UPDATE operation, in a module Action string }
TraceTag holds tracing information for the session. It can be set on the session with ContextWithTraceTag.
type VersionInfo ¶ added in v2.0.3
type VersionInfo struct { ServerRelease string Version, Release, Update, PortRelease, PortUpdate, Full int }
VersionInfo holds version info returned by Oracle DB.
func ClientVersion ¶ added in v2.0.3
func ClientVersion(ctx context.Context, ex Execer) (VersionInfo, error)
ClientVersion returns the VersionInfo from the DB.
func ServerVersion ¶ added in v2.0.1
func ServerVersion(ctx context.Context, ex Execer) (VersionInfo, error)
ServerVersion returns the VersionInfo of the client.
func (VersionInfo) String ¶ added in v2.0.3
func (V VersionInfo) String() string
type Visibility ¶ added in v2.20.0
type Visibility uint32
Visibility constants represents visibility.