TO_CHAR returns zeroes for DATE columns filled via OCI
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():
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():
0