⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ori.h

📁 将对Oracle数据库读写操作的OCI进行封装。不但具有普通数据的读取操作
💻 H
📖 第 1 页 / 共 5 页
字号:
  PRIVATE FUNCTIONS
    None

  EXAMPLES 

    The following types will be used in the examples in this section: 

    OBJECT TYPE professor
    (
        varchar2  name;
        number    department;
        number    num_of_students; 
    );

    OBJECT TYPE course 
    (
        varchar2   name;
        number     grade; 
    );

    OBJECT TYPE student
    (
        vstring      name;
        number       department;
        ref          advisor;                      /o advisor is a professor o/
        collection   courses;
    );

    EXAMPLE 1

      Here is a set of examples to illustrate the usages of some of the
      orio and oric functions.  

      OCIenv    *env;              /o OCI environment handle o/
      OCIError  *err;              /o OCI error handle o/
      OCISvcCtx *svc;              /o OCI service handle o/

      dvoid   *stu_tbl;            /o pointer to the student table o/
      OCIType *stu_tdo;            /o student type tdo o/

      OCIRef    *stu2_ref;         /o object reference to student object o/
      student   *stu1;             /o pointer to the student object o/
      student   *stu2;             /o pointer to the student object o/
      professor *pro;              /o pointer to the professor object o/

      /o Initialize the OCI environment handle, error handle and service
	 handle and login to the database o/ 
      ...

      /o CREATE A PERSISTENT OBJECT o/

      /o get the table object of student o/
      if (OCIObjectPinTable(env, err, svc, "ORACLEU", sizeof("ORACLEU"), 
          "STUDENT_TABLE", sizeof("STUDENT_TABLE"), (OCIRef *)0, 
          OCI_DURATION_NULL, &stu_tbl) != OCI_SUCCESS)
          /o error handling code o/ 

      /o get type object of student o/
      if (OCITypeByName(env, err, svc, "ORACLEU", sizeof("ORACLEU"), 
          "STUDENT", sizeof("STUDENT"), OCI_DURATION_NULL, OCI_TYPEGET_HEADER,
          &stu_tdo) != OCI_SUCCESS)
          /o error handling code o/ 

      /o create a persistent object 'mark' (of type student) o/ 
      if (OCIObjectNew(env, err, svc, OCI_TYPECODE_ADT, stu_tdo, stu_tbl, 
            OCI_DURATION_TRANS, (ub1)FALSE, (dvoid **)&stu1) != OCI_SUCCESS)
          /o error handling code o/

      /o RETRIEVE OBJECTS IN PERSISTENT STORES o/ 

      /o Use OCI to retrieve a reference to student object 'joe'.
       o The retrieved reference is bound to the variable stu2_ref.
       o/ 

      /o pin/retrieve the student "joe" by reference o/ 
      if (OCIObjectPin(env, err, &stu2_ref, (OCIComplexObject *)0, OCI_PIN_ANY,
                  OCI_DURATION_TRANS, OCI_LOCK_X, &stu2) != OCI_SUCCESS)
          /o error handling code o/ 

      /o pin/retrieve the advisor of student "joe" by reference o/ 
      if (OCIObjectPin(env, err, &stu2->advisor, (OCIComplexObject *)0,
          OCI_PIN_ANY, OCI_DURATION_TRANS, OCI_LOCK_X, &pro) != OCI_SUCCESS)
          /o error handling code o/ 

      /o MODIFY OBJECTS o/

      /o initialize the newly created object "mark" o/
      DISCARD OCIStringAssignText(env, err, "mark", sizeof("mark"), 
                                    &stu1->name);
      department = 522;
      DISCARD OCINumberFromInt(err, &department, sizeof(department), 
                                    OCI_NUMBER_UNSIGNED, &stu1->department);

      /o assign advisor to student "mark" o/
      DISCARD OCIRefAssign(env, err, &stu2->advisor, &stu1->advisor);

      /o update student "joe". o/  
      department = 533;
      DISCARD OCINumberFromInt(err, &department, sizeof(department), 
                                    OCI_NUMBER_UNSIGNED, &stu2->department);
      DISCARD OCIObjectMarkUpdate(env, err, stu2);

      /o UNPIN OBJECTS AFTER FINSIHED PROCESSING THEM o/ 

      /o unpin the student object "mark" o/
      if (OCIObjectUnpin(env, err, stu1) != OCI_SUCCESS)
          /o error handling code o/ 

      /o unpin the student object "joe" o/
      if (OCIObjectUnpin(env, err, stu2) != OCI_SUCCESS)
          /o error handling code o/ 

      /o unpin the professor object o/
      if (OCIObjectUnpin(env, err, pro) != OCI_SUCCESS)
          /o error handling code o/ 

      /o unpin the type object o/
      if (OCIObjectUnpin(env, err, stu_tdo) != OCI_SUCCESS)
          /o error handling code o/ 

      /o unpin the table object o/
      if (OCIObjectUnpin(env, err, stu_tbl) != OCI_SUCCESS)
          /o error handling code o/ 

      /o FLUSH MODIFIED OBJECTS BACK TO PERSISTENT STORE o/

      if (OCICacheFlush(env, err, svc, (dvoid *)0, ((OCIRef*)(*)())0, 
                       (OCIRef *)0) != OCI_SUCCESS)
          /o error handling code o/

      /o commit transaction o/

    END OF EXAMPLE 1

  NOTES
    This file has been subsetted to contain only the routines that will
    be in the first release.

  MODIFIED
    bpalaval   02/09/01 - Change text to oratext.
    rkasamse   06/21/00 - add ociobjectgetnewoid
    rkasamse   05/24/00 - add OCIObjectSetData
    whe        09/01/99 - 976457:check __cplusplus for C++ code
    smuralid   10/29/98 - add comments for OCIObjectMakeObjectRef              
    mkrishna   08/19/98 - change OCIGetPkTypeRef to OCIObjectGetPrimaryKeyTypeR
    mkrishna   08/10/98 - add OCIObjectMakeObjectRef & OCIObjectGetPkTypeRef
    rkasamse   06/22/98 - add comments for OCIDurationBegin(End)
    pmitra     04/01/98 - OCIObjectLockNoWait added                            
    pmitra     11/05/97 - [573769] OCIObjectArrayPin pos parameter cannot be NU
    cxcheng    07/29/97 - fix compile for short names
    skrishna   07/14/97 - add OCIObjectGetProperty
    skrishna   04/30/97 - OCIObjectFlushRefresh: remove duplicate declaration
    skrishna   04/24/97 - flag unsupported functions
    sthakur    03/20/97 - modify flag argument to OCIObjectFree
    skrishna   03/18/97 - fix ifdef for supporting ansi and k&r proto-types
    cxcheng    02/19/97 - remove short names support
    cxcheng    02/06/97 - take out short name support except with SLSHORTNAME
    sthakur    12/20/96 - fix a typepo in OCIOBjectArrayPin
    jboonleu   11/07/96 - modify comments
    cxcheng    10/28/96 - more beautification changes
    jboonleu   10/24/96 - add flag to OCIObjectFree
    jboonleu   10/22/96 - change interface of OCICacheFlush
    cxcheng    10/18/96 - rename OCIObjectPinArray to OCIObjectArrayPin
    cxcheng    10/14/96 - more renaming of types
    jboonleu   10/09/96 - add new interfaces
    cxcheng    10/09/96 - more lint fixes
    cxcheng    10/08/96 - more lint fixes
    jboonleu   09/27/96 - fix lint errors
    jboonleu   10/07/96 - beautify ori.h after conversion to long names
    cxcheng    10/04/96 - replace short names with long names
    sthakur    08/20/96 - add COR context to OCIObjectPin
    mluong     07/17/96 - add back orioglk, oriogdr, oriogiv, and oriocur.
    jboonleu   07/17/96 - rename refresh option to conherency option 
    jboonleu   07/16/96 - change comment for cache consistency
    jwijaya    07/03/96 - add ANSI prototypes
    jboonleu   06/12/96 - update comment
    jboonleu   05/08/96 -  change description of OCIDurationGetParent
    jboonleu   05/01/96 -  add OROOCOSFN
    skrishna   04/08/96 -  change ori*() to take OCIEnv* and OCIError* instead
			   of oroenv*
    jboonleu   01/04/96 -  interface change
    jboonleu   10/24/95 -  support of variable ref
    jboonleu   02/15/95 -  new interface
    sthakur    01/05/95 -  pass username to origrgc 
    skotsovo   12/07/94 -  update example 
    jwijaya    11/15/94 -  rename ORONSPTAB to ORONSPEXT 
    jwijaya    10/06/94 -  add namespace to oriopnm() 
    jwijaya    10/02/94 -  connection handle -> connection number 
    jboonleu   08/16/94 -  fix lint errors 
    jboonleu   07/20/94 -  change interface of OCICacheFlush 
    tanguyen   07/18/94 -  add oriocpe, change OCIObjectCopy to oriocps
    tcheng     07/15/94 -  add init param maximum_sga_heap_size 
    tcheng     07/13/94 -  change origini to get param string 
    jboonleu   07/05/94 -  change sccs string from sccid to a comment 
    jboonleu   07/01/94 -  Add examples to ORIO* and ORIC* functions 
    tanguyen   06/30/94 -  Fix the ORI_ORACLE ifdef
    skotsovo   06/27/94 -  include all public functions in public functions 
                           list at top of header file
    tcheng     06/27/94 -  modify comments according to new template 
    tanguyen   06/24/94 -  fix comments for OCIObjectCopy 
    tcheng     06/24/94 -  fix comments in origrgc()
    tanguyen   06/21/94 -  fix comments and format 
    tcheng     06/20/94 -  commenting origini/trm/err/rgc/urg() functions
    tanguyen   06/16/94 -  fix descriptions of ref operations 
    tanguyen   06/16/94 -  clarifies refs comparison 
    tanguyen   05/12/94 -  adds more interfaces (OCIObjectMarkUpdate)
    jwijaya    05/10/94 -  fix examples, add origurg, change origcon to origrgc
    tanguyen   05/03/94 -  remove unnecessary 'type' argument from 
                           'OCIObjectCopy'
    tanguyen   03/08/94 -  clarifies comments
    jwijaya    02/16/94 -  more questions
    jwijaya    02/11/94 -  more comments
    jwijaya    02/10/94 -  identify optional arguments
    jwijaya    02/07/94 -  Creation
*/


#ifndef ORATYPES
#include <oratypes.h>
#endif
#ifndef ORO_ORACLE
#include <oro.h>
#endif
#ifndef OCI_ORACLE
#include <oci.h>
#endif
#ifndef ORT_ORACLE
#include <ort.h>
#endif

#ifndef ORI_ORACLE
#define ORI_ORACLE

/*---------------------------------------------------------------------------*/
/*                         SHORT NAMES SUPPORT SECTION                       */
/*---------------------------------------------------------------------------*/

#ifdef SLSHORTNAME

/* the following are short names that are only supported on IBM mainframes
   with the SLSHORTNAME defined.
   With this all subsequent long names will actually be substituted with
   the short names here */

#define OCIDurationBegin                 origbgu
#define OCIDurationEnd                   origedu
#define OCIDurationGetParent             origpdr
#define OCICacheFlushRefresh             oricfrh
#define OCICacheUnpin                    oricunp
#define OCICacheFree                     oricfre
#define OCICacheUnmark                   oricumk
#define OCICacheGetObjects               oricgpr
#define OCICacheRegister                 oricscb
#define OCIObjectUnpin                   oriounp
#define OCIObjectPinCountReset           orioupz
#define OCIObjectLock                    oriolck
#define OCIObjectLockNoWait              oriolnw
#define OCIObjectMarkUpdate              orioupd
#define OCIObjectUnmark                  orioumk
#define OCIObjectUnmarkByRef             orioumr
#define OCIObjectAlwaysLatest            oriomkl
#define OCIObjectNotAlwaysLatest         oriouml
#define OCIObjectMarkDeleteByRef         oriordl
#define OCIObjectMarkDelete              oriopdl
#define OCIObjectFlush                   oriofls
#define OCIObjectFlushRefresh            oriofrh
#define OCIObjectCopy                    oriocpy
#define OCIObjectGetTypeRef              oriogtr
#define OCIObjectGetObjectRef            oriogor
#define OCIObjectGetInd                  oriogns
#define OCIObjectExists                  oriogex
#define OCIObjectGetProperty             oriogpr

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -