コード例 #1
0
ファイル: oci_wrapper.cpp プロジェクト: AsherBond/MondocosmOS
void OWStatement::Define( OCIArray** pphData )
{
    OCIDefine* hDefine = NULL;

    nNextCol++;

    CheckError( OCIDefineByPos( hStmt,
        &hDefine,
        hError,
        (ub4) nNextCol,
        (dvoid*) NULL,
        (sb4) 0,
        (ub2) SQLT_NTY,
        (void*) NULL,
        (ub2*) NULL,
        (ub2*) NULL,
        (ub4) OCI_DEFAULT ), hError );

    CheckError( OCIDefineObject( hDefine,
        hError,
        poConnection->hNumArrayTDO,
        (dvoid**) pphData,
        (ub4*) NULL,
        (dvoid**) NULL,
        (ub4*) NULL ), hError );
}
コード例 #2
0
ファイル: ObjectVar.c プロジェクト: antrophy/goracle
//-----------------------------------------------------------------------------
// ObjectVar_PostDefine()
//   Performs additional steps required for defining objects.
//-----------------------------------------------------------------------------
static int ObjectVar_PostDefine(
    udt_ObjectVar *self)                // variable to set up
{
    sword status;

    status = OCIDefineObject(self->defineHandle,
            self->environment->errorHandle, self->objectType->tdo, self->data,
            0, self->objectIndicator, 0);
    return Environment_CheckForError(self->environment, status,
            "ObjectVar_PostDefine(): define object");
}
コード例 #3
0
/* Function to get an array of REFs to populate the varray of REFs*/
static void getRef()
{
  OCIDefine *defhp = (OCIDefine *) 0; /* For the REF column */
  i_residence *sub_obj[NUMREC];
  ub4 subsize[NUMREC];
  ub4 pos = 0;
  ub4 arraySize = NUMREC;

  OCIHandleAlloc(envhp, (dvoid **) &stmthp, OCI_HTYPE_STMT, (size_t) 0,
    ((dvoid **) 0));

  if((status = OCIStmtPrepare(stmthp, errhp, (text *) selRef,
    (ub4) strlen((char *) selRef), OCI_NTV_SYNTAX, OCI_DEFAULT)) != OCI_SUCCESS)
  {
    printf("OciStmtPrepare - Failure\n");
  }

  if((status = OCIObjectNew(envhp, errhp, svchp, OCI_TYPECODE_REF,
    (OCIType *) 0, (dvoid *) 0, OCI_DURATION_DEFAULT, FALSE,
    (dvoid **) workadd)) != OCI_SUCCESS)
  {
    printf("OCIObjectNew - Failure\n");
  }

  if((status = OCIDefineByPos(stmthp, &defhp, errhp, (ub4) 1, (dvoid *) 0,
    (sb4) 0, SQLT_REF, (dvoid *) 0, (ub2 *) 0, (ub2 *) 0, (ub4) OCI_DEFAULT ))
    != OCI_SUCCESS)
  {
    printf("OCIDefineByPos - Failure\n");
  }

  if((status = OCIDefineObject(defhp, errhp, (OCIType *) 0, (dvoid **) workadd,
    subsize, (dvoid **) 0, (ub4 *) 0)) != OCI_SUCCESS)
  {
    printf("OCIDefineObject - failure\n");
  }

  if((status = OCIStmtExecute(svchp, stmthp, errhp, (ub4) NUMREC, (ub4) 0,
    (OCISnapshot *) 0, (OCISnapshot *) 0, OCI_DEFAULT)) != OCI_SUCCESS)
  {
    printf("OCIStmtExecute - Failure\n");
  }
  else
  {
    if((status = OCIObjectArrayPin(envhp, errhp, workadd, (ub4) arraySize,
      (OCIComplexObject **) 0, 0, OCI_PIN_ANY, OCI_DURATION_SESSION,
      OCI_LOCK_NONE, (dvoid **) sub_obj, (ub4 *) &pos)) != OCI_SUCCESS)
    {
      printf("OCIObjectArrayPin - Failure\n");
    }
  }
  OCIHandleFree((dvoid *) stmthp, OCI_HTYPE_STMT);
} /* End of getRef() */
コード例 #4
0
ファイル: trotl_xml.cpp プロジェクト: Daniel1892/tora
void BindParXML::define_hook()
{
//	xmlsize = 0;

//	std::cout << "OCIDefineObject" << std::endl;

	sword res = OCICALL(OCIDefineObject(defnpp, _stmt._errh,
	                                    xmltdo,
	                                    // TODO If the application wants the buffer to be implicitly allocated in the cache,
	                                    // *pgvpp should be passed in as null.
	                                    (dvoid **) &(_xmlvaluep[0]),
	                                    0,
	                                    0, //(dvoid **) &xml_ind,
	                                    0));
	oci_check_error(__TROTL_HERE__, _stmt._errh, res);

//	res = OCICALL(OCIDefineArrayOfStruct(defnpp, stmt._errh, sizeof(OCIXMLType*), 0, 0, 0));
//	oci_check_error(__TROTL_HERE__, stmt._errh, res);
}
コード例 #5
0
/* Function to display data from the table */
static void selectFunction ()
{ 
  OCIDefine *defhp = (OCIDefine *)0;
  OCIRef *sub_ref = (OCIRef *)0;
  i_manager *sub_obj = (i_manager *)0;
  ub4 subSize = 0;
  ub4 sizeUB4 = sizeof (ub4);
  OCIType *mtype = (OCIType *)0;

  OCIHandleAlloc (envhp, (dvoid **)&stmthp, OCI_HTYPE_STMT, (size_t)0,
    (dvoid **)0);

  if ((status = OCIStmtPrepare (stmthp, errhp, (text *)selectSql, 
    (ub4)strlen((char *)selectSql),OCI_NTV_SYNTAX, OCI_DEFAULT)) != OCI_SUCCESS)
  {
    printf ("OCIStmtPrepare - Fail\n");
  }

  if (( status = OCIObjectNew(envhp, errhp, svchp, OCI_TYPECODE_REF,
    (OCIType *)0, (dvoid *)0, OCI_DURATION_DEFAULT, FALSE, 
    (dvoid **) &sub_ref)) != OCI_SUCCESS)
  {
    printf ("OCIObjectNew - Failure\n");
  }

  if ((status = OCIDefineByPos(stmthp, &defhp, errhp, (ub4) 1,
    (dvoid *) 0, (sb4) 0, SQLT_REF, (dvoid *) 0,
    (ub2 *)0, (ub2 *)0, (ub4) OCI_DEFAULT)) != OCI_SUCCESS)
  {
    printf ("OCIDefineByPos - Failure \n");
  }

  if ((status = OCIDefineObject(defhp, errhp, (OCIType *) 0,
    (dvoid **)&sub_ref, (ub4 *)&subSize, (dvoid **) 0, (ub4 *) 0))
    != OCI_SUCCESS)
  {
    printf ("OCIDefineObject - Failure \n");
  }
  
  printf ("\nExecuting the statement:%s\n", selectSql);
  if (OCIStmtExecute (svchp, stmthp, errhp, (ub4)1, (ub4)0,
    (OCISnapshot *)0, (OCISnapshot *)0, OCI_DEFAULT ) != OCI_SUCCESS)
  {
    printf("OCIStmtExecute - Failure \n");
  }
  else
  {
    printf("OCIStmtExecute - Success\n");
    if ((status = OCIObjectPin(envhp, errhp, sub_ref, (OCIComplexObject *)0,
      OCI_PIN_ANY, OCI_DURATION_SESSION, OCI_LOCK_NONE,
      (dvoid **) &sub_obj)) != OCI_SUCCESS)
    {
      printf("OCIObjectPin - Failure \n");
    }
    else
    {
      printf ("\nDisplaying the contents of the object\n");
      display (sub_obj);
    }
  }
} /* end of selectFunction() */
コード例 #6
0
/* Function to modify the data of an inherited object */
static void modifyFunction ()
{ 
  OCIDefine *defhp = (OCIDefine *)0; 
  OCIRef *sub_ref = (OCIRef *)0;
  i_residence elem;
  i_residence *elemptr = (i_residence *)0;
  i_manager *sub_obj = (i_manager *)0;
  ub4 subSize = 0;
  ub4 sizeUB4 = sizeof (ub4);
  OCIType *mtype = (OCIType *)0;

  text *name = (text*)"JENNY";
  ub4 name_len=(ub4)strlen( (char * ) name);
  ub4 ssn = 808; /* Data for ssn */
  ub4 addr_hno = 800; /*Data for  hno of addr */
  text *addr_street = (text *)"Laurel Road"; /*Data for street of addr */
  ub4 addr_streetLen = (ub4)strlen( (char *)addr_street);
  ub4 altadrs_hno = 800; /*data for hno of altadrs */
  text *altadrs_street = (text *)"Shoreline Street"; /*Data for street of altadrs */
  ub4 altadrs_streetLen = (ub4)strlen( (char *)altadrs_street);
  ub4 empno = 8888; /* data for empno */

  sb4 index1 = 0; /* Index for the starting point of the scan */
  sb4 index2 = 0; /* Index of the next existing element */
  boolean eoc = TRUE; /* For getting the status for the availability of
                         the next index */
  ub4 count = 0; /* Loop counter */
  OCIHandleAlloc (envhp, (dvoid **)&stmthp, OCI_HTYPE_STMT, (size_t)0,
    (dvoid **)0);

  if ((status = OCIStmtPrepare (stmthp, errhp, (text *)updateSql, 
    (ub4)strlen((char *)updateSql),OCI_NTV_SYNTAX, OCI_DEFAULT)) != OCI_SUCCESS)
  {
    printf ("OCIStmtPrepare - Fail\n");
  }

  if (( status = OCIObjectNew(envhp, errhp, svchp, OCI_TYPECODE_REF,
    (OCIType *)0, (dvoid *)0, OCI_DURATION_DEFAULT, FALSE, 
    (dvoid **) &sub_ref)) != OCI_SUCCESS)
  {
    printf ("OCIObjectNew - Failure\n");
  }

  if ((status = OCIDefineByPos(stmthp, &defhp, errhp, (ub4) 1,
    (dvoid *) 0, (sb4) 0, SQLT_REF, (dvoid *) 0,
    (ub2 *)0, (ub2 *)0, (ub4) OCI_DEFAULT)) != OCI_SUCCESS)
  {
    printf ("OCIDefineByPos - Failure \n");
  }

  if ((status = OCIDefineObject(defhp, errhp, (OCIType *)0,
    (dvoid **)&sub_ref, (ub4 *)&subSize, (dvoid **) 0, (ub4 *) 0))
    != OCI_SUCCESS)
  {
    printf ("OCIDefineObject - Failure \n");
  }
 
  printf ("\nExecuting the statement:%s\n", updateSql); 
  if (OCIStmtExecute (svchp, stmthp, errhp, (ub4)1, (ub4)0,
    (OCISnapshot *)0, (OCISnapshot *)0, OCI_COMMIT_ON_SUCCESS ) != OCI_SUCCESS)
  {
    printf("OCIStmtExecute - Failure \n");
  }
  else
  {
    printf("OCIStmtExecute - Success\n");
    if ((status = OCIObjectPin(envhp, errhp, sub_ref, (OCIComplexObject *)0,
      OCI_PIN_ANY, OCI_DURATION_SESSION, OCI_LOCK_NONE, 
      (dvoid **) &sub_obj)) != OCI_SUCCESS)
    {
      printf("OCIObjectPin - Failure \n");
    }
    else
    {
      printf ("\nDisplaying the original data from the employee table \n");
      display (sub_obj);
      printf ("\nModifying the data present in the object\n");
      if ((status = OCIObjectMarkUpdate (envhp, errhp, (dvoid *)sub_obj))
        != OCI_SUCCESS)
      {
        printf ("OCIObjectMarkUpdate - Fail\n");
      }
      else
      {
        printf ("OCIObjectMarkUpdate - Success\n");
      } 
      OCINumberFromInt (errhp, (dvoid *)&ssn, sizeof(ssn), OCI_NUMBER_UNSIGNED,
        &(sub_obj->_super.ssn));
      OCINumberFromInt (errhp, (dvoid *)&empno, sizeof(empno), 
                       OCI_NUMBER_UNSIGNED, &(sub_obj->empno));
      OCINumberFromInt (errhp, (dvoid *)&addr_hno, sizeof(addr_hno),
               OCI_NUMBER_UNSIGNED, &(sub_obj->_super.addr.hno));
      OCIStringAssignText (envhp, errhp, (text *)name, (ub2)name_len,
        &(sub_obj->_super.name));
      OCIStringAssignText (envhp, errhp, (text *)addr_street, (ub2)addr_streetLen,
        &(sub_obj->_super.addr.street));
      OCITableFirst(envhp, errhp, (CONST OCITable*)sub_obj->_super.altadrs, 
         &index1);
      OCICollGetElem(envhp, errhp, (OCIColl *)sub_obj->_super.altadrs, 
        index1, (boolean *)&eoc, (dvoid **)&elemptr, (dvoid **)0);
      OCINumberFromInt (errhp, (dvoid *)&altadrs_hno, sizeof(altadrs_hno),
        OCI_NUMBER_UNSIGNED, &(elemptr->hno));
      OCIStringAssignText (envhp, errhp, (text *)altadrs_street, (ub2)altadrs_streetLen,
        &(elemptr->street));
      for (count = 0; count < NUMREC-1; ++count)
      {
        altadrs_hno += count;
        OCITableNext(envhp, errhp, index1,
         (CONST OCITable*) sub_obj->_super.altadrs, &index2, &eoc);
        OCICollGetElem(envhp, errhp, (OCIColl *)sub_obj->_super.altadrs, 
          index2, (boolean *)&eoc, (dvoid **)&elemptr, (dvoid **)0);
        OCINumberFromInt (errhp, (dvoid *)&altadrs_hno, sizeof(altadrs_hno),
          OCI_NUMBER_UNSIGNED, &(elemptr->hno));
        OCIStringAssignText (envhp, errhp, (text *)altadrs_street, (ub2)altadrs_streetLen,
          &(elemptr->street));
        index1 = index2;
      } 
      index1 = 0;
      index2 = 0;
      
      OCITableFirst(envhp, errhp, (CONST OCITable*)sub_obj->workadd, &index1);
      OCICollAssignElem (envhp, errhp, index1, (dvoid *)workadd[count],
       (dvoid *)0, (OCIColl *)sub_obj->workadd);
      for (count = 0; count < NUMREC; ++count)
      {
        OCITableNext(envhp, errhp, index1,(CONST OCITable*) sub_obj->workadd,
          &index2, &eoc);
        OCICollAssignElem (envhp, errhp, index1, (dvoid *)workadd[count],
          (dvoid *)0, (OCIColl *)sub_obj->workadd);
        index1 = index2;
      } 
      
      if ((status = OCIObjectFlush(envhp, errhp, sub_obj)) != OCI_SUCCESS)
      {
        printf ("OCIObjectFlush - Fail\n");
      }
      else
      {
        printf ("OCIObjectFlush - Success\n");
      }
      printf ("Refreshing the object\n");
      if ((status = OCIObjectRefresh(envhp, errhp, (dvoid *)sub_obj))
        != OCI_SUCCESS)
      {
        printf ("OCIObjectRefresh - Fail\n");
      }
      else
      {
        printf ("OCIObjectRefresh - Success\n");
      }
      printf ("\nDisplaying the data in the employee table after the refresh\n");
      display (sub_obj);

      printf ("\nModifying the data present in the object once again\n");
      ssn = 606; /* Data for ssn */
      addr_hno = 200; /*Data for  hno of addr */
      addr_street = (text *)"Main Street"; /*Data for street of addr */
      addr_streetLen = (ub4)strlen( (char *)addr_street);
      altadrs_hno = 600; /*data for hno of altadrs */
      altadrs_street = (text *)"Shell Blvd";/*Data for street of altadrs*/
      altadrs_streetLen = (ub4)strlen( (char *)altadrs_street);
      empno = 6666; /* data for empno */

      if ((status = OCIObjectMarkUpdate (envhp, errhp, (dvoid *)sub_obj))
        != OCI_SUCCESS)
      {
        printf ("OCIObjectMarkUpdate - Fail\n");
      }
      else
      {
        printf ("OCIObjectMarkUpdate - Success\n");
      }
      index1 = 0;
      index2 = 0;
      OCINumberFromInt (errhp, (dvoid *)&ssn, sizeof(ssn), OCI_NUMBER_UNSIGNED,
        &(sub_obj->_super.ssn));
      OCINumberFromInt (errhp, (dvoid *)&empno, sizeof(empno), OCI_NUMBER_UNSIGNED,
        &(sub_obj->empno));
      OCINumberFromInt (errhp, (dvoid *)&addr_hno, sizeof(addr_hno),
        OCI_NUMBER_UNSIGNED, &(sub_obj->_super.addr.hno));
      OCIStringAssignText (envhp, errhp, (text *)addr_street, 
         (ub2)addr_streetLen, &(sub_obj->_super.addr.street));
      OCITableFirst(envhp, errhp,(CONST OCITable*)sub_obj->_super.altadrs,
          &index1);
      OCICollGetElem(envhp, errhp, (OCIColl *)sub_obj->_super.altadrs, 
        index1, (boolean *)&eoc, (dvoid **)&elemptr, (dvoid **)0);
      OCINumberFromInt (errhp, (dvoid *)&altadrs_hno, sizeof(altadrs_hno),
        OCI_NUMBER_UNSIGNED, &(elemptr->hno));
      OCIStringAssignText (envhp, errhp, (text *)altadrs_street, (ub2)altadrs_streetLen,
        &(elemptr->street));
      for (count = 0; count < NUMREC-1; ++count)
      {
        altadrs_hno += count;
        OCITableNext(envhp, errhp, index1,(CONST OCITable*) sub_obj->_super.altadrs, &index2, 
          &eoc);
        OCICollGetElem(envhp, errhp, (OCIColl *)sub_obj->_super.altadrs, 
          index2, (boolean *)&eoc, (dvoid **)&elemptr, (dvoid **)0);
        OCINumberFromInt (errhp, (dvoid *)&altadrs_hno, sizeof(altadrs_hno),
          OCI_NUMBER_UNSIGNED, &(elemptr->hno));
        OCIStringAssignText (envhp, errhp, (text *)altadrs_street, (ub2)altadrs_streetLen,
          &(elemptr->street));
        index1 = index2;
      } 
      index1 = 0;
      index2 = 0;
      
      OCITableFirst(envhp, errhp, (CONST OCITable*)sub_obj->workadd, &index1);
      OCICollAssignElem (envhp, errhp, index1, (dvoid *)workadd[count],
       (dvoid *)0, (OCIColl *)sub_obj->workadd);
      for (count = 0; count < NUMREC; ++count)
      {
        OCITableNext(envhp, errhp, index1, (CONST OCITable*)sub_obj->workadd,
          &index2, &eoc);
        OCICollAssignElem (envhp, errhp, index1, (dvoid *)workadd[count],
          (dvoid *)0, (OCIColl *)sub_obj->workadd);
        index1 = index2;
      } 
      if ((status = OCICacheFlush (envhp, errhp, svchp, NULL, NULL, &sub_ref))
        != OCI_SUCCESS)
      {
        printf ("OCICacheFlush - Fail\n");
      }
      else
      {
        printf ("OCICacheFlush - Success\n");
      }
    }
        
    if ((status = OCITransCommit (svchp, errhp, OCI_DEFAULT)) != OCI_SUCCESS)
    {
      printf ("OCITransCommit - Fail\n");
    }
    else
      printf ("OCITransCommit - Success\n");
  }
  OCIHandleFree((dvoid *) stmthp, OCI_HTYPE_STMT);

} /* end of modifyFunction() */