types

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NCHAR                     uint16 = 1
	NUMBER                    uint16 = 2
	BInteger                  uint16 = 3
	FLOAT                     uint16 = 4
	NullStr                   uint16 = 5
	VarNum                    uint16 = 6
	PDN                       uint16 = 7
	LONG                      uint16 = 8
	VARCHAR                   uint16 = 9
	ROWID                     uint16 = 11
	DATE                      uint16 = 12
	VarRaw                    uint16 = 15
	BFLOAT                    uint16 = 21
	BDOUBLE                   uint16 = 22
	RAW                       uint16 = 23
	LongRaw                   uint16 = 24
	TNS_JSON_TYPE_DATE        uint16 = 60
	TNS_JSON_TYPE_INTERVAL_YM uint16 = 61
	TNS_JSON_TYPE_INTERVAL_DS uint16 = 62
	UINT                      uint16 = 68
	LongVarChar               uint16 = 94
	LongVarRaw                uint16 = 95
	CHAR                      uint16 = 96
	CHARZ                     uint16 = 97
	IBFLOAT                   uint16 = 100
	IBDOUBLE                  uint16 = 101
	REFCURSOR                 uint16 = 102
	OCIXMLType                uint16 = 108
	XMLType                   uint16 = 109
	OCIRef                    uint16 = 110
	OCIClobLocator            uint16 = 112
	OCIBlobLocator            uint16 = 113
	OCIFileLocator            uint16 = 114
	RESULTSET                 uint16 = 116
	JSON                      uint16 = 119
	TNS_DATA_TYPE_OAC122      uint16 = 120
	VECTOR                    uint16 = 127
	OCIString                 uint16 = 155
	OCIDate                   uint16 = 156
	TimeStampDTY              uint16 = 180
	TimeStampTZ_DTY           uint16 = 181
	INTERVALYM_DTY            uint16 = 182
	INTERVALDS_DTY            uint16 = 183
	TimeTZ                    uint16 = 186
	TIMESTAMP                 uint16 = 187
	TIMESTAMPTZ               uint16 = 188
	IntervalYM                uint16 = 189
	IntervalDS                uint16 = 190
	UROWID                    uint16 = 208
	TimeStampLTZ_DTY          uint16 = 231
	TimeStampLTZ              uint16 = 232
	BOOLEAN                   uint16 = 0xFC
)

import "github.com/sijms/go-ora/v3"

View Source
const (
	MaxLenNumber      int64 = 0x16
	MaxLenBFloat      int64 = 0x4
	MaxLenBDouble     int64 = 0x8
	MaxLenDate        int64 = 0x7
	MaxLenTimeStamp   int64 = 0xB
	MaxLenTimeStampTZ int64 = 0xD
	MaxLenIntervalYM  int64 = 0x5
	MaxLenIntervalDS  int64 = 0xB
	MaxLenBFile       int64 = 4000
)

Variables

View Source
var (
	TyFloat64     = reflect.TypeOf((*float64)(nil)).Elem()
	TyFloat32     = reflect.TypeOf((*float32)(nil)).Elem()
	TyInt         = reflect.TypeOf((*int)(nil)).Elem()
	TyInt8        = reflect.TypeOf((*int8)(nil)).Elem()
	TyInt16       = reflect.TypeOf((*int16)(nil)).Elem()
	TyInt32       = reflect.TypeOf((*int32)(nil)).Elem()
	TyInt64       = reflect.TypeOf((*int64)(nil)).Elem()
	TyUint        = reflect.TypeOf((*uint)(nil)).Elem()
	TyUint8       = reflect.TypeOf((*uint8)(nil)).Elem()
	TyUint16      = reflect.TypeOf((*uint16)(nil)).Elem()
	TyUint32      = reflect.TypeOf((*uint32)(nil)).Elem()
	TyUint64      = reflect.TypeOf((*uint64)(nil)).Elem()
	TyBool        = reflect.TypeOf((*bool)(nil)).Elem()
	TyBytes       = reflect.TypeOf((*[]byte)(nil)).Elem()
	TyString      = reflect.TypeOf((*string)(nil)).Elem()
	TyTime        = reflect.TypeOf((*time.Time)(nil)).Elem()
	TyNullByte    = reflect.TypeOf((*sql.NullByte)(nil)).Elem()
	TyNullInt16   = reflect.TypeOf((*sql.NullInt16)(nil)).Elem()
	TyNullInt32   = reflect.TypeOf((*sql.NullInt32)(nil)).Elem()
	TyNullInt64   = reflect.TypeOf((*sql.NullInt64)(nil)).Elem()
	TyNullFloat64 = reflect.TypeOf((*sql.NullFloat64)(nil)).Elem()
	TyNullBool    = reflect.TypeOf((*sql.NullBool)(nil)).Elem()
	TyNullString  = reflect.TypeOf((*sql.NullString)(nil)).Elem()
	TyNullTime    = reflect.TypeOf((*sql.NullTime)(nil)).Elem()
	TyScanner     = reflect.TypeOf((*sql.Scanner)(nil)).Elem()

	TyNumber   = reflect.TypeOf((*Number)(nil)).Elem()
	TyBoolean  = reflect.TypeOf((*Bool)(nil)).Elem()
	TyVarchar  = reflect.TypeOf((*String)(nil)).Elem()
	TyDate     = reflect.TypeOf((*Date)(nil)).Elem()
	TyInterval = reflect.TypeOf((*Interval)(nil)).Elem()
	TyRaw      = reflect.TypeOf((*Raw)(nil)).Elem()
	TyVector   = reflect.TypeOf((*Vector)(nil)).Elem()
	TyJson     = reflect.TypeOf((*Json)(nil)).Elem()
	TyClob     = reflect.TypeOf((*Clob)(nil)).Elem()
	TyBlob     = reflect.TypeOf((*Blob)(nil)).Elem()
	TyBFile    = reflect.TypeOf((*BFile)(nil)).Elem()
	TyObject   = reflect.TypeOf((*Object)(nil)).Elem()
)

Functions

func Copy

func Copy(dest, src any) error

func RCopy

func RCopy(dest reflect.Value, src any) (err error)

Types

type BFile

type BFile struct {
	Basic

	//dirName  string
	//fileName string
	Conv converters.IStringConverter
	// contains filtered or unexported fields
}

func CreateBFile

func CreateBFile(db *sql.DB, dirName, fileName string) (*BFile, error)

func (*BFile) Close

func (file *BFile) Close() error

func (*BFile) CopyTo

func (file *BFile) CopyTo(dest driver.Value) error

func (*BFile) Exists

func (file *BFile) Exists() (bool, error)

func (*BFile) Free

func (l *BFile) Free() error

func (*BFile) GetDirName

func (file *BFile) GetDirName() string

func (*BFile) GetFileName

func (file *BFile) GetFileName() string

func (*BFile) GetLength

func (l *BFile) GetLength() (int64, error)

func (*BFile) GetLocator

func (l *BFile) GetLocator() Locator

func (*BFile) GetMaxLen

func (file *BFile) GetMaxLen() int64

func (*BFile) GetReadMode

func (l *BFile) GetReadMode() configurations.LobReadMode

func (*BFile) GetStreamer

func (l *BFile) GetStreamer() LobStreamer

func (*BFile) IsDataUploaded

func (l *BFile) IsDataUploaded() bool

func (*BFile) IsInit

func (file *BFile) IsInit() bool

func (*BFile) IsNil

func (l *BFile) IsNil() bool

func (*BFile) IsOpen

func (file *BFile) IsOpen() bool

func (*BFile) IsQuasi

func (l *BFile) IsQuasi() bool

func (*BFile) Open

func (file *BFile) Open(ctx context.Context) error

func (*BFile) ReadBytesFromPos

func (l *BFile) ReadBytesFromPos(ctx context.Context, pos, count int64) ([]byte, error)

func (*BFile) ReadFromPos

func (l *BFile) ReadFromPos(ctx context.Context, pos int64) ([]byte, error)
func (l *lobBase) Read(ctx context.Context) ([]byte, error) {
	return l.ReadBytesFromPos(ctx, 0, 0)
}

func (*BFile) Scan

func (file *BFile) Scan(input interface{}) error

func (*BFile) SetStreamer

func (file *BFile) SetStreamer(input LobStreamer)
func (file *BFile) filePath() string {
	if len(file.dirName) == 0 || len(file.fileName) == 0 {
		return ""
	}
	return file.dirName + "/" + file.fileName
}

func (*BFile) SetValue

func (file *BFile) SetValue(input interface{}) error

func (*BFile) Value

func (file *BFile) Value() (interface{}, error)

type Basic

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

func (*Basic) Bytes

func (b *Basic) Bytes() []byte

func (*Basic) GetDataType

func (b *Basic) GetDataType() uint16

func (*Basic) GetMaxLen

func (b *Basic) GetMaxLen() int64

func (*Basic) SetBytes

func (b *Basic) SetBytes(input []byte)

func (*Basic) SetDataType

func (b *Basic) SetDataType(dt uint16)

type Blob

type Blob struct {
	Raw

	UploadCtx context.Context
	// contains filtered or unexported fields
}

func CreateBlob

func CreateBlob(db *sql.DB, uploadCtx context.Context, input interface{}) (*Blob, error)

func NewBlob

func NewBlob(stream LobStreamer, uploadCtx context.Context, input interface{}) (*Blob, error)

func (*Blob) CopyTo

func (blob *Blob) CopyTo(dest driver.Value) error

func (*Blob) Free

func (l *Blob) Free() error

func (*Blob) GetLength

func (l *Blob) GetLength() (int64, error)

func (*Blob) GetLocator

func (l *Blob) GetLocator() Locator

func (*Blob) GetReadMode

func (l *Blob) GetReadMode() configurations.LobReadMode

func (*Blob) GetStreamer

func (l *Blob) GetStreamer() LobStreamer

func (*Blob) IsDataUploaded

func (l *Blob) IsDataUploaded() bool

func (*Blob) IsNil

func (l *Blob) IsNil() bool

func (*Blob) IsQuasi

func (l *Blob) IsQuasi() bool

func (*Blob) Read

func (blob *Blob) Read(ctx context.Context) error
func (blob *Blob) createLocatorAndUploadData(ctx context.Context) error {
	if l.stream == nil {
		return errNilStreamer
	}
	var err error
	if len(blob.bValue) == 0 {
		return nil
	}
	done := blob.stream.StartContext(ctx)
	defer blob.stream.EndContext(done)
	_, err = blob.stream.CreateTemporaryLocator(0, 0)
	if err != nil {
		return err
	}
	err = blob.stream.Write(blob.bValue)
	return err
}

func (*Blob) ReadBytesFromPos

func (l *Blob) ReadBytesFromPos(ctx context.Context, pos, count int64) ([]byte, error)

func (*Blob) ReadFromPos

func (l *Blob) ReadFromPos(ctx context.Context, pos int64) ([]byte, error)
func (l *lobBase) Read(ctx context.Context) ([]byte, error) {
	return l.ReadBytesFromPos(ctx, 0, 0)
}

func (*Blob) Scan

func (blob *Blob) Scan(src interface{}) error

func (*Blob) SetStreamer

func (l *Blob) SetStreamer(input LobStreamer)

func (*Blob) SetValue

func (blob *Blob) SetValue(input interface{}) error

func (*Blob) Upload

func (blob *Blob) Upload() error

type Bool

type Bool struct {
	Basic
}

func (*Bool) CopyTo

func (bl *Bool) CopyTo(dest driver.Value) error

func (*Bool) Scan

func (bl *Bool) Scan(input interface{}) error

func (*Bool) SetValue

func (bl *Bool) SetValue(input interface{}) error

func (*Bool) Value

func (bl *Bool) Value() (interface{}, error)

type Clob

type Clob struct {
	String
	// contains filtered or unexported fields
}

func CreateClob

func CreateClob(db *sql.DB, uploadCtx context.Context, input interface{}, useNClob bool) (*Clob, error)

func NewClob

func NewClob(stream LobStreamer, uploadCtx context.Context, input interface{}, useNClob bool) (*Clob, error)

func (*Clob) CopyTo

