Ejemplo n.º 1
0
CPLErr OGROCIStatement::BindObject( const char *pszPlaceName, 
                                    void *pahObjects, OCIType *hTDO,
                                    void **papIndicators )

{
    OCIBind *hBindOrd = NULL;

    if( poSession->Failed( 
            OCIBindByName( hStatement, &hBindOrd, poSession->hError,
                           (text *) pszPlaceName, (sb4) strlen(pszPlaceName), 
                           (dvoid *) 0, (sb4) 0, SQLT_NTY, (dvoid *)0, 
                           (ub2 *)0, (ub2 *)0, (ub4)0, (ub4 *)0, 
                           (ub4)OCI_DEFAULT),
            "OCIBindByName()") )
        return CE_Failure;
    
    if( poSession->Failed(
            OCIBindObject( hBindOrd, poSession->hError, hTDO,
                           (dvoid **) pahObjects, (ub4 *)0, 
                           (dvoid **)papIndicators, (ub4 *)0),
            "OCIBindObject()" ) )
        return CE_Failure;

    return CE_None;
}
Ejemplo n.º 2
0
void OWStatement::Bind( OCIArray** pphData, OCIType* type )
{
    OCIBind* hBind = NULL;

    nNextBnd++;

    CheckError( OCIBindByPos(
        hStmt,
        &hBind,
        hError,
        (ub4) nNextBnd,
        (dvoid*) 0,
        (sb4) 0,
        (ub2) SQLT_NTY,
        (void*) NULL,
        (ub2*) NULL,
        (ub2*) NULL,
        (ub4) NULL,
        (ub4) NULL,
        (ub4) OCI_DEFAULT ),
        hError );

    CheckError( OCIBindObject(
        hBind,
        hError,
        type,
        (dvoid **)pphData,
        (ub4 *)0,
        (dvoid **)0,
        (ub4 *)0 ),
        hError);

}
Ejemplo n.º 3
0
void OWStatement::Bind( sdo_geometry** pphData )
{
    OCIBind* hBind = NULL;

    nNextBnd++;

    CheckError( OCIBindByPos(
        hStmt,
        &hBind,
        hError,
        (ub4) nNextBnd,
        (dvoid*) NULL,
        (sb4) 0,
        (ub2) SQLT_NTY,
        (void*) NULL,
        (ub2*) NULL,
        (ub2*) NULL,
        (ub4) 0,
        (ub4) 0,
        (ub4) OCI_DEFAULT ),
        hError );

    CheckError( OCIBindObject(
        hBind,
        hError,
        poConnection->hGeometryTDO,
    (dvoid**) pphData,
        (ub4*) 0,
    (dvoid**) 0,
        (ub4*) 0),
        hError );

}
Ejemplo n.º 4
0
void BindParXML::bind_hook()
{
//	xmlsize = 0;

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

	sword res = OCICALL(OCIBindObject(bindp, _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);
//  TODO
//	if( _cnt > 1 ) {
//		res = OCICALL(OCIDefineArrayOfStruct(bindp, conn._env._errh, sizeof(OCIXMLType*), 0, 0, 0));
//		oci_check_error(__TROTL_HERE__, conn._env._errh, res);
//	}
}
Ejemplo n.º 5
0
/* Function to insert an instance of the subtype into a supertype table */
static void insertFunction()
{
  OCIBind *bindhp = (OCIBind *)0;
  i_residence elem;
  i_residence *elemptr = &elem;
  i_manager *sub_obj = (i_manager *)0;
  i_manager_ind ind;
  OCIType *i_manager_tdo = (OCIType *)0;

  ub4 subSize = 0;
  ub4 sizeUB4 = sizeof (ub4);
  sb4 size = 0;
  text *name = (text*)"JENNY";
  ub4 name_len =(ub4)( strlen( (char * ) name));
  ub4 ssn = 303; /* Data for ssn */
  ub4 addr_hno = 33; /*Data for  hno of addr */
  text *addr_street = (text *)"T33"; /*Data for street of addr */
  ub4 addr_streetLen = (ub4)(strlen( (char *)addr_street));
  ub4 altadrs_hno = 333; /*data for hno of altadrs */
  text *altadrs_street = (text *)"T333"; /*Data for street of altadrs */
  ub4 altadrs_streetLen = (ub4)(strlen( (char *)altadrs_street));
  ub4 empno = 3333; /* 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 */

  memset(&ind, 0, sizeof(ind));
  memset(elemptr, 0, sizeof(elem));
  OCIHandleAlloc (envhp, (dvoid **)&stmthp, OCI_HTYPE_STMT, (size_t)0,
    (dvoid **)0);

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

  if ((status = OCIBindByName(stmthp, &bindhp, errhp, (text *)":v1",
      (sb4) -1, (dvoid *)0, (sb4)0, SQLT_NTY, (dvoid *)0, (ub2 *)0, (ub2 *)0,
      (ub4)0, (ub4 *)0, OCI_DEFAULT)) != OCI_SUCCESS)
  {
    printf ("OCIBindByName - Failure \n");
  }

  if ((status = OCITypeByName (envhp, errhp, svchp, (CONST text *)0, (ub4)0,
    (CONST text *)"I_MANAGER", (ub4)strlen ((char *)"I_MANAGER"),
    (CONST text *)0, (ub4)0, OCI_DURATION_SESSION, OCI_TYPEGET_HEADER,
    &i_manager_tdo)) != OCI_SUCCESS)
  {
    printf ("OCITypeByName - Fail\n");
  }

  if (( status = OCIObjectNew(envhp, errhp, svchp, OCI_TYPECODE_OBJECT,
    (OCIType *)i_manager_tdo, (dvoid *)0, OCI_DURATION_SESSION, TRUE,
    (dvoid **) &sub_obj)) != OCI_SUCCESS)
  {
    printf ("OCIObjectNew - Failure\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));
  for (count = 0; count < NUMREC; ++count)
  {
    OCIStringAssignText (envhp, errhp, (text *)altadrs_street, (ub2)altadrs_streetLen,
      &(elemptr->street));  
    OCINumberFromInt (errhp, (dvoid *)&altadrs_hno, sizeof(altadrs_hno),
      OCI_NUMBER_UNSIGNED, &(elemptr->hno));
    if (( status = OCICollAppend (envhp, errhp, (dvoid *)elemptr, (dvoid *)&ind,
      (OCIColl *)sub_obj->_super.altadrs)) != OCI_SUCCESS)
    {
      printf ("OCICollAppend - Fail\n");
    }
    altadrs_hno ++;
  } 
  for (count = 0; count < NUMREC; ++count)
  {
    if (( status = OCICollAppend (envhp, errhp, (dvoid *)workadd[count], 
      (dvoid *)&ind, (OCIColl *)sub_obj->workadd)) != OCI_SUCCESS)
    {
      printf ("OCICollAppend - Fail\n");
    }
  } 
  OCITableSize(envhp, errhp,(CONST OCITable*) (sub_obj->_super.altadrs), &size);
  OCITableSize(envhp, errhp,(CONST OCITable*) (sub_obj->workadd), &size);

  if (OCIBindObject(bindhp, errhp, i_manager_tdo,
    (dvoid **) &sub_obj, (ub4 *)0, (dvoid **)&ind , (ub4 *) 0) != OCI_SUCCESS)
  {
    printf("OCIBindObject - Failure \n");
  }

  printf ("\nExecuting the statement:%s\n", insertSql); 
  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");

  OCIHandleFree((dvoid *) stmthp, OCI_HTYPE_STMT);
}/* End on insertFunction() */