📄 sdora.pas
字号:
{*******************************************************}
{ }
{ Delphi SQLDirect Component Library }
{ Oracle API (SQLNet 2.3+) Interface Unit }
{ OCI Date: 23.05.1997 (updated from OCI8) }
{ OCI Date: 19.04.2002 (updated from OCI8 v.9) }
{ }
{ Copyright (c) 1997,2005 by Yuri Sheino }
{ }
{*******************************************************}
{$I SqlDir.inc}
unit SDOra {$IFDEF SD_CLR} platform {$ENDIF};
interface
uses
Windows, SysUtils, Classes, Db, Registry, SyncObjs,
{$IFDEF SD_VCL6}
FmtBcd, Variants,
{$ENDIF}
{$IFDEF SD_CLR}
System.Runtime.InteropServices,
{$ENDIF}
SDConsts, SDCommon;
const
(* FETCH RETURN CODES *)
FetRTru = 1; // data truncated
FetRSin = 2; // signed number fetched
FetRDnn = 3; // data is not numeric
FetRNof = 4; // numeric overflow
FetRDtn = 5; // data type not supported
FetRDnd = 6; // data is not in date format
FetRNul = -1; // data is null
{*******************************************************************************
* limits.h - implementation dependent values *
*Purpose: *
* Contains defines for a number of implementation dependent values *
* which are commonly used in C programs. *
*******************************************************************************}
const
CHAR_BIT = 8; // number of bits in a char
SCHAR_MIN = -128; // minimum signed char value
SCHAR_MAX = 127; // maximum signed char value
UCHAR_MAX = $FF; // maximum unsigned char value
CHAR_MIN = 0;
CHAR_MAX = UCHAR_MAX;
MB_LEN_MAX = 2; // max. # bytes in multibyte char
SHRT_MIN = -32768; // minimum (signed) short value
SHRT_MAX = 32767; // maximum (signed) short value
USHRT_MAX = $FFFF; // maximum unsigned short value
INT_MIN = (-2147483647 - 1); // minimum (signed) int value
INT_MAX = 2147483647; // maximum (signed) int value
UINT_MAX = $FFFFFFFF; // maximum unsigned int value
LONG_MIN = (-2147483647 - 1); // minimum (signed) long value
LONG_MAX = 2147483647; // maximum (signed) long value
ULONG_MAX = $FFFFFFFF; // maximum unsigned long value
{*******************************************************************************
* OraTypes.h *
*******************************************************************************}
//const
// #define boolean int
// TRUE = 1;
// FALSE = 0;
type
eword = Integer; // use where sign not important
uword = Integer; // use where unsigned important
sword = Integer; // use where signed important
size_t = Integer;
OraBoolean = LongBool; // 4 byte
const
EWORDMAXVAL = INT_MAX;
EWORDMINVAL = 0;
UWORDMAXVAL = UINT_MAX;
UWORDMINVAL = 0;
SWORDMAXVAL = INT_MAX;
SWORDMINVAL = INT_MIN;
MINEWORDMAXVAL= 32767;
MAXEWORDMINVAL= 0;
MINUWORDMAXVAL= 65535;
MAXUWORDMINVAL= 0;
MINSWORDMAXVAL= 32767;
MAXSWORDMINVAL= -32767;
const
EB1MAXVAL = SCHAR_MAX;
EB1MINVAL = 0;
UB1MAXVAL = UCHAR_MAX;
UB1MINVAL = 0;
SB1MAXVAL = SCHAR_MAX;
SB1MINVAL = SCHAR_MIN;
MINEB1MAXVAL = 127;
MAXEB1MINVAL = 0;
MINUB1MAXVAL = 255;
MAXUB1MINVAL = 0;
MINSB1MAXVAL = 127;
MAXSB1MINVAL = -127;
// number of bits in a byte
UB1BITS = CHAR_BIT;
UB1MASK = $FF;
const
EB2MAXVAL = SHRT_MAX;
EB2MINVAL = 0;
UB2MAXVAL = USHRT_MAX;
UB2MINVAL = 0;
SB2MAXVAL = SHRT_MAX;
SB2MINVAL = SHRT_MIN;
MINEB2MAXVAL = 32767;
MAXEB2MINVAL = 0;
MINUB2MAXVAL = 65535;
MAXUB2MINVAL = 0;
MINSB2MAXVAL = 32767;
MAXSB2MINVAL = -32767;
type
// human readable (printable) characters
PText = TSDCharPtr;
PPText = ^PText;
POraText = PText; // in Oracle9: oratext = text = unsigned char (oratypes.h)
eb1 = ShortInt; // use where sign not important
ub1 = Byte; // use where unsigned important
sb1 = ShortInt; // use where signed important
eb2 = SmallInt; // use where sign not important
ub2 = Word; // use where unsigned important
sb2 = SmallInt; // use where signed important
eb4 = LongInt; // use where sign not important
ub4 = LongInt; // use where unsigned important
sb4 = LongInt; // use where signed important
const
EB4MAXVAL = INT_MAX;
EB4MINVAL = 0;
UB4MAXVAL = UINT_MAX;
UB4MINVAL = 0;
SB4MAXVAL = INT_MAX;
SB4MINVAL = INT_MIN;
MINEB4MAXVAL = 2147483647;
MAXEB4MINVAL = 0;
MINUB4MAXVAL = UINT_MAX;
MAXUB4MINVAL = 0;
MINSB4MAXVAL = 2147483647;
MAXSB4MINVAL = -2147483647;
type
ubig_ora = LongInt; // use where unsigned important
sbig_ora = LongInt; // use where signed important
const
UBIG_ORAMAXVAL = ULONG_MAX;
UBIG_ORAMINVAL = 0;
SBIG_ORAMAXVAL = LONG_MAX;
SBIG_ORAMINVAL = LONG_MIN;
MINUBIG_ORAMAXVAL = 2147483647;
MAXUBIG_ORAMINVAL = 0;
MINSBIG_ORAMAXVAL = 2147483647;
MAXSBIG_ORAMINVAL = -2147483647;
const
SIZE_TMAXVAL = UB4MAXVAL; // This case applies for others
MINSIZE_TMAXVAL = 65535;
SizeOfPtr = SizeOf(LongInt);
type
dvoid = TSDPtr;
{$IFDEF SD_CLR}
Pdvoid = dvoid;
PPdvoid = dvoid;
eb1p = dvoid;
ub1p = dvoid;
sb1p = dvoid;
eb2p = dvoid;
ub2p = dvoid;
ub2pp = dvoid;
sb2p = dvoid;
eb4p = dvoid;
ub4p = dvoid;
ub4pp = dvoid;
sb4p = dvoid;
{$ELSE}
Pdvoid = ^dvoid;
PPdvoid = ^Pdvoid;
eb1p = ^eb1;
ub1p = ^ub1;
sb1p = ^sb1;
eb2p = ^eb2;
ub2p = ^ub2;
ub2pp = ^ub2p;
sb2p = ^sb2;
eb4p = ^eb4;
ub4p = ^ub4;
ub4pp = ^ub4p;
sb4p = ^sb4;
{$ENDIF}
{*******************************************************************************
* ocidfn.h
* Common header file for OCI C sample programs. *
* This header declares the cursor and logon data area structure. *
* The types used are defined in <oratypes.h>. *
*******************************************************************************}
type
// The cda_head struct is strictly PRIVATE. It is used
// internally only. Do not use this struct in OCI programs.
cda_head = record
v2_rc: sb2;
ft: ub2;
rpc: ub4;
peo: ub2;
fc: ub1;
rcs1: ub1;
rc: ub2;
wrn: ub1;
rcs2: ub1;
rcs3: sword;
rcs4: ub4;
rcs5: ub2;
rcs6: ub1;
rcs7: ub4;
rcs8: ub2;
ose: sword;
chk: ub1;
rcsp: dvoid;
end;
const
CDA_SIZE = 64;
LDA_SIZE = CDA_SIZE;
HDA_SIZE = 256;
CDA_HEAD_SIZE = {$IFDEF SD_CLR} 48 {$ELSE} SizeOf(cda_head) {$ENDIF};
type
// rowid structures
rd = record
rcs4: ub4;
rcs5: ub2;
rcs6: ub1;
end;
rid = record
r: rd;
rcs7: ub4;
rcs8: ub2;
end;
{$IFDEF SD_CLR}
[StructLayout(LayoutKind.Sequential)]
cda_def = record
v2_rc: sb2; // V2 return code
ft: ub2; // SQL function type
rpc: ub4; // rows processed count
peo: ub2; // parse error offset
fc: ub1; // OCI function code
rcs1: ub1; // filler area
rc: ub2; // V7 return code
wrn: ub1; // warning flags
rcs2: ub1; // reserved
rcs3: sword; // reserved
rowid: rid; // rowid structure
ose: sword; // OSD dependent error
chk: ub1;
rcsp: dvoid; // pointer to reserved area
[MarshalAs(UnmanagedType.ByValArray, SizeConst = CDA_SIZE - CDA_HEAD_SIZE)]
rcs9: packed array[1..CDA_SIZE - CDA_HEAD_SIZE] of ub1; // filler
end;
{$ELSE}
// the real CDA, padded to CDA_SIZE bytes in size
cda_def = record
v2_rc: sb2; // V2 return code
ft: ub2; // SQL function type
rpc: ub4; // rows processed count
peo: ub2; // parse error offset
fc: ub1; // OCI function code
rcs1: ub1; // filler area
rc: ub2; // V7 return code
wrn: ub1; // warning flags
rcs2: ub1; // reserved
rcs3: sword; // reserved
rowid: rid; // rowid structure
ose: sword; // OSD dependent error
chk: ub1;
rcsp: dvoid; // pointer to reserved area
rcs9: array[1..CDA_SIZE - CDA_HEAD_SIZE] of ub1; // filler
end;
{$ENDIF}
// the logon data area (LDA) is the same shape as the CDA
TCdaDef = cda_def;
Lda_Def = Cda_Def;
TLdaDef = Lda_Def;
THdaDef = array[1..HDA_SIZE div 4] of ub4;
{$IFDEF SD_CLR}
PHdaDef = dvoid;
PCdaDef = dvoid;
PLdaDef = dvoid;
{$ELSE}
PHdaDef = ^THdaDef;
PCdaDef = ^TCdaDef;
PLdaDef = ^TLdaDef;
{$ENDIF}
const
// OCI Environment Modes for opinit call
OCI_EV_DEF = 0; // default single-threaded environment
OCI_EV_TSF = 1; // thread-safe environment
// OCI Logon Modes for olog call
OCI_LM_DEF = 0; // default login
OCI_LM_NBL = 1; // non-blocking logon
// OCI_*_PIECE defines the piece types that are returned or set
OCI_ONE_PIECE = 0; // there or this is the only piece
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -