Public Member Functions | Protected Attributes

OCIPL::SqlVariantArray Struct Reference

variant array to be used as bind variable buffer More...

#include <ocipl.h>

Collaboration diagram for OCIPL::SqlVariantArray:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SqlVariantArray ()
 SqlVariantArray (const ColumnTypeInfo &type, int size)
 SqlVariantArray (const SqlVariantArray &other)
 ~SqlVariantArray ()
void clear ()
void assign (const SqlVariantArray &other)
ub2 get_data_type () const
SqlVariantArrayoperator= (const SqlVariantArray &other)
tstring str (int row, OCIError *errh) const
SqlNumber number (int row, OCIError *errh) const
OciDate oci_date (int row, OCIError *errh) const
SqlDateTime sql_date (int row, OCIError *errh) const
bool is_null (int row) const
bool is_not_null (int row) const
void bind_result (SqlStatement &stmt, int idx)
void set_string (int row, const TCHAR *str)
void set_number (int row, const SqlNumber &num)
void set_date (int row, const OciDate &date)
void set_datetime (int row, const SqlDateTime &datetime)
void bind_input (SqlStatement &stmt, int idx, int row)

Protected Attributes

union {
   SqlStringArray *   _pstring
   SqlNumberArray *   _pnumber
   OciDateArray *   _poci_date
   SqlDateTimeArray *   _psql_date
   void *   _punion_ptr
}; 
int _size
ub2 _data_type

Detailed Description

variant array to be used as bind variable buffer

Definition at line 3467 of file ocipl.h.


Constructor & Destructor Documentation

OCIPL::SqlVariantArray::SqlVariantArray (  ) [inline]

Definition at line 3469 of file ocipl.h.

     :  _data_type(0)
    {
        _punion_ptr = NULL;
    }
OCIPL::SqlVariantArray::SqlVariantArray ( const ColumnTypeInfo type,
int  size 
)

Definition at line 1461 of file ocipl.cpp.

References _data_type, OCIPL::ColumnTypeInfo::_data_type, _pnumber, _poci_date, _psql_date, _pstring, OCIPL::ColumnTypeInfo::_width, and THROW_OCI_EXCEPTION.

 :  _size(size),
    _data_type(type._data_type)
{
    switch(type._data_type) {
      case OCI_TYPECODE_CHAR:
        _data_type = OCI_TYPECODE_VARCHAR;
        // fall through

      case OCI_TYPECODE_VARCHAR:
        _pstring = new SqlStringArray(size, type._width);
        break;

      case OCI_TYPECODE_NUMBER:
        _pnumber = new SqlNumberArray(size);
        break;

#ifdef SQLT_BFLOAT
      case OCI_TYPECODE_BFLOAT:
        _pfloat = new float[size];
        break;

      case OCI_TYPECODE_BDOUBLE:
        _pdouble = new double[size];
        break;
#endif

      case OCI_TYPECODE_DATE:
        _poci_date = new OciDateArray(size);
        break;

#if ORACLE_VERSION>=81
      case OCI_TYPECODE_TIME:
      case OCI_TYPECODE_TIMESTAMP:
        _psql_date = new SqlDateTimeArray(size);
        break;
/* no LOB allocation without available handles
      case OCI_TYPECODE_BLOB:
        _pblob = new OciBlobArray(size);
        break;

      case OCI_TYPECODE_CLOB:
        _pclob = new OciClobArray(size);
        break;
*/
#endif
      case SQLT_LNG:
        _pstring = new SqlStringArray(size, type._width);   //@@
        break;

      default:
        THROW_OCI_EXCEPTION("unsupported datatype");
    }
}
OCIPL::SqlVariantArray::SqlVariantArray ( const SqlVariantArray other )

Definition at line 1516 of file ocipl.cpp.

References assign().

 :  _size(0),
    _data_type(0)
{
    assign(other);
}

Here is the call graph for this function:

OCIPL::SqlVariantArray::~SqlVariantArray (  ) [inline]

Definition at line 3477 of file ocipl.h.

{clear();}

Member Function Documentation

void OCIPL::SqlVariantArray::assign ( const SqlVariantArray other )

Definition at line 1523 of file ocipl.cpp.

References _data_type, _pnumber, _poci_date, _psql_date, _pstring, _size, and clear().

Referenced by SqlVariantArray().

{
    clear();

    _size = other._size;
    _data_type = other._data_type;

    switch(other._data_type) {
      case 0:
        break;

      case OCI_TYPECODE_VARCHAR:
        _pstring = new SqlStringArray(*other._pstring); //@@
        break;

      case OCI_TYPECODE_NUMBER:
        _pnumber = new SqlNumberArray(*other._pnumber);
        break;

#ifdef SQLT_BFLOAT
      case OCI_TYPECODE_BFLOAT:
        _pfloat = new float[_size];
        memcpy(_pfloat, other._pfloat, sizeof(float)*_size);
        break;

      case OCI_TYPECODE_BDOUBLE:
        _pdouble = new double[_size];
        memcpy(_pfloat, other._pfloat, sizeof(double)*_size);
        break;
#endif

      case OCI_TYPECODE_DATE:
        _poci_date = new OciDateArray(*other._poci_date);
        break;

#if ORACLE_VERSION>=81
      case OCI_TYPECODE_TIME:
      case OCI_TYPECODE_TIMESTAMP:
        _psql_date = new SqlDateTimeArray(*other._psql_date);
        break;
#endif
/*
      case OCI_TYPECODE_BLOB:
        _pblob = new OciBlobArray(*other._pblob);
        break;

      case OCI_TYPECODE_CLOB:
        _pclob = new OciClobArray(*other._pclob);
        break;
*/
      case SQLT_LNG:
        _pstring = new SqlStringArray(*other._pstring); //@@
        break;

      default:
        assert(0);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OCIPL::SqlVariantArray::bind_input ( SqlStatement stmt,
int  idx,
int  row 
)

Definition at line 1917 of file ocipl.cpp.

References _data_type, _pnumber, _poci_date, _psql_date, _pstring, OCIPL::SqlStringArray::alen(), OCIPL::SqlStatement::bind_input(), OCIPL::OciDateArray::get_date(), OCIPL::SqlDateTimeArray::get_datetime(), OCIPL::SqlNumberArray::get_number(), OCIPL::SqlIndArray::ind(), and OCIPL::SqlStringArray::str().

{
    switch(_data_type) {
      case OCI_TYPECODE_VARCHAR:
        stmt.bind_input(idx, BindInput(_pstring->str(row), _pstring->alen(), SQLT_STR));
        break;

      case OCI_TYPECODE_NUMBER:
        stmt.bind_input(idx, BindInput(_pnumber->get_number(row), _pnumber->ind(row)));
        break;

#ifdef SQLT_BFLOAT
      case OCI_TYPECODE_BFLOAT:
        stmt.bind_input(idx, *_pfloat);
        break;

      case OCI_TYPECODE_BDOUBLE:
        stmt.bind_input(idx, *_pdouble);
        break;
#endif

      case OCI_TYPECODE_DATE:
        stmt.bind_input(idx, BindInput(_poci_date->get_date(row), _poci_date->ind(row)));
        break;

#if ORACLE_VERSION>=81
      case OCI_TYPECODE_TIME:
      case OCI_TYPECODE_TIMESTAMP:
        stmt.bind_input(idx, BindInput(_psql_date->get_datetime(row), _psql_date->ind(row)));
        break;
#endif
/*
      case OCI_TYPECODE_BLOB:
        stmt.bind_input(idx, *_pblob);
        break;

      case OCI_TYPECODE_CLOB:
        stmt.bind_input(idx, *_pclob);
        break;
*/
      case SQLT_LNG:
        stmt.bind_input(idx, BindInput(_pstring->str(row), _pstring->alen(), SQLT_STR));    //@@
        break;

      default:
        assert(0);
    }
}

Here is the call graph for this function:

void OCIPL::SqlVariantArray::bind_result ( SqlStatement stmt,
int  idx 
)

Definition at line 1867 of file ocipl.cpp.

References _data_type, _pnumber, _poci_date, _psql_date, _pstring, and OCIPL::SqlStatement::bind_result().

{
    switch(_data_type) {
      case OCI_TYPECODE_VARCHAR:
        stmt.bind_result(idx, *_pstring);
        break;

      case OCI_TYPECODE_NUMBER:
        stmt.bind_result(idx, *_pnumber);
        break;

#ifdef SQLT_BFLOAT
      case OCI_TYPECODE_BFLOAT:
        stmt.bind_result(idx, *_pfloat);
        break;

      case OCI_TYPECODE_BDOUBLE:
        stmt.bind_result(idx, *_pdouble);
        break;
#endif

      case OCI_TYPECODE_DATE:
        stmt.bind_result(idx, *_poci_date);
        break;

#if ORACLE_VERSION>=81
      case OCI_TYPECODE_TIME:
      case OCI_TYPECODE_TIMESTAMP:
        stmt.bind_result(idx, *_psql_date);
        break;
#endif
/*
      case OCI_TYPECODE_BLOB:
        stmt.bind_result(idx, *_pblob);
        break;

      case OCI_TYPECODE_CLOB:
        stmt.bind_result(idx, *_pclob);
        break;
*/
      case SQLT_LNG:
        stmt.bind_result(idx, *_pstring);   //@@
        break;

      default:
        assert(0);
    }
}

Here is the call graph for this function:

void OCIPL::SqlVariantArray::clear (  )

Definition at line 1582 of file ocipl.cpp.

References _data_type, _pnumber, _poci_date, _psql_date, _pstring, and _size.

Referenced by assign().

{
    switch(_data_type) {
      case 0:
        break;

      case OCI_TYPECODE_VARCHAR:
        delete _pstring;
        break;

      case OCI_TYPECODE_NUMBER:
        delete _pnumber;
        break;

#ifdef SQLT_BFLOAT
      case OCI_TYPECODE_BFLOAT:
        delete [] _pfloat;
        break;

      case OCI_TYPECODE_BDOUBLE:
        delete [] _pdouble;
        break;
#endif

      case OCI_TYPECODE_DATE:
        delete _poci_date;
        break;

#if ORACLE_VERSION>=81
      case OCI_TYPECODE_TIME:
      case OCI_TYPECODE_TIMESTAMP:
        delete _psql_date;
        break;
#endif
/*
      case OCI_TYPECODE_BLOB:
        delete _pblob;
        break;

      case OCI_TYPECODE_CLOB:
        delete _pclob;
        break;
*/
      case SQLT_LNG:
        delete _pstring;    //@@
        break;

      default:
        assert(0);
    }

    _size = 0;
    _data_type = 0;
}

Here is the caller graph for this function:

ub2 OCIPL::SqlVariantArray::get_data_type (  ) const [inline]

Definition at line 3482 of file ocipl.h.

        {return _data_type;}
bool OCIPL::SqlVariantArray::is_not_null ( int  row ) const

Definition at line 1827 of file ocipl.cpp.

References _data_type, _pnumber, _poci_date, _psql_date, _pstring, and OCIPL::SqlIndArray::is_not_null().

{
    switch(_data_type) {
      case 0:
#ifdef SQLT_BFLOAT
      case OCI_TYPECODE_BFLOAT:
      case OCI_TYPECODE_BDOUBLE:
#endif
        return true;

      case OCI_TYPECODE_VARCHAR:
        return _pstring->is_not_null(row);

      case OCI_TYPECODE_NUMBER:
        return _pnumber->is_not_null(row);

      case OCI_TYPECODE_DATE:
        return _poci_date->is_not_null(row);

#if ORACLE_VERSION>=81
      case OCI_TYPECODE_TIME:
      case OCI_TYPECODE_TIMESTAMP:
        return _psql_date->is_not_null(row);
#endif
/*
      case OCI_TYPECODE_BLOB:
        return _pblob->is_not_null(row);

      case OCI_TYPECODE_CLOB:
        return _pclob->is_not_null(row);
*/
      case SQLT_LNG:
        return _pstring->is_not_null(row);  //@@

      default:
        assert(0);
        return true;
    }
}

Here is the call graph for this function:

bool OCIPL::SqlVariantArray::is_null ( int  row ) const [inline]

Definition at line 3492 of file ocipl.h.

{return !is_not_null(row);}
SqlNumber OCIPL::SqlVariantArray::number ( int  row,
OCIError *  errh 
) const

Definition at line 1713 of file ocipl.cpp.

References _data_type, _pnumber, _pstring, OCIPL::SqlStringArray::c_str(), OCIPL::SqlNumberArray::get_ref(), OCIPL::SqlIndArray::is_not_null(), and THROW_OCI_EXCEPTION.

{
    switch(_data_type) {
      case 0:
        return SqlNumber();

      case OCI_TYPECODE_VARCHAR:
        return SqlNumber(errh, _pstring->c_str(row));

      case OCI_TYPECODE_NUMBER:
        if (_pnumber->is_not_null(row))
            return _pnumber->get_ref(row);
        else
            return SqlNumber();

#ifdef SQLT_BFLOAT
      case OCI_TYPECODE_BFLOAT:
        return SqlNumber(errh, _pfloat[row]);

      case OCI_TYPECODE_BDOUBLE:
        return SqlNumber(errh, _pdouble[row]);
#endif

    //case OCI_TYPECODE_DATE:
    //  return ...

      default:
        THROW_OCI_EXCEPTION("no conversion to number");
        //return SqlNumber();   // not reached
    }
}

Here is the call graph for this function:

OciDate OCIPL::SqlVariantArray::oci_date ( int  row,
OCIError *  errh 
) const

Definition at line 1754 of file ocipl.cpp.

References _data_type, _poci_date, _pstring, OCIPL::SqlStringArray::c_str(), OCIPL::OciDateArray::get_ref(), OCIPL::SqlIndArray::is_not_null(), and THROW_OCI_EXCEPTION.

{
    switch(_data_type) {
      case 0:
        return OciDate();

      case OCI_TYPECODE_VARCHAR:
        return OciDate(errh, _pstring->c_str(row));

      case OCI_TYPECODE_DATE:
        if (_poci_date->is_not_null(row))
            return *_poci_date->get_ref(row);
        else
            return OciDate();
/*@@todo convert type
#if ORACLE_VERSION>=81
      case OCI_TYPECODE_TIME:
      case OCI_TYPECODE_TIMESTAMP:
        return *_sql_date;
#endif
*/
      default:
        THROW_OCI_EXCEPTION("no conversion to date");
        //return OciDate(); // not reached
    }
}

Here is the call graph for this function:

SqlVariantArray& OCIPL::SqlVariantArray::operator= ( const SqlVariantArray other ) [inline]

Definition at line 3485 of file ocipl.h.

{assign(other); return *this;}
void OCIPL::SqlVariantArray::set_date ( int  row,
const OciDate date 
)

Definition at line 1781 of file ocipl.cpp.

References _data_type, _poci_date, OCIPL::OciDateArray::set_date(), and THROW_OCI_EXCEPTION.

{
    if (_data_type != OCI_TYPECODE_DATE)
        THROW_OCI_EXCEPTION("invalid variant data type");

    _poci_date->set_date(row, date);
}

Here is the call graph for this function:

void OCIPL::SqlVariantArray::set_datetime ( int  row,
const SqlDateTime datetime 
)

Definition at line 1818 of file ocipl.cpp.

References _data_type, _psql_date, OCIPL::SqlDateTimeArray::set_datetime(), and THROW_OCI_EXCEPTION.

{
    if (_data_type!=OCI_TYPECODE_TIME && _data_type!=OCI_TYPECODE_TIMESTAMP)
        THROW_OCI_EXCEPTION("invalid variant data type");

    _psql_date->set_datetime(row, datetime);
}

Here is the call graph for this function:

void OCIPL::SqlVariantArray::set_number ( int  row,
const SqlNumber num 
)

Definition at line 1745 of file ocipl.cpp.

References _data_type, _pnumber, OCIPL::SqlNumberArray::set_number(), and THROW_OCI_EXCEPTION.

{
    if (_data_type != OCI_TYPECODE_NUMBER)
        THROW_OCI_EXCEPTION("invalid variant data type");

    _pnumber->set_number(row, num);
}

Here is the call graph for this function:

void OCIPL::SqlVariantArray::set_string ( int  row,
const TCHAR *  str 
)

Definition at line 1704 of file ocipl.cpp.

References _data_type, _pstring, OCIPL::SqlStringArray::assign(), and THROW_OCI_EXCEPTION.

{
    if (_data_type != OCI_TYPECODE_VARCHAR)
        THROW_OCI_EXCEPTION("invalid variant data type");

    _pstring->assign(row, str);
}

Here is the call graph for this function:

SqlDateTime OCIPL::SqlVariantArray::sql_date ( int  row,
OCIError *  errh 
) const

Definition at line 1790 of file ocipl.cpp.

References _data_type, _psql_date, OCIPL::SqlDateTimeArray::get_ref(), OCIPL::SqlIndArray::is_not_null(), and THROW_OCI_EXCEPTION.

{
    switch(_data_type) {
      case 0:
        return SqlDateTime();

/*@@todo convert type
      case OCI_TYPECODE_VARCHAR:
        return SqlDateTime(errh, *_string);

      case OCI_TYPECODE_DATE:
        return *_oci_date;
*/
#if ORACLE_VERSION>=81
      case OCI_TYPECODE_TIME:
      case OCI_TYPECODE_TIMESTAMP:
        if (_psql_date->is_not_null(row))
            return *_psql_date->get_ref(row);
        else
            return SqlDateTime();
#endif

      default:
        THROW_OCI_EXCEPTION("no conversion to date");
        //return SqlDateTime(); // not reached
    }
}

Here is the call graph for this function:

tstring OCIPL::SqlVariantArray::str ( int  row,
OCIError *  errh 
) const

Definition at line 1637 of file ocipl.cpp.

References _data_type, _pnumber, _poci_date, _psql_date, _pstring, _stprintf, OCIPL::SqlStringArray::c_str(), COUNTOF, OCIPL::SqlDateTimeArray::str(), OCIPL::OciDateArray::str(), OCIPL::SqlNumberArray::str(), TCHAR, and TEXT.

{
#ifdef SQLT_BFLOAT
    TCHAR buffer[16];
#endif

    switch(_data_type) {
      case 0:
        return TEXT("");

      case OCI_TYPECODE_VARCHAR:
        return _pstring->c_str(row);
//      return *_string;

      case OCI_TYPECODE_NUMBER:
        return _pnumber->str(row, errh);

#ifdef SQLT_BFLOAT
      case OCI_TYPECODE_BFLOAT:
#ifdef __STDC_WANT_SECURE_LIB__
        _stprintf_s(buffer, COUNTOF(buffer),
#else
        _stprintf(buffer,
#endif
        TEXT("%f"), _pfloat[row]);
        return buffer;

      case OCI_TYPECODE_BDOUBLE:
#ifdef __STDC_WANT_SECURE_LIB__
        _stprintf_s(buffer, COUNTOF(buffer),
#else
        _stprintf(buffer,
#endif
        TEXT("%f"), _pdouble[row]);
        return buffer;
#endif

      case OCI_TYPECODE_DATE:
        return _poci_date->str(row);

#if ORACLE_VERSION>=81
      case OCI_TYPECODE_TIME:
      case OCI_TYPECODE_TIMESTAMP:
        return _psql_date->str(row);
#endif
/*
      case OCI_TYPECODE_BLOB:
        return TEXT("(BLOB)");

      case OCI_TYPECODE_BFILE:
        return TEXT("(BFILE)");

      case OCI_TYPECODE_CLOB:
        return TEXT("(CLOB)");

      case OCI_TYPECODE_CFILE:
        return TEXT("(CFILE)");
*/
      case SQLT_LNG:
        return _pstring->c_str(row);    //@@

      default:
        assert(0);
        return TEXT("");
    }
}

Here is the call graph for this function:


Member Data Documentation

union { ... } [protected]

Definition at line 3516 of file ocipl.h.

Definition at line 3523 of file ocipl.h.

Referenced by assign(), and clear().


The documentation for this struct was generated from the following files: