Board index » delphi » OCI (Oracle Call Interface)

OCI (Oracle Call Interface)

Hi All,

Does anybody has or can tell be where to find a Delphi 3 (Pascal or Object
Pascal) unit which imports OCI (Oracle Call Interface)?

grtnx,
Richard

-----
Real programmers don't comment their code.
It was hard to write, it should be hard to understand.
-----
Richard Willemsen
http://www.xs4all.nl/~rwillems/

 

Re:OCI (Oracle Call Interface)


That's very brave, but their are available a group of components that would
probably be easier to use.  They're called DOA (Direct Oracle Access)
meaning there is no BDE at all.

The demo's available at
http://www.radiantdata.com/products.htm

Quote
Richard Willemsen wrote in message <358a4a66.12738...@192.168.0.1>...
>Hi All,

>Does anybody has or can tell be where to find a Delphi 3 (Pascal or Object
>Pascal) unit which imports OCI (Oracle Call Interface)?

>grtnx,
>Richard

>-----
>Real programmers don't comment their code.
>It was hard to write, it should be hard to understand.
>-----
>Richard Willemsen
>http://www.xs4all.nl/~rwillems/

Re:OCI (Oracle Call Interface)


I use this unit to interface to the OCI.  It is my translation of ociapr.h,
oratypes.h, and some stuff from the OCI manual.  It should probably carry an
Oracle copyright.

x-------- cut here ---------x
unit OCI;

interface

const
  CDA_SIZE         = 64;

(* OCI Logon Modes for olog call *)
  OCI_LM_DEF       = 0;           (* default login *)
  OCI_LM_NBL       = 1;           (* non-blocking logon *)

(* OCI Environment Modes for opinit call *)
  OCI_EV_DEF       = 0;           (* default single-threaded environment *)
  OCI_EV_TSF       = 1;           (* thread-safe environment *)

(* OCI_*_PIECE defines the piece types that are returned or set *)
  OCI_ONE_PIECE    = 0;           (* there or this is the only piece *)
  OCI_FIRST_PIECE  = 1;           (* the first of many pieces *)
  OCI_NEXT_PIECE   = 2;           (* the next of many pieces *)
  OCI_LAST_PIECE   = 3;           (* the last piece of this column *)

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

  OCI_def          = 1;           (* deferred mode *)
  OCI_imm          = 0;           (* non deferred mode *)

Type
  sb1              = shortint;    {8 bit signed}
  sb2              = smallint;    {16 bit signed}
  sb4              = longint;     {32 bit signed}
  sword            = longint;     {32 bit signed - maxvalue +/- 32768}

  ub4              = cardinal;    {32 bit unsigned - 32 bit compiler
only!!!}
  ub2              = word;        {16 bit unsigned}
  ub1              = byte;        {8 bit unsigned}
  size_t           = longint;

  rd = record
    rcs4      : ub4;
    rcs5      : ub2;
    rcs6      : ub1;
  end;

  rid = record {rowid}
    rcsx      : rd;
    rcs7      : ub4;
    rcs8      : ub2
  end;

  cda_head = record        (* Used for size calcualtion only!!!! *)
    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;
    ose       : sword;     (* OSD dependent error *)
    chk       : ub1;
    rcsp      : pointer;     (* pointer to reserved area *)
  end;

  cda_def = record
    v2_rc     : sb2;       (* 0  V2 return code *)
    ft        : ub2;       (* 2  SQL function type *)
    rpc       : ub4;       (* 4  rows processed count *)
    peo       : ub2;       (* 8  parse error offset *)
    fc        : ub1;       (* 10 OCI function code *)
    rcs1      : ub1;       (* 11 filler area *)
    rc        : ub2;       (* 12 V7 return code *)
    wrn       : ub1;       (* 14 warning flags *)
    rcs2      : ub1;       (* 15 reserved *)
    rcs3      : sword;     (* 16 reserved *)
    rowid     : rid;       (* 20 *)
    ose       : sword;     (* 33 OSD dependent error *)
    chk       : ub1;       (* 37 *)
    rcsp      : pointer;   (* 38 pointer to reserved area *)
    rcs9      : array[1..cda_size-sizeof(cda_head)] of byte;  (* filler *)
  end;

  hda_def = array[0..255] of byte;

function olog(var lda:cda_def; var hda:hda_def;           (* logon on to
database *)
              uid : pchar; uidl : sword;
              pswd : pchar; pswdl : sword;
              conn : pchar; connl: sword;
              mode : ub4):sword; cdecl;
function ologof(var lda : cda_def):sword;cdecl;         (* log off database
*)
function oopen(var cursor:cda_def;var lda:cda_def;        (* open cursor *)
                 dbn:pchar;dbnl:sword;arsize:sword;
                 uid:pchar;uidl:sword):sword;cdecl;
function oclose(var cursor:cda_def):sword;cdecl;        (* close cursor *)
function ocof (var lda:cda_def):sword; cdecl;           (* auto-commit off
*)
function ocom (var lda:cda_def):sword; cdecl;           (* auto-commit on *)
function ocon (var lda:cda_def):sword; cdecl;
function obreak(var lda:cda_def):sword; cdecl;
function ocan(var cursor:cda_def):sword; cdecl;

function oexec (var cursor:cda_def):sword; cdecl;
function oexfet (var cursor:cda_def;nrows:ub4;
                 cancel, exact:sword):sword; cdecl;
function oexn (var cursor:cda_def;iters, rowoff:sword):sword; cdecl;
function ofen (var cursor:cda_def; nrows:sword):sword; cdecl;
function ofetch (var cursor:cda_def):sword; cdecl;
function odefin(var cursor:cda_def;pos:sword;var buf;bufl:sword;
                ftype:sword;scale:sword;var indp:sb2;fmt:pointer;fmtl:sword;
                fmtt:sword;var rlen:ub2;var rcode:ub2):sword; cdecl;
(* Oci BIND (Piecewise or with Skips) *)
function obindps(var cursor:cda_def; opcode:ub1; sqlvar:pchar;
        sqlvl:sb4; var pvctx:ub1; progvl:sb4;
        ftype, scale: sword;
        var indp:sb2; var alen, arcode:ub2;
        pv_skip, ind_skip, alen_skip, rc_skip:sb4;
        maxsiz:ub4; var cursiz:ub4;
        fmt:pchar; fmtl:sb4; fmtt:sword):sword; cdecl;

(* Oci DEFINe (Piecewise or with Skips) *)
function odefinps(var cursor:cda_def; opcode:ub1;pos:sword;var bufctx;
  bufl:sb4;ftype, scale:sword;
  var indp:sb2; fmt:pchar; fmtl:sb4; fmtt:sword;
  var rlen, rcode:ub2;
  pv_skip, ind_skip, alen_skip, rc_skip:sb4):sword;cdecl;

function opinit(mode:ub4):sword;cdecl;
function orol(var lda:cda_def):sword;cdecl;
function oopt(var cursor:cda_def; rbopt, waitopt:sword):sword;cdecl;
function osetpi(var cursor:cda_def; piece:ub1; bufp:pointer; var
lenp:ub4):sword;cdecl;
procedure sqlld2(var lda:cda_def; cname:pchar;var cnlen:sb4);cdecl;
procedure sqllda(var lda:cda_def);cdecl;
function oflng(var cursor:cda_def; pos:sword; var buf:ub1;
               bufl:sb4; dtype:sword; var retl:ub4; offset:sb4):sword;cdecl;
function ogetpi(var cursor:cda_def; var piecep:ub1;var ctxpp:pointer;
                var iterp, indexp:ub4):sword;cdecl;
function oparse(var cursor:cda_def; sqlstm:pchar; sqllen:sb4;
                defflg:sword; lngflg:ub4):sword;cdecl
function odessp(var cursor:cda_def; objnam:pchar; onlen:size_t;
              var rsv1:ub1; rsv1ln:size_t; var rsv2:ub1; rsv2ln:size_t;
              var ovrld, pos, level:ub2; var argnam:pchar;
              var arnlen, dtype:ub2; var defsup, mode:ub1;
              var dtsiz:ub4; var prec, scale:ub2; var radix:ub1;
              var spare, arrsiz:ub4):sword;cdecl;
function odescr(var cursor:cda_def; pos:sword; var dbsize:sb4;
{                 var dbtype:sb2; var cbuf:sb1; var cbufl, dsize:sb4;}
                 var dbtype:sb2; cbuf:pchar; var cbufl, dsize:sb4;
                 var prec, scale, nullok:sb2):sword;cdecl;

function oerhms(var lda:cda_def;rcode:sb2;                (* error message
*)
                buf:pchar;bufsiz:sword):sword; cdecl;

(* non-blocking functions *)
function onbset (var lda:cda_def):sword; cdecl;
function onbtst (var lda:cda_def):sword; cdecl;
function onbclr (var lda:cda_def):sword; cdecl;

function ognfd (var lda:cda_def;fdp:pointer):sword; cdecl;

implementation

function olog; cdecl; external 'ociw32.dll';
function ologof; cdecl; external 'ociw32.dll';
function oopen; cdecl; external 'ociw32.dll';
function oclose; cdecl; external 'ociw32.dll';

function oparse;cdecl external 'ociw32.dll';
function odescr;cdecl; external 'ociw32.dll';
function obindps; cdecl; external 'ociw32.dll';
function odefinps; cdecl; external 'ociw32.dll';

function ocof; cdecl; external 'ociw32.dll';
function ocom; cdecl; external 'ociw32.dll';
function ocon; cdecl; external 'ociw32.dll';
function obreak; cdecl; external 'ociw32.dll';
function ocan; cdecl; external 'ociw32.dll';

function oexec; cdecl; external 'ociw32.dll';
function oexfet; cdecl; external 'ociw32.dll';
function oexn; cdecl; external 'ociw32.dll';
function ofen; cdecl; external 'ociw32.dll';
function ofetch; cdecl; external 'ociw32.dll';
function odefin; cdecl; external 'ociw32.dll';

function opinit;cdecl; external 'ociw32.dll';
function orol;cdecl; external 'ociw32.dll';
function oopt;cdecl; external 'ociw32.dll';
function osetpi;cdecl; external 'ociw32.dll';
procedure sqlld2;cdecl; external 'ociw32.dll';
procedure sqllda;cdecl; external 'ociw32.dll';
function oflng;cdecl; external 'ociw32.dll';
function ogetpi;cdecl; external 'ociw32.dll';

function odessp;cdecl; external 'ociw32.dll';
function oerhms; cdecl; external 'ociw32.dll';

function onbset; cdecl; external 'ociw32.dll';
function onbtst; cdecl; external 'ociw32.dll';
function onbclr; cdecl; external 'ociw32.dll';
function ognfd ;
...

read more »

Re:OCI (Oracle Call Interface)


Quote
On Sun, 21 Jun 1998 16:14:10 -0400, <andy.coo...@ibm.net> wrote:
>I use this unit to interface to the OCI.  It is my translation of ociapr.h,
>oratypes.h, and some stuff from the OCI manual.  It should probably carry an
>Oracle copyright.

>x-------- cut here ---------x
> ............................
> ............................
>x---- end cut ----x

Thank you very much Andy.

grtnx,
Richard

-----
Real programmers don't comment their code.
It was hard to write, it should be hard to understand.
-----
Richard Willemsen
http://www.xs4all.nl/~rwillems/

Re:OCI (Oracle Call Interface)


20-Jun-98 19:19 T Story wrote:
:> That's very brave, but their are available a group of components that would
:> probably be easier to use.  They're called DOA (Direct Oracle Access)
:> meaning there is no BDE at all.
:>
:> The demo's available at
:> http://www.radiantdata.com/products.htm
:>

Quote
:> Richard Willemsen wrote in message <358a4a66.12738...@192.168.0.1>...

:> >Hi All,
:> >
:> >Does anybody has or can tell be where to find a Delphi 3 (Pascal or Object
:> >Pascal) unit which imports OCI (Oracle Call Interface)?
:> >
:> >grtnx,
:> >Richard
:> >
:> >
:> >-----
:> >Real programmers don't comment their code.
:> >It was hard to write, it should be hard to understand.
:> >-----
:> >Richard Willemsen
:> >http://www.xs4all.nl/~rwillems/
:>
28-Mar-98 07:55 Michael Thuma wrote:
:> There is an enterprisein the Netherlands. They have components
:> that work properly without BDE based on the OCI Interface.
:>
:> You find them on the net under
:>
:> http://www.allroundautomations.nl/
:>
:>
:> The BDE is absolutely useless for programmers who have to write applications querying SQL-Servers. You should not use databound components like DB-Edit. Use normal (what ar abnormal) Windows Components. It's the better way in my opinion.
:>
:> Michael Thuma

Other Threads