func (clob *Clob) CopyTo(dest driver.Value) error
func NewClob(streamer LobStreamer) *Clob {
	ret := &Clob{}
	ret.stream = streamer
	return ret
}
func NewClob(streamer LobStreamer, charsetID, charsetForm int, data []byte) (Clob, error) {
	ret := &clob{}
	var err error
	ret.stream = streamer
	if ret.IsVarWidthChar() {
		if ret.stream.DatabaseVersionNumber() < 10200 && ret.IsLittleEndian() {
			ret.charsetConverter, err = streamer.GetStringCoder().GetStringCoder(2002, 0)
		} else {
			ret.charsetConverter, err = streamer.GetStringCoder().GetStringCoder(2000, 0)
		}
	} else {
		ret.charsetConverter, err = streamer.GetStringCoder().GetStringCoder(charsetID, charsetForm)
	}
	if err != nil {
		return nil, err
	}
	if len(data) == 0 {
		ret.Valid = false
	} else {
		ret.Valid = true
		ret.String = ret.charsetConverter.Decode(data)
	}
	return ret, nil
}
func (l *clob) Charset() (charsetID int, charsetForm int) {
	return l.charsetID, l.charsetForm
}

func (*Clob) Free

func (l *Clob) Free() error

func (*Clob) GetLength

func (l *Clob) GetLength() (int64, error)

func (*Clob) GetLocator

func (l *Clob) GetLocator() Locator

func (*Clob) GetReadMode

func (l *Clob) GetReadMode() configurations.LobReadMode

func (*Clob) GetStreamer

func (l *Clob) GetStreamer() LobStreamer

func (*Clob) IsDataUploaded

func (l *Clob) IsDataUploaded() bool

func (*Clob) IsNil

func (l *Clob) IsNil() bool

func (*Clob) IsQuasi

func (l *Clob) IsQuasi() bool

func (*Clob) Read

func (clob *Clob) Read(ctx context.Context) error

func (*Clob) ReadBytesFromPos

func (l *Clob) ReadBytesFromPos(ctx context.Context, pos, count int64) ([]byte, error)

func (*Clob) ReadFromPos

func (l *Clob) ReadFromPos(ctx context.Context, pos int64) ([]byte, error)
func (l *lobBase) Read(ctx context.Context) ([]byte, error) {
	return l.ReadBytesFromPos(ctx, 0, 0)
}

func (*Clob) Scan

func (clob *Clob) Scan(value interface{}) error

func (*Clob) SetStreamer

func (l *Clob) SetStreamer(input LobStreamer)

func (*Clob) SetValue

func (clob *Clob) SetValue(input interface{}) error

SetValue use stream to get charset converter call basic SetValue upload value to server

func (*Clob) Upload

func (clob *Clob) Upload() error

type Date

type Date struct {
	Basic
	AsUTC            bool
	DBTimeZone       *time.Location
	DBServerTimeZone *time.Location
}

func NewTimeStamp

func NewTimeStamp(t time.Time) *Date

func NewTimeStampTZ

func NewTimeStampTZ(t time.Time) *Date

func (*Date) CopyTo

func (date *Date) CopyTo(dest driver.Value) (err error)

func (*Date) GetMaxLen

func (date *Date) GetMaxLen() int64
func NewTimeStampLTZ(t time.Time) *Date {
	ret := new(Date)
	ret.dataType = TimeStampLTZ_DTY
	_ = ret.SetValue(t)
	return ret

}

func (*Date) Scan

func (date *Date) Scan(value interface{}) (err error)

func (*Date) SetValue

func (date *Date) SetValue(input interface{}) (err error)

func (*Date) Value

func (date *Date) Value() (interface{}, error)

type Interval

type Interval struct {
	Basic
}

func NewDaySecondInterval

func NewDaySecondInterval(day, hour, minute, second, nanosecond int) (*Interval, error)

func NewYearMonthInterval

func NewYearMonthInterval(year, month int) (*Interval, error)

func (*Interval) CopyTo

func (interval *Interval) CopyTo(dest driver.Value) error

func (*Interval) GetMaxLen

func (interval *Interval) GetMaxLen() int64

func (*Interval) Scan

func (interval *Interval) Scan(value interface{}) error

func (*Interval) SetValue

func (interval *Interval) SetValue(input interface{}) error

