Forum Stats

  • 3,769,909 Users
  • 2,253,029 Discussions


Describe timestamp column with OCIAttrGet

Can someone please help with this OCI call?

Using Oracle 11G (xe) on Linux 64bit (Fedora 21).  Using the OCI library to implicit describe the results after the select execution, and before the binding.

My question comes down to a confusing return value of OCIAttrGet when describing a timestamp(6) database column.  The code below for column.dataType is returning 187.  This confuses me greatly because I was assuming the results from these calls will correspond to the INTERNAL data type values described in Table 3-1 of the Programmers Reference.  187 isn't in the list.  I was rather expecting a value of 180 == TIMESTAMP.  187 is the value for EXTERNAL data types of a Timestamp; a value I would expect to use in the subsequent call to OCIDefineByPos if I want it bound to a OCIDateTime*.

So is the OCIAttrGet function returning the value of INTERNAL datatypes, or EXTERNAL datatypes?  To me, I don't see how it can possibly return external types because it doesn't yet know what I'm going to bind it to.

I haven't found a full example that clarifies things.

This probably seems trivial, but if I'm off on this, my whole understanding of that value is returned is called into question.

ub4 OracleDB::DescribeSelectResults(ColumnsMetaData & columnList)


/* Request a parameter descriptor for position 1 in the select list */

    ub4 counter = 1;

    int errcde;

    OCIParam * mypard = (OCIParam *) 0;


    errcde = OCIParamGet(stmthp, OCI_HTYPE_STMT, errhp,    reinterpret_cast<void**>(&mypard), counter);

        /* Loop only if a descriptor was successfully retrieved for

           current position, starting at 1


    while (errcde == OCI_SUCCESS)


        ColumnMetaData column;


        /* Retrieve the data type attribute */

        errcde =  OCIAttrGet(mypard, OCI_DTYPE_PARAM,

                    &column.dataType, 0,  OCI_ATTR_DATA_TYPE, errhp );

        if (errcde)

            HandleError (errcde);


        /* Retrieve the column name attribute */

        errcde = OCIAttrGet (mypard, OCI_DTYPE_PARAM, &column.columnName,


                             OCI_ATTR_NAME, errhp);

        if (errcde)

            HandleError (errcde);


This discussion has been closed.