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

📄 occicontrol.h

📁 oci函数批量插入数据
💻 H
📖 第 1 页 / 共 4 页
字号:
void getVector( Statement *stmt, unsigned int index,
OCCI_STD_NAMESPACE::vector<T *> &vect)
{
  OCCI_STD_NAMESPACE::vector<PObject *> vec_pobj;
  getVectorOfPObjects(stmt, index, vec_pobj);
  vect.clear();
  unsigned int size = vec_pobj.size();
  vect.reserve( size );
  for (unsigned int i=0; i< size; i++)
    vect.push_back((T *)vec_pobj[i]);
}
#endif

/*------------------------ getVector for Ref<T> ---------------------------*/
/*
   NAME
      getVector - overloaded function. Retrieves the attribute in the current
position as a vector of Ref<T>

   PARAMETERS
      rs - ResultSet
      vect- reference to vector of Ref<T>(OUT parameter).

   DESCRIPTION
     Retrieves the column in the specified position as a vector of Ref<T>.
   The attribute at the current position should be a collection type (varray or
   nested table). The SQL type of the elements in the collection should be
   compatible with Ref<T>.

   RETURNS
     nothing

   NOTES
        compatible SQL types : REF
*/
#ifndef WIN32COMMON
template <class T>
void getVector( ResultSet *rs, unsigned int index, OCCI_STD_NAMESPACE::vector<Ref<T> > &vect) 
{
  OCCI_STD_NAMESPACE::vector<void *> vec_ref;
  getVectorOfOCIRefs(rs, index, vec_ref);

  const Connection *sess = rs->getStatement()->getConnection();

  vect.clear();
  unsigned int size = vec_ref.size();
  vect.reserve( size );
  for (unsigned int i=0; i< size; i++)
  {
    if (vec_ref[i] == (OCIRef *)0)
       vect.push_back(Ref<T>());     // pushing a default-constructed Ref
     else
       vect.push_back(Ref<T>(sess, (OCIRef *)vec_ref[i], FALSE));
  }
}
#endif

/*------------------------ setVector for PObject*---------------------------*/
/*
   NAME
      SetVector - overloaded function. Binds the attribute in the current
      position with a vector of objects.

   PARAMETERS
      rs - ResultSet
      vect- reference to vector of objects(OUT parameter).

   DESCRIPTION
     Binds the column in the specified position with a vector of signed int .
   The column at the current position should be a collection type (varray or
   nested table). The SQL type of the elements in the collection should be
   compatible with objects .

   RETURNS
     nothing

   NOTES
     compatible SQL types : SQLT_NTY
 
     This will be calling setVector(..., vector<PObject*>,..)

*/
#ifdef WIN32COMMON
// and other platforms that do not support
// partial function template specialization

template <class T>
void setVector( Statement *stmt, unsigned int index, const OCCI_STD_NAMESPACE::vector<T> &vect, const OCCI_STD_NAMESPACE::string &sqltype) 
{
  OCCI_STD_NAMESPACE::vector<PObject *> vec_pobj;
  unsigned int size = vect.size();
  vec_pobj.reserve( size );
  
  for (unsigned int i = 0; i < size; i++)
    vec_pobj.push_back((PObject *)vect[i]);

  setVectorOfPObjects(stmt, index, vec_pobj, sqltype);
}
#else
template <class T>
void setVector( Statement *stmt, unsigned int index, const OCCI_STD_NAMESPACE::
vector<T *> &vect, const OCCI_STD_NAMESPACE::string &sqltype)
{
  OCCI_STD_NAMESPACE::vector<PObject *> vec_pobj;
  unsigned int size = vect.size();
  vec_pobj.reserve( size );

  for (unsigned int i = 0; i < size; i++)
    vec_pobj.push_back((PObject *)vect[i]);

  setVectorOfPObjects(stmt, index, vec_pobj, sqltype);
}
#endif

/*------------------------ setVector for Ref<T>---------------------------*/
/*
   NAME
      setVector - overloaded function. Binds the attribute in the current
      position with a vector of Ref<T>.

   PARAMETERS
      rs - ResultSet
      vect- reference to vector of REF

   DESCRIPTION
     Binds the column in the specified position with a vector of signed int .
   The column at the current position should be a collection type (varray or
   nested table). The SQL type of the elements in the collection should be
   compatible with OCIRef* .

   RETURNS
     nothing

   NOTES
     compatible SQL types : REF 

     This will just call setVector(..., vector<OCIRef*>,..)


*/
#ifndef WIN32COMMON
template <class T>
void setVector( Statement *stmt, unsigned int index, const OCCI_STD_NAMESPACE::vector<Ref<T> > &vect, const OCCI_STD_NAMESPACE::string &sqltype)
{
  OCCI_STD_NAMESPACE::vector<void *> vec_ref;
  OCCI_STD_NAMESPACE::vector<OCIInd> vec_ind;
  unsigned int size = vect.size();
  vec_ref.reserve( size );
  vec_ind.reserve( size );

  for (unsigned int i = 0; i < size; i++)
  {
    vec_ref.push_back((void *)vect[i].getRef());
    vec_ind.push_back( vect[i].isNull() ? OCI_IND_NULL : OCI_IND_NOTNULL);
  }

  setVectorOfOCIRefs(stmt, index, vec_ref, vec_ind, sqltype);
}
#endif