func (*Interval) Value

func (interval *Interval) Value() (interface{}, error)

type Json

type Json struct {
	Basic
	Coder JsonCoder
	// contains filtered or unexported fields
}

func (*Json) CopyTo

func (js *Json) CopyTo(dest driver.Value) error

func (*Json) Free

func (l *Json) Free() error

func (*Json) GetLength

func (l *Json) GetLength() (int64, error)

func (*Json) GetLocator

func (js *Json) GetLocator() Locator

func (*Json) GetReadMode

func (l *Json) GetReadMode() configurations.LobReadMode

func (*Json) GetStreamer

func (l *Json) GetStreamer() LobStreamer

func (*Json) IsDataUploaded

func (l *Json) IsDataUploaded() bool

func (*Json) IsNil

func (l *Json) IsNil() bool

func (*Json) IsQuasi

func (l *Json) IsQuasi() bool

func (*Json) Read

func (js *Json) Read(ctx context.Context) error

func (*Json) ReadBytesFromPos

func (l *Json) ReadBytesFromPos(ctx context.Context, pos, count int64) ([]byte, error)

func (*Json) ReadFromPos

func (l *Json) ReadFromPos(ctx context.Context, pos int64) ([]byte, error)
func (l *lobBase) Read(ctx context.Context) ([]byte, error) {
	return l.ReadBytesFromPos(ctx, 0, 0)
}

func (*Json) Scan

func (js *Json) Scan(input interface{}) error

func (*Json) SetStreamer

func (l *Json) SetStreamer(input LobStreamer)

func (*Json) SetValue

func (js *Json) SetValue(input interface{}) error

func (*Json) Upload

func (js *Json) Upload() error

func (*Json) Value

func (js *Json) Value() (interface{}, error)

type JsonCoder

type JsonCoder interface {
	JsonEncoder
	JsonDecoder
}

type Json interface { }

type JsonDecoder

type JsonDecoder interface {
	DecodeJson(data []byte) (interface{}, error)
}

type JsonEncoder

type JsonEncoder interface {
	EncodeJson(input interface{}) ([]byte, error)
}

type Lob

type Lob interface {
	GetLocator() Locator
	Free() error
	GetLength() (int64, error)
	Read(ctx context.Context) error
	GetReadMode() configurations.LobReadMode
	sql.Scanner
}

type LobStreamer

type LobStreamer interface {
	StartContext(ctx context.Context) chan struct{}
	EndContext(done chan struct{})
	GetLocator() Locator
	SetLocator(locator Locator)
	DatabaseVersionNumber() int
	GetStringCoder() converters.StringCoder
	GetLobStreamMode() configurations.LobFetch
	GetLobReadMode() configurations.LobReadMode
	GetTracer() trace.Tracer
	GetSize() (int64, error)
	Exists() (bool, error)
	CreateTemporaryLocator(charsetID, charsetForm int) (Locator, error)
	FreeTemporaryLocator() error
	Open(mode, opID int) error
	Read(offset, count int64) ([]byte, error)
	Write(data []byte) error
	Close(opID int) error
}

type Locator

type Locator []byte

func NewQuasiLocator

func NewQuasiLocator(dataLen uint64) Locator

func (Locator) IsLittleEndian

func (loc Locator) IsLittleEndian() bool

func (Locator) IsQuasi

func (loc Locator) IsQuasi() bool

func (Locator) IsReadOnly

func (loc Locator) IsReadOnly() bool

func (Locator) IsTemporary

func (loc Locator) IsTemporary() bool

func (Locator) IsValueBased

func (loc Locator) IsValueBased() bool

func (Locator) IsVarWidthChar

func (loc Locator) IsVarWidthChar() bool

type Number

type Number struct {
	Basic
}

func NewBinaryDouble

func NewBinaryDouble(number float64) *Number

func NewBinaryFloat

func NewBinaryFloat(number float32) *Number

func NewNumber

func NewNumber(n interface{}) (*Number, error)

func (*Number) CopyTo

func (number *Number) CopyTo(dest interface{}) error

func (*Number) Float64

func (number *Number) Float64() (float64, error)

func (*Number) GetMaxLen

