Precompilers and OCI (MOSC)

MOSC Banner

TO_CHAR returns zeroes for DATE columns filled via OCI

edited Apr 9, 2013 6:33AM in Precompilers and OCI (MOSC) 1 comment
A C++ program that uses OCI writes data to a column of type DATE NOT NULL. After this, a select via SQL*Plus yields the expected results. But "SELECT TO_CHAR(colname, 'YYYYMMDD') FROM tablename" returns only '00000000', whereas "SELECT TO_CHAR(TO_DATE(colname), 'YYYYMMDD') from tablename" shows the correct values.
The program calls OCIBindByPos() with parameters valuep = address of an OCIDate structure created with OCIDescriptorAlloc() (with descType = OCI_DTYPE_DATE), value_sz = sizeof(OCIDate*), dty = SQLT_DATE (btw: using dty = SQLT_ODT as described in the OCI Programmer's Guide results in a segmentation fault).

The OCIDate structure is filled using OCIDateSetDate():

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center