/*------------------------ getVector for Ref<T> ---------------------------*/
/*
   NAME
      getVector - overloaded function. Retrieves the attribute in the current
position as a vector of Ref<T>

   PARAMETERS
      stmt - Statement
      vect- reference to vector of Ref<T>(OUT parameter).

   DESCRIPTION
     Retrieves the column in the specified position as a vector of Ref<T>.
   The attribute at the current position should be a collection type (varray or
   nested table). The SQL type of the elements in the collection should be
   compatible with Ref<T>.

   RETURNS
     nothing

   NOTES
        compatible SQL types : REF
*/
#ifndef WIN32COMMON
template <class T>
void getVector( Statement *stmt, unsigned int index, OCCI_STD_NAMESPACE::vector<Ref<T> > &vect) 
{
  OCCI_STD_NAMESPACE::vector<void *> vec_ref;
  getVectorOfOCIRefs(stmt, index, vec_ref);

  const Connection *sess = stmt->getConnection();

  vect.clear();
  unsigned int size = vec_ref.size();
  vect.reserve( size );
  for (unsigned int i=0; i< size; i++)
  {
    if (vec_ref[i] == (OCIRef *)0)
       vect.push_back(Ref <T>());     // pushing a default-constructed Ref
     else
       vect.push_back(Ref<T> (sess, (OCIRef *)vec_ref[i], FALSE));
  }
 
}
#endif

// Platform independent get/setVectorOfRefs method added
// get(set)Vector of Ref<T> and get(set)VectorOfRefs are identical 
// in functionality. 

/*------------------------ getVectorOfRefs for Ref<T> ----------------------*/
/*
   NAME
      getVectorOfRefs - overloaded function. Retrieves the attribute in the
      current position as a vector of Ref<T>

   PARAMETERS
      rs - ResultSet
      vect- reference to vector of Ref<T>(OUT parameter).

   DESCRIPTION
     Retrieves the column in the specified position as a vector of Ref<T>.
   The attribute at the current position should be a collection type (varray or
   nested table). The SQL type of the elements in the collection should be
   compatible with Ref<T>.

   RETURNS
     nothing

   NOTES
        compatible SQL types : REF
*/

template <class T>
void getVectorOfRefs( ResultSet *rs, unsigned int index, 
OCCI_STD_NAMESPACE::vector<Ref<T> > &vect)
{
  OCCI_STD_NAMESPACE::vector<void *> vec_ref;
  getVectorOfOCIRefs(rs, index, vec_ref);

  const Connection *sess = rs->getStatement()->getConnection();

  vect.clear();
  unsigned int size = vec_ref.size();
  vect.reserve( size );
  for (unsigned int i=0; i< size; i++)
  {
    if (vec_ref[i] == (OCIRef *)0)
       vect.push_back(Ref<T>());     // pushing a default-constructed Ref
     else
       vect.push_back(Ref<T>(sess, (OCIRef *)vec_ref[i], FALSE));
  }
}

/*------------------------ setVectorOfRefs for Ref<T>-----------------------*/
/*
   NAME
      setVectorOfRefs - overloaded function. Binds the attribute in the current
      position with a vector of Ref<T>.

   PARAMETERS
      rs - ResultSet
      vect- reference to vector of REF

   DESCRIPTION
     Binds the column in the specified position with a vector of signed int .
   The column at the current position should be a collection type (varray or
   nested table). The SQL type of the elements in the collection should be
   compatible with OCIRef* .

   RETURNS
     nothing

   NOTES
     compatible SQL types : REF

     This will just call setVector(..., vector<OCIRef*>,..)


*/

template <class T>
void setVectorOfRefs( Statement *stmt, unsigned int index, 
const OCCI_STD_NAMESPACE::vector<Ref<T> > &vect, 
const OCCI_STD_NAMESPACE::string &sqltype)
{
  OCCI_STD_NAMESPACE::vector<void *> vec_ref;
  OCCI_STD_NAMESPACE::vector<OCIInd> vec_ind;
  unsigned int size = vect.size();
  vec_ref.reserve( size );
  vec_ind.reserve( size );

  for (unsigned int i = 0; i < size; i++)
  {
    vec_ref.push_back((void *)vect[i].getRef());
    vec_ind.push_back( vect[i].isNull() ? OCI_IND_NULL : OCI_IND_NOTNULL);
  }

  setVectorOfOCIRefs(stmt, index, vec_ref, vec_ind, sqltype);
}

/*------------------------ getVectorOfRefs for Ref<T> ----------------------*/
/*
   NAME
      getVectorOfRefs - overloaded function. Retrieves the attribute in the
      current position as a vector of Ref<T>

   PARAMETERS
      stmt - Statement
      vect- reference to vector of Ref<T>(OUT parameter).

   DESCRIPTION
     Retrieves the column in the specified position as a vector of Ref<T>.
   The attribute at the current position should be a collection type (varray or
   nested table). The SQL type of the elements in the collection should be
   compatible with Ref<T>.

   RETURNS
     nothing

   NOTES
        compatible SQL types : REF
*/

template <class T>
void getVectorOfRefs( Statement *stmt, unsigned int index, 
OCCI_STD_NAMESPACE::vector <Ref<T> > &vect)
{
  OCCI_STD_NAMESPACE::vector<void *> vec_ref;
  getVectorOfOCIRefs(stmt, index, vec_ref);

  const Connection *sess = stmt->getConnection();

  vect.clear();
  unsigned int size = vec_ref.size();
  vect.reserve( size );
  for (unsigned int i=0; i< size; i++)
  {
    if (vec_ref[i] == (OCIRef *)0)
       vect.push_back(Ref <T>());     // pushing a default-constructed Ref
     else
       vect.push_back(Ref<T> (sess, (OCIRef *)vec_ref[i], FALSE));
  }
}


/*---------------------------------------------------------------------------
                          INTERNAL FUNCTIONS
  ---------------------------------------------------------------------------*/


} /* end of namespace occi */
} /* end of namespace oracle */
#endif                                              /* OCCICONTROL_ORACLE */

#endif                                              /* _olint */

⌨️ 快捷键说明

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