func (number *Number) GetMaxLen() int64

func (*Number) Int64

func (number *Number) Int64() (int64, error)

func (*Number) Scan

func (number *Number) Scan(value interface{}) error

func (*Number) SetValue

func (number *Number) SetValue(input interface{}) error

func (*Number) String

func (number *Number) String() (string, error)

func (*Number) Uint64

func (number *Number) Uint64() (uint64, error)

func (*Number) Value

func (number *Number) Value() (interface{}, error)

type Object

type Object struct {
	Basic
	Name  string
	Owner string
	Value driver.Value
}

type OracleType

type OracleType interface {
	SetValue(input interface{}) error
	Value() (interface{}, error)
	CopyTo(dest driver.Value) error
	SetDataType(dt uint16)
	GetDataType() uint16
	GetMaxLen() int64
	sql.Scanner
}

type Raw

type Raw struct {
	Basic
}

func (*Raw) CopyTo

func (raw *Raw) CopyTo(dest driver.Value) error

func (*Raw) Scan

func (raw *Raw) Scan(input interface{}) error

func (*Raw) SetValue

func (raw *Raw) SetValue(input interface{}) error

func (*Raw) Value

func (raw *Raw) Value() (interface{}, error)

type RowID

type RowID struct {
	Basic
	Rba         int64
	PartitionID int64

	BlockNumber int64
	SlotNumber  int64
	// contains filtered or unexported fields
}

func (RowID) SetValue

func (rowid RowID) SetValue(_ interface{}) error

func (RowID) Value

func (rowid RowID) Value() (interface{}, error)

type String

type String struct {
	Basic
	Conv        converters.IStringConverter
	UseNCharset bool
}

func (*String) CopyTo

func (str *String) CopyTo(dest driver.Value) (err error)

func (*String) Scan

func (str *String) Scan(input interface{}) error

func (*String) SetValue

func (str *String) SetValue(input interface{}) error

func (*String) Value

func (str *String) Value() (interface{}, error)

type Vector

type Vector struct {
	Basic
	// contains filtered or unexported fields
}

func CreateVector

func CreateVector(array interface{}) (*Vector, error)

CreateVector : create vector from supported array type: uint8, float32 and float64

func (*Vector) CopyTo

func (vector *Vector) CopyTo(dest driver.Value) error

func (*Vector) Free

func (l *Vector) Free() error

func (*Vector) GetLength

func (l *Vector) GetLength() (int64, error)

func (*Vector) GetLocator

func (vector *Vector) GetLocator() Locator

func (*Vector) GetReadMode

func (l *Vector) GetReadMode() configurations.LobReadMode

func (*Vector) GetStreamer

func (l *Vector) GetStreamer() LobStreamer

func (*Vector) IsDataUploaded

func (l *Vector) IsDataUploaded() bool

func (*Vector) IsNil

func (l *Vector) IsNil() bool

func (*Vector) IsQuasi

func (l *Vector) IsQuasi() bool

func (*Vector) Read

func (vector *Vector) Read(ctx context.Context) error

func (*Vector) ReadBytesFromPos

func (l *Vector) ReadBytesFromPos(ctx context.Context, pos, count int64) ([]byte, error)

func (*Vector) ReadFromPos

func (l *Vector) ReadFromPos(ctx context.Context, pos int64) ([]byte, error)
func (l *lobBase) Read(ctx context.Context) ([]byte, error) {
	return l.ReadBytesFromPos(ctx, 0, 0)
}

func (*Vector) Scan

func (vector *Vector) Scan(input interface{}) error

func (*Vector) SetStreamer

func (l *Vector) SetStreamer(input LobStreamer)

func (*Vector) SetValue

func (vector *Vector) SetValue(input interface{}) error

func (*Vector) Upload

func (vector *Vector) Upload() error

func (*Vector) Value

func (vector *Vector) Value() (interface{}, error)

type VectorDataType

type VectorDataType int

type VectorType

type VectorType int
const (
	VECTOR_SPARSE VectorType = iota
	VECTOR_DENSE
)

const (

VECTOR_NIL VectorDataType = iota
VECTOR_UINT8
VECTOR_FL32
VECTOR_FL64

)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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