File : oci-lib.ads


with
   System,
   Interfaces.C,
   Interfaces.C.Strings;

package OCI.Lib is

   package C renames Interfaces.C;
   package Cstr renames C.Strings;

   subtype Text_Ptr is Cstr.Chars_Ptr;
   subtype Text is C.Char_Array;
   subtype Undefined is Integer;
   Empty : constant := 0;

   OCI_SUCCESS           : constant := 0;
   OCI_SUCCESS_WITH_INFO : constant := 1;
   OCI_NO_DATA           : constant := 100;
   OCI_ERROR             : constant := -1;
   OCI_INVALID_HANDLE    : constant := -2;
   OCI_NEED_DATA         : constant := 99;
   OCI_STILL_EXECUTING   : constant := -3123;
   OCI_CONTINUE          : constant := -24200;

   ------------------------Scrollable Cursor Options--------------------------*/
   OCI_FETCH_NEXT : constant := 2; -- next row */
   OCI_FETCH_FIRST : constant := 16#04#; -- first row of the result set */
   OCI_FETCH_LAST : constant := 16#08#; -- the last row of the result set */
   OCI_FETCH_PRIOR : constant := 16#10#; -- the previous row relative to current */
   OCI_FETCH_ABSOLUTE : constant := 16#20#; --absolute offset from first */
   OCI_FETCH_RELATIVE  : constant := 16#40#; --offset relative to current */
   OCI_FETCH_RESERVED_1 : constant := 16#80#; --reserved for internal use */

   OCI_V7_SYNTAX   : constant := 2;-- V7 language
   OCI_V8_SYNTAX   : constant := 3;-- V8 language
   OCI_NTV_SYNTAX  : constant := 1;-- Use what so ever is the native lang of server

   -----------------------------Attribute Types-------------------------------
   OCI_ATTR_FNCODE : constant := 1 ;                         -- the OCI function code */
   OCI_ATTR_OBJECT  : constant := 2;-- is the environment initialized in object mode */
   OCI_ATTR_NONBLOCKING_MODE : constant := 3 ;                   -- non blocking mode */
   OCI_ATTR_SQLCODE : constant := 4  ;                                -- the SQL verb */
   OCI_ATTR_ENV : constant := 5  ;  -- the environment handle */
   OCI_ATTR_SERVER: constant := 6  ;                             -- the server handle */
   OCI_ATTR_SESSION : constant :=7  ;                      -- the user session handle */
   OCI_ATTR_TRANS  : constant := 8  ;                       -- the transaction handle */
   OCI_ATTR_ROW_COUNT  : constant := 9 ;          -- the rows processed so far */
   OCI_ATTR_SQLFNCODE: constant := 10 ;           -- the SQL verb of the statement */
   OCI_ATTR_PREFETCH_ROWS  : constant :=11    ;-- sets the number of rows to prefetch */
   OCI_ATTR_NESTED_PREFETCH_ROWS : constant :=12 ;-- the prefetch rows of nested table*/
   OCI_ATTR_PREFETCH_MEMORY: constant := 13         ;-- memory limit for rows fetched */
   OCI_ATTR_NESTED_PREFETCH_MEMORY : constant :=14   ;-- memory limit for nested rows */
   OCI_ATTR_CHAR_COUNT : constant := 15 ;
   -- this specifies the bind and define size in characters */
   OCI_ATTR_PDSCL  : constant := 16                          ;-- packed decimal scale */
   OCI_ATTR_PDFMT  : constant := 17                         ;-- packed decimal format */
   OCI_ATTR_PARAM_COUNT: constant := 18       ;-- number of column in the select list */
   OCI_ATTR_ROWID  : constant := 19                                     ;
   -- the rowid */
   OCI_ATTR_CHARSET : constant := 20                      ;-- the character set value */
   OCI_ATTR_NCHAR  : constant := 21                                    ;
   -- NCHAR type */
   OCI_ATTR_USERNAME : constant :=22                           ;-- username attribute */
   OCI_ATTR_PASSWORD : constant :=23                           ;-- password attribute */
   OCI_ATTR_STMT_TYPE  : constant := 24                            ;
   -- statement type */
   OCI_ATTR_INTERNAL_NAME : constant :=  25             ;-- user friendly global name */
   OCI_ATTR_EXTERNAL_NAME  : constant := 26      ;-- the internal name for global txn */
   OCI_ATTR_XID     : constant := 27           ;-- XOPEN defined global transaction id */
   OCI_ATTR_TRANS_LOCK: constant := 28                                            ;
   -- */
   OCI_ATTR_TRANS_NAME: constant := 29    ;-- string to identify a global transaction */
   OCI_ATTR_HEAPALLOC: constant := 30                ;-- memory allocated on the heap */
   OCI_ATTR_CHARSET_ID : constant :=31                           ;
   -- Character Set ID */
   OCI_ATTR_CHARSET_FORM : constant :=32                       ;-- Character Set Form */
   OCI_ATTR_MAXDATA_SIZE : constant :=33       ;-- Maximumsize of data on the server  */
   OCI_ATTR_CACHE_OPT_SIZE : constant :=34              ;-- object cache optimal size */
   OCI_ATTR_CACHE_MAX_SIZE: constant := 35   ;-- object cache maximum size percentage */
   OCI_ATTR_PINOPTION : constant :=36             ;-- object cache default pin option */
   OCI_ATTR_ALLOC_DURATION : constant :=37
      ;-- object cache default allocation duration */
   OCI_ATTR_PIN_DURATION : constant :=38        ;-- object cache default pin duration */
   OCI_ATTR_FDO        : constant :=  39       ;-- Format Descriptor object attribute */
   OCI_ATTR_POSTPROCESSING_CALLBACK: constant := 40;-- Callback to process outbind data */
   OCI_ATTR_POSTPROCESSING_CONTEXT : constant :=41
      ;-- Callback context to process outbind data */
   OCI_ATTR_ROWS_RETURNED : constant :=42
      ;-- Number of rows returned in current iter - for Bind handles */
   OCI_ATTR_FOCBK      : constant :=  43              ;-- Failover Callback attribute */
   OCI_ATTR_IN_V8_MODE  : constant := 44 ;-- is the server/service context in V8 mode */
   OCI_ATTR_LOBEMPTY    : constant := 45                              ;
   -- empty lob ? */
   OCI_ATTR_SESSLANG    : constant := 46                  ;-- session language handle */

   -- Attributes common to Columns and Stored Procs */
   OCI_ATTR_DATA_SIZE  : constant := 1;  -- maximum size of the data */
   OCI_ATTR_DATA_TYPE  : constant := 2;  -- the SQL type of the column/argument */
   OCI_ATTR_DISP_SIZE  : constant := 3;  -- the display size */
   OCI_ATTR_NAME       : constant := 4;  -- the name of the column/argument */
   OCI_ATTR_PRECISION  : constant := 5;  -- precision if number type */
   OCI_ATTR_SCALE      : constant := 6;  -- scale if number type */
   OCI_ATTR_IS_NULL    : constant := 7;  -- is it null ? */
   OCI_ATTR_TYPE_NAME  : constant := 8;
   -- name of the named data type or a package name for package private types */
   OCI_ATTR_SCHEMA_NAME : constant := 9;  -- the schema name */
   OCI_ATTR_SUB_NAME    : constant := 10; -- type name if package private type */
   OCI_ATTR_POSITION    : constant := 11;


   -------------------------Descriptor Types----------------------------------*/
   -- descriptor values range from 50 - 255 */
   OCI_DTYPE_FIRST : constant := 50;   -- start value of descriptor type */
   OCI_DTYPE_LOB : constant :=50   ;   -- lob  locator */
   OCI_DTYPE_SNAP : constant :=51  ;   -- snapshot descriptor */
   OCI_DTYPE_RSET : constant :=52  ;   -- result set descriptor */
   OCI_DTYPE_PARAM : constant :=53 ; -- a parameter descriptor obtained from ocigparm */
   OCI_DTYPE_ROWID  : constant :=54;   -- rowid descriptor */
   OCI_DTYPE_COMPLEXOBJECTCOMP  : constant :=55;  -- complex object retrieval descriptor */
   OCI_DTYPE_FILE : constant :=56;       -- File Lob locator */
   OCI_DTYPE_AQENQ_OPTIONS : constant :=57      ;       -- enqueue options */
   OCI_DTYPE_AQDEQ_OPTIONS : constant :=58      ;       -- dequeue options */
   OCI_DTYPE_AQMSG_PROPERTIES : constant :=59;  -- message properties */
   OCI_DTYPE_AQAGENT : constant :=60;                   -- aq agent */
   OCI_DTYPE_LOCATOR : constant :=61;               -- LOB locator */
   OCI_DTYPE_DATETIME : constant :=62;              -- datetime structure */
   OCI_DTYPE_INTERVAL : constant :=63 ;             -- interval structure */
   OCI_DTYPE_AQNFY_DESCRIPTOR  : constant :=64; -- AQ notify descriptor */
   OCI_DTYPE_LAST : constant :=64;                 -- last value of a descriptor type */

   SQLT_CHR : constant := 1;--(ORANET TYPE) character string
   SQLT_NUM : constant := 2;--(ORANET TYPE) oracle numeric
   SQLT_INT : constant := 3;--(ORANET TYPE) integer
   SQLT_FLT : constant := 4;--(ORANET TYPE) Floating point number
   SQLT_STR : constant := 5;--zero terminated string
   SQLT_VNU : constant := 6;--NUM with preceding length byte
   SQLT_PDN : constant := 7;--(ORANET TYPE) Packed Decimal Numeric
   SQLT_LNG : constant := 8;--long
   SQLT_VCS : constant := 9;--Variable character string
   SQLT_NON : constant := 10;--Null/empty PCC Descriptor entry
   SQLT_RID : constant := 11;--rowid
   SQLT_DAT : constant := 12;--date in oracle format
   SQLT_VBI : constant := 15;--binary in VCS format
   SQLT_BIN : constant := 23;--binary data(DTYBIN)
   SQLT_LBI : constant := 24;--long binary
   SQLT_UIN : constant := 68;--unsigned integer
   SQLT_SLS : constant := 91;--Display sign leading separate
   SQLT_LVC : constant := 94;--Longer longs (char)
   SQLT_LVB : constant := 95;--Longer long binary 
   SQLT_AFC : constant := 96;--Ansi fixed char
   SQLT_AVC : constant := 97;--Ansi Var char
   SQLT_CUR : constant := 102;--cursor  type
   SQLT_RDD : constant := 104;--rowid descriptor
   SQLT_LAB : constant := 105;--label type
   SQLT_OSL : constant := 106;--oslabel type

   SQLT_NTY : constant := 108;--named object type
   SQLT_REF : constant := 110;--ref type
   SQLT_CLOB : constant := 112;--character lob
   SQLT_BLOB : constant := 113;--binary lob
   SQLT_BFILEE : constant := 114;--binary file lob
   SQLT_CFILEE : constant := 115;--character file lob
   SQLT_RSET : constant := 116;--  result set type
   SQLT_NCO : constant := 122;--   named collection type (varray or nested table)
   SQLT_VST : constant := 155;--   OCIString type
   SQLT_ODT : constant := 156;--   OCIDate 

   SQLT_FILE  : constant :=SQLT_BFILEE; -- binary file lob */
   SQLT_CFILE : constant :=SQLT_CFILEE;
   SQLT_BFILE : constant :=SQLT_BFILEE;

   -------------------------------- TYPE CODE ----------------------------------

   -- Type manager typecodes

   -- These are typecodes designed to be used with the type manager;
   -- they also include longer, more readable versions of existing SQLT names.
   -- Those types that are directly related to existing SQLT types are #define'd
   -- to their SQLT equivalents.

   -- The type manager typecodes are designed to be useable for all OCI calls.
   -- They are in the range from 192 to 320 for typecodes, so as not to conflict
   -- with existing OCI SQLT typecodes (see ocidfn.h).

   OCI_TYPECODE_REF       : constant :=  SQLT_REF; -- SQL/OTS OBJECT REFERENCE
   OCI_TYPECODE_DATE      : constant :=  SQLT_DAT; -- SQL DATE  OTS DATE
   OCI_TYPECODE_SIGNED8   : constant :=  27; -- SQL SIGNED INTEGER(8)  OTS SINT8
   OCI_TYPECODE_SIGNED16  : constant :=  28; -- SQL SIGNED INTEGER(16)  OTS SINT16
   OCI_TYPECODE_SIGNED32  : constant :=  29; -- SQL SIGNED INTEGER(32)  OTS SINT32
   OCI_TYPECODE_REAL      : constant := 21; -- SQL REAL  OTS SQL_REAL
   OCI_TYPECODE_DOUBLE    : constant := 22; -- SQL DOUBLE PRECISION  OTS SQL_DOUBLE
   OCI_TYPECODE_FLOAT     : constant := SQLT_FLT; -- SQL FLOAT(P)  OTS FLOAT(P)
   OCI_TYPECODE_NUMBER    : constant := SQLT_NUM; -- SQL NUMBER(P S)  OTS NUMBER(P S)
   OCI_TYPECODE_DECIMAL   : constant := SQLT_PDN; -- SQL DECIMAL(P S)  OTS DECIMAL(P S)
   OCI_TYPECODE_UNSIGNED8 : constant :=  SQLT_BIN; -- SQL UNSIGNED INTEGER(8)  OTS UINT8
   OCI_TYPECODE_UNSIGNED16 : constant := 25; -- SQL UNSIGNED INTEGER(16)  OTS UINT16
   OCI_TYPECODE_UNSIGNED32 : constant := 26; -- SQL UNSIGNED INTEGER(32)  OTS UINT32
   OCI_TYPECODE_OCTET     : constant :=  245; -- SQL ???  OTS OCTET
   OCI_TYPECODE_SMALLINT  : constant :=  246; -- SQL SMALLINT  OTS SMALLINT
   OCI_TYPECODE_INTEGER   : constant :=  SQLT_INT; -- SQL INTEGER  OTS INTEGER
   OCI_TYPECODE_RAW       : constant := SQLT_LVB; -- SQL RAW(N)  OTS RAW(N)
   OCI_TYPECODE_PTR       : constant := 32; -- SQL POINTER  OTS POINTER
   OCI_TYPECODE_VARCHAR2  : constant := SQLT_VCS; -- SQL VARCHAR2(N)  OTS SQL_VARCHAR2(N)
   OCI_TYPECODE_CHAR      : constant := SQLT_AFC; -- SQL CHAR(N)  OTS SQL_CHAR(N)
   OCI_TYPECODE_VARCHAR   : constant :=  SQLT_CHR; -- SQL VARCHAR(N)  OTS SQL_VARCHAR(N)
   OCI_TYPECODE_MLSLABEL : constant := SQLT_LAB; -- OTS MLSLABEL
   OCI_TYPECODE_VARRAY   : constant :=   247; -- SQL VARRAY  OTS PAGED VARRAY
   OCI_TYPECODE_TABLE     : constant :=  248; -- SQL TABLE  OTS MULTISET
   OCI_TYPECODE_OBJECT     : constant :=  SQLT_NTY; -- SQL/OTS NAMED OBJECT TYPE
   OCI_TYPECODE_OPAQUE      : constant :=  58; --  SQL/OTS Opaque Types
   OCI_TYPECODE_NAMEDCOLLECTION : constant := SQLT_NCO; -- SQL/OTS NAMED COLLECTION TYPE
   OCI_TYPECODE_BLOB   : constant := SQLT_BLOB; -- SQL/OTS BINARY LARGE OBJECT
   OCI_TYPECODE_BFILE : constant := SQLT_BFILE; -- SQL/OTS BINARY FILE OBJECT
   OCI_TYPECODE_CLOB : constant := SQLT_CLOB; -- SQL/OTS CHARACTER LARGE OBJECT
   OCI_TYPECODE_CFILE : constant := SQLT_CFILE; -- SQL/OTS CHARACTER FILE OBJECT

   OCI_TYPECODE_OTMFIRST: constant := 228; -- first Open Type Manager typecode
   OCI_TYPECODE_OTMLAST : constant := 320; -- last OTM typecode
   OCI_TYPECODE_SYSFIRST: constant := 228; -- first OTM system type (internal)
   OCI_TYPECODE_SYSLAST : constant := 235; -- last OTM system type (internal)

   -- the following are PL/SQL-only internal. They should not be used
   --  OCI_TYPECODE_ITABLE    : constant :=  SQLT_TAB; -- PLSQL indexed table
   --  OCI_TYPECODE_RECORD    : constant :=  SQLT_REC; -- PLSQL record
   --  OCI_TYPECODE_BOOLEAN   : constant :=  SQLT_BOL; -- PLSQL boolean

   -- The OCITypeCode type is interchangeable with the existing SQLT type
   -- which is a ub2
   -- typedef ub2 OCITypeCode;

   subtype Ub1 is C.Unsigned_Char;
   subtype Sb1 is C.Signed_Char;
   subtype Ub2 is C.Unsigned_Short;
   subtype Sb2 is C.Short;
   subtype Ub4 is C.Unsigned_Long;
   subtype Sb4 is C.Long;
   subtype Eb1 is C.Char;
   subtype Eb2 is C.Short;
   subtype Eb4 is C.Long;
   subtype uword is C.unsigned;

   subtype Dvoid is System.Address;

   type Access_Ub4 is access Ub4;
   type Access_Ub2 is access Ub2;

   subtype OCIHandle is System.Address;
   Empty_Handle : constant OCIHandle := System.Null_Address;

   -----------------------Handle Definitions----------------------------------*/
   type OCIEnv is new OCIHandle; --
   type OCIError is new OCIHandle; -- OCI error handle
   type OCISvcCtx is new OCIHandle; -- OCI service handle
   type OCIStmt is new OCIHandle; -- OCI statement handle
   type OCIBind is new OCIHandle; -- OCI bind handle
   type OCIDefine is new OCIHandle; -- OCI Define handle
   type OCIDescribe is new OCIHandle; -- OCI Describe handle
   type OCIServer is new OCIHandle; -- OCI Server handle
   type OCISession is new OCIHandle; -- OCI Authentication handle
   type OCIComplexObject is new OCIHandle; -- OCI COR handle
   type OCITrans is new OCIHandle; -- OCI Transaction handle
   type OCISecurity is new OCIHandle; -- OCI Security handle
   type OCISubscription is new OCIHandle; --subscription handle
   -----------------------Descriptor Definitions------------------------------*/
   type OCISnapshot is new OCIHandle; --OCI snapshot descriptor
   type OCIResult is new OCIHandle; --OCI Result Set Descriptor
   type OCILobLocator is new OCIHandle; --OCI Lob Locator descriptor
   type OCIParam is new OCIHandle; --OCI PARameter descriptor
   type OCIComplexObjectComp is new OCIHandle; ---- OCI COR descriptor
   type OCIRowid is new OCIHandle; --OCI ROWID descriptor
   type OCIDateTime is new OCIHandle; --OCI DateTime descriptor
   type OCIInterval is new OCIHandle; --OCI Interval descriptor

   -------------------------- AQ Descriptors ---------------------------------*/
   type OCIAQEnqOptions is new OCIHandle; --AQ Enqueue Options hdl
   type OCIAQDeqOptions is new OCIHandle; --AQ Dequeue Options hdl
   type OCIAQMsgProperties is new OCIHandle; --AQ Mesg Properties
   type OCIAQAgent is new OCIHandle; --AQ Agent descriptor
   type OCIAQNfyDescriptor is new OCIHandle; --AQ Nfy descriptor


   subtype Sword is C.Int;
   -----------------------------  Various Modes --------   
   OCI_DEFAULT  : constant := 0;
   ------------- OCIInitialize Modes / OCICreateEnvironment Modes
   OCI_THREADED : constant := 1; -- the application is in threaded environment
   OCI_OBJECT   : constant := 2; -- the application is in object environment
   OCI_EVENTS   : constant := 4; -- the application is enabled for events
   OCI_SHARED   : constant := 16#10#; -- the application is in shared mode
   ---------------- only for OCICreateEnvironment Modes
   OCI_NO_UCB   : constant := 16#40#; -- 
   OCI_NO_MUTEX : constant := 16#80#; -- the environment handle will not be
   ----------------------------- OCIEnvInit Modes 
   OCI_ENV_NO_UCB   : constant := 1;
   OCI_ENV_NO_MUTEX : constant := 8;

   OCI_HTYPE_FIRST         : constant := 1; -- start value of handle type
   OCI_HTYPE_ENV           : constant := 1;
   OCI_HTYPE_ERROR         : constant := 2;
   OCI_HTYPE_SVCCTX        : constant := 3;-- service handle
   OCI_HTYPE_STMT          : constant := 4;-- statement handle
   OCI_HTYPE_BIND          : constant := 5;-- bind handle
   OCI_HTYPE_DEFINE        : constant := 6;-- define handle
   OCI_HTYPE_DESCRIBE      : constant := 7;-- describe handle
   OCI_HTYPE_SERVER        : constant := 8;-- server handle
   OCI_HTYPE_SESSION       : constant := 9;-- authentication handle
   OCI_HTYPE_TRANS         : constant := 10;-- transaction handle
   OCI_HTYPE_COMPLEXOBJECT : constant := 11;-- complex object retrieval handle
   OCI_HTYPE_SECURITY      : constant := 12;-- security handle
   OCI_HTYPE_SUBSCRIPTION  : constant := 13;-- subscription handle
   OCI_HTYPE_DIRPATH_CTX   : constant := 14;-- direct path context
   OCI_HTYPE_DIRPATH_COLUMN_ARRAY : constant := 15;-- direct path column array
   OCI_HTYPE_DIRPATH_STREAM       : constant := 16;-- direct path stream
   OCI_HTYPE_PROC         : constant := 17;-- process handle
   OCI_HTYPE_LAST         : constant := 17;-- last value of a handle type

   subtype Deword is Eb4;
   subtype Dsize_T is Ub4;
   subtype Dboolean is Sb4;
   subtype Duword is Ub4;
   subtype Dsword is Sb4;
   subtype Dword is Dsword;

   Null_Indicator : constant := -1;

   OCI_STMT_SELECT : constant := 1; -- select statement
   OCI_STMT_UPDATE : constant := 2; -- update statement
   OCI_STMT_DELETE : constant := 3; -- delete statement
   OCI_STMT_INSERT : constant := 4; -- Insert Statement
   OCI_STMT_CREATE : constant := 5; -- create statement
   OCI_STMT_DROP   : constant := 6; -- drop statement
   OCI_STMT_ALTER  : constant := 7; -- alter statement
   OCI_STMT_BEGIN  : constant := 8; -- begin ... (pl/sql statement)
   OCI_STMT_DECLARE: constant := 9; -- declare .. (pl/sql statement ) 

   type OCITime is
   record
      OCITimeHH : Ub1; -- hours; range is 0 <= hours <=23
      OCITimeMI : Ub1; -- minutes; range is 0 <= minutes <= 59
      OCITimeSS : Ub1; -- seconds; range is 0 <= seconds <= 59
   end record;

   type OCIDate is
   record
      OCIDateYYYY : Sb2; -- gregorian year; range is -4712 <= year <= 9999
      OCIDateMM   : Ub1; -- month; range is 1 <= month < 12
      OCIDateDD   : Ub1; -- day; range is 1 <= day <= 31
      OCIDateTime : OCITime; -- time
   end record;

   OCI_NUMBER_SIZE : constant := 22;
   type OCINumber is array (1 .. OCI_NUMBER_SIZE) of Ub1;

   type OCIString is new DVoid;

   function OCIEnvCreate(
      Envh : access OCIEnv;
      Mode : Ub4;
      Ctxp : Undefined := Empty;
      Malocfp : Undefined := Empty;
      Ralocfp : Undefined := Empty;
      Mfreefp : Undefined := Empty;
      Xtramemsz : Undefined := Empty;
      Usrmempp : Undefined := Empty) return Sword;

   pragma Import(C,OCIEnvCreate,"OCIEnvCreate");

   function OCIErrorGet(
      Hndlp : OCIHandle;
      Recordno : Ub4 := 1;
      Sqlstate : Undefined := Empty;
      Errcodep : access Sb4;
      Bufp : Text_Ptr;
      Bufsiz : Ub4;
      Htype : Ub4) return Sword;

   pragma Import(C,OCIErrorGet,"OCIErrorGet");

   function OCILogon (Envhp : OCIEnv;
      Errhp : OCIError;
      Svchp : access OCISvcCtx;
      Username : Text;
      Uname_Len : Ub4;
      Password : Text;
      Passwd_Len : Ub4;
      Dbname : Text;
      Dbname_Len : Ub4) return Sword;

   pragma Import(C,OCILogon,"OCILogon");

   function OCILogoff (Svchp : OCISvcCtx;
      Errhp : OCIError) return Sword;

   pragma Import(C,OCILogoff,"OCILogoff");

   function OCIInitialize(
      Mode : Ub4;
      Ctxp : Undefined := Empty;
      Malocfp : Undefined := Empty;
      Ralocfp : Undefined := Empty;
      Mfreefp : Undefined := Empty) return Sword;

   pragma Import(C,OCIInitialize,"OCIInitialize");

   function OCIEnvInit(
      Envh : access OCIEnv;
      Mode : Ub4;
      Xtramemsz : Undefined := Empty;
      Usrmempp : Undefined := Empty) return Sword;

   pragma Import(C,OCIEnvInit,"OCIEnvInit");

   function OCIHandleAlloc (Parenth : OCIHandle;
      Hndlpp : access OCIHandle;
      Htype :  Ub4;
      Xtramem_Sz : C.Size_T := 0;
      Usrmempp : Undefined := Empty) return Sword;

   pragma Import(C,OCIHandleAlloc,"OCIHandleAlloc");

   function OCIHandleFree(Hndlp : OCIHandle;
      Htype : Ub4) return Sword;

   pragma Import(C,OCIHandleFree,"OCIHandleFree");

   function OCIStmtPrepare (Stmtp : OCIStmt;
      Errhp : OCIError;
      Stmt : Text;
      Stmt_Len : Ub4;
      Language : Ub4 := OCI_NTV_SYNTAX;
      Mode : Ub4 := OCI_DEFAULT) return Sword;

   pragma Import(C,OCIStmtPrepare,"OCIStmtPrepare");

   function OCIStmtExecute (
      Svchp : OCISvcCtx;
      Stmtp : OCIStmt;
      Errhp : OCIError;
      Iters : Ub4;
      Rowoff : Ub4 := 0;
      Snap_In : OCIHandle := Empty_Handle;
      Snap_Out : OCIHandle := Empty_Handle;
      Mode : Ub4 := OCI_DEFAULT) return Sword;

   pragma Import(C,OCIStmtExecute,"OCIStmtExecute");

   function OCIParamGet (
      Hndlp : OCIHandle;
      Htype : Ub4;
      Errhp : OCIError;
      Parmdpp : access OCIParam;
      Pos : Ub4) return Sword;

   pragma Import(C,OCIParamGet,"OCIParamGet");

   function OCIAttrGet (Trgthndlp : OCIHandle;
      Trghndltyp : Ub4;
      Attributep : access Integer;
      Sizep : access Ub4;
      Attrtype : Ub4;
      Errhp : OCIError) return Sword;

   function OCIAttrGet (Trgthndlp : OCIHandle;
      Trghndltyp : Ub4;
      Attributep : access Cstr.Chars_Ptr;
      Sizep : access Ub4;
      Attrtype : Ub4;
      Errhp : OCIError) return Sword;

   pragma Import(C,OCIAttrGet,"OCIAttrGet");

   function OCIStmtFetch(Stmtp : OCIStmt;
      Errhp : OCIError;
      Nrows : Ub4 := 1;
      Orientation : Ub2 := OCI_FETCH_NEXT;
      Mode : Ub4 := OCI_DEFAULT) return Sword;

   pragma Import(C,OCIStmtFetch,"OCIStmtFetch");

   function OCIBindByName (
      Stmtp : OCIStmt;
      Bindpp : access OCIBind;
      Errhp : OCIError;
      Placeholder : Text;
      Placeh_Len : Sb4;
      Valuep : Dvoid;
      Value_Sz : Sb4;
      Dty : Ub2;
      Indp : access Sb2;
      Alenp : Access_Ub2 := null;
      Rcodep : Access_Ub2 := null;
      Maxarr_Len : Ub4 := 0;
      Curelep : Access_Ub4 := null;
      Mode : Ub4 := OCI_DEFAULT) return Sword;

   pragma Import(C,OCIBindByName,"OCIBindByName");
   
   function OCIBindByPos ( 
      Stmtp : OCIStmt;
      Bindpp : access OCIBind;
      Errhp : OCIError;
      position : ub4;
      Valuep : Dvoid;
      Value_Sz : Sb4;
      Dty : Ub2;
      Indp : access Sb2;
      Alenp : Access_Ub2 := null;
      Rcodep : Access_Ub2 := null;
      Maxarr_Len : Ub4 := 0;
      Curelep : Access_Ub4 := null;
      Mode : Ub4 := OCI_DEFAULT) return Sword;

   pragma Import(C,OCIBindByPos,"OCIBindByPos");

   function OCIDefineByPos (
      Stmtp : OCIStmt;
      Defnpp : access OCIDefine;
      Errhp : OCIError;
      Position : Ub4;
      Value : Dvoid;
      Value_Sz : Sb4;
      Dty : Ub2;
      Indp :  access Sb2;
      Rlenp : Access_Ub2 := null;
      Rcodep :  Access_Ub2 := null;
      Mode : Ub4 := OCI_DEFAULT) return Sword;

   pragma Import(C,OCIDefineByPos,"OCIDefineByPos");

   function OCIDateToText (Err : OCIError;
      Date : OCIDate;
      Fmt : Text;
      Fmt_Length : Ub1;
      Lang_Name : Integer;--text;
      Lang_Length : Ub4;
      Buf_Size : access Ub4;
      Buf : Text_Ptr) return Sword;

   pragma Import(C,OCIDateToText,"OCIDateToText");

   function OCINumberToText (Err : OCIError;
      Date : OCINumber;
      Fmt : Text;
      Fmt_Length : Ub1;
      Nls_Name : Integer;--text;
      Nls_Length : Ub4;
      Buf_Size : access Ub4;
      Buf : Text_Ptr) return Sword;

   pragma Import(C,OCINumberToText,"OCINumberToText");

   function OCIDateSysDate (Err : OCIError;
      Date : access OCIDate) return Sword;

   pragma Import(C,OCIDateSysDate,"OCIDateSysDate");

   function OCIStringResize (Env :  OCIEnv;
      Err : OCIError;
      New_Size : Ub4;
      Str : access OCIString) return Sword;

   pragma Import(C,OCIStringResize,"OCIStringResize");

   function OCIStringAssignText (Env :  OCIEnv;
      Err : OCIError;
      Rhs : Text;
      Rhs_Len :  Ub2;
      Lhs : access OCIString) return Sword;

   pragma Import(C,OCIStringAssignText,"OCIStringAssignText");

   function OCIStringPtr (Env : OCIEnv;
      Vs : OCIString) return Cstr.Chars_Ptr;

   pragma Import(C,OCIStringPtr,"OCIStringPtr");

   function OCIStringSize (Env : OCIEnv;
      Vs : OCIString) return Ub4;

   pragma Import(C,OCIStringSize,"OCIStringSize");

   function OCIStringAllocSize(env :  OCIEnv;
                               vs : OCIString;
                               allocsize : access ub4) return sword; 
                               
   pragma Import(C,OCIStringAllocSize,"OCIStringAllocSize");
                               
   function OCIDescriptorAlloc(
      Parenth : OCIEnv;
      Descpp : access DVoid;
      Htype : Ub4;
      Xtramem_Sz : C.Size_T := 0;
      Usrmempp : Undefined := 0) return Sword;

   pragma Import(C, OCIDescriptorAlloc, "OCIDescriptorAlloc");

   function OCIDescriptorFree (descp : OCIHandle;
                          dtype : ub4) return sword;

   pragma Import(C, OCIDescriptorFree, "OCIDescriptorFree");

   function OCIServerVersion (
               hndlp : OCIHandle; 
               errhp : OCIError;
               bufp   : text_Ptr;
               bufsz   : ub4;
               hndltype : ub1) return sword;

   pragma Import(C, OCIServerVersion, "OCIServerVersion");

   function OCITransCommit (
       svchp :  OCISvcCtx;
       errhp : OCIError;
       flags  : ub4 := OCI_DEFAULT) return sword;               
       
   pragma Import(C, OCITransCommit, "OCITransCommit");
   
   function OCITransRollback (
       svchp :  OCISvcCtx;
       errhp : OCIError;
       flags  : ub4 := OCI_DEFAULT) return sword;               
       
   pragma Import(C, OCITransRollback, "OCITransRollback");
   
   function OCINumberAbs(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;

   pragma Import(C, OCINumberAbs, "OCINumberAbs");
   
   function OCINumberArcCos(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;

   pragma Import(C, OCINumberArcCos, "OCINumberArcCos");

   function OCINumberArcSin(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;
   pragma Import(C, OCINumberArcSin, "OCINumberArcSin");

   function OCINumberArcTan(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;
   pragma Import(C, OCINumberArcTan, "OCINumberArcTan");

   function OCINumberAssign(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;
   pragma Import(C, OCINumberAssign, "OCINumberAssign");

   function OCINumberCeil(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;
   pragma Import(C, OCINumberCeil, "OCINumberCeil");

   function OCINumberCos(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;
   pragma Import(C, OCINumberCos, "OCINumberCos");

   function OCINumberExp(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;
   pragma Import(C, OCINumberExp, "OCINumberExp");

   function OCINumberFloor(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;
   pragma Import(C, OCINumberFloor, "OCINumberFloor");

   function OCINumberHypCos(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;
   pragma Import(C, OCINumberHypCos, "OCINumberHypCos");

   function OCINumberHypSin(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;
   pragma Import(C, OCINumberHypSin, "OCINumberHypSin");

   function OCINumberHypTan(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;
   pragma Import(C, OCINumberHypTan, "OCINumberHypTan");

   function OCINumberLn(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;
   pragma Import(C, OCINumberLn, "OCINumberLn");

   function OCINumberNeg(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;
   pragma Import(C, OCINumberNeg, "OCINumberNeg");

   function OCINumberSin(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;
   pragma Import(C, OCINumberSin, "OCINumberSin");

   function OCINumberSqrt(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;
   pragma Import(C, OCINumberSqrt, "OCINumberSqrt");

   function OCINumberTan(
                  err : OCIError; 
                  number : OCINumber; 
                  result : access OCINumber) return sword;
   pragma Import(C, OCINumberTan, "OCINumberTan");

   function OCINumberArcTan2(err : OCIError; 
                      number1 : OCINumber; 
                      number2 : OCINumber; 
                      result : access OCINumber) return sword;
   pragma Import(C, OCINumberArcTan2, "OCINumberArcTan2");
   
   function OCINumberAdd(err : OCIError; 
                      number1 : OCINumber; 
                      number2 : OCINumber; 
                      result : access OCINumber) return sword;
   pragma Import(C, OCINumberAdd, "OCINumberAdd");
   
   function OCINumberDiv(err : OCIError; 
                      number1 : OCINumber; 
                      number2 : OCINumber; 
                      result : access OCINumber) return sword;
   pragma Import(C, OCINumberDiv, "OCINumberDiv");
   
   function OCINumberLog(err : OCIError; 
                      number1 : OCINumber; 
                      number2 : OCINumber; 
                      result : access OCINumber) return sword;
   pragma Import(C, OCINumberLog, "OCINumberLog");
   
   function OCINumberMod(err : OCIError; 
                      number1 : OCINumber; 
                      number2 : OCINumber; 
                      result : access OCINumber) return sword;

   pragma Import(C, OCINumberMod, "OCINumberMod");
   
   function OCINumberMul(err : OCIError; 
                      number1 : OCINumber; 
                      number2 : OCINumber; 
                      result : access OCINumber) return sword;
   pragma Import(C, OCINumberMul, "OCINumberMul");
   
   function OCINumberPower(err : OCIError; 
                      number1 : OCINumber; 
                      number2 : OCINumber; 
                      result : access OCINumber) return sword;
   pragma Import(C, OCINumberPower, "OCINumberPower");
   
   function OCINumberSub(err : OCIError; 
                      number1 : OCINumber; 
                      number2 : OCINumber; 
                      result : access OCINumber) return sword;
   pragma Import(C, OCINumberSub, "OCINumberSub");
   
   function OCINumberToReal(err : OCIError; 
                      number : OCINumber;
                      rsl_length : uword;
                      rsl : access Long_Float) return sword;   
   pragma Import(C, OCINumberToReal, "OCINumberToReal");
                      
   function OCINumberFromReal (err : OCIError; 
                      rnum : access Long_Float;
                      rnum_length : uword;
                      number : access OCINumber) return sword;   
   pragma Import(C, OCINumberFromReal, "OCINumberFromReal");
                    
end OCI.Lib