Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle's OLE DB/OValue/C++

Re: Oracle's OLE DB/OValue/C++

From: Boris Bunjan <boris.bunjan_at_zg.hinet.hr>
Date: Sat, 21 Jul 2001 21:32:31 GMT
Message-ID: <9ijlt4$em3p$1@as201.hinet.hr>

"steven" <rgc_at_newsguy.com> wrote in message news:rccqktsf7hht1svpdjkpt92a646gq7ftud_at_4ax.com...
> I am reading fields in an Oracle Table using Oracle's OLE DB/C++
> oracl.h that are of VARCHAR2(30). I have read the first 4 fields just
> fine, but the fifth field errors when i try to convert it to a string.
> Most of the data is like '10 FEB 2001' the rest are blank. The project
> is a ISAPI Extension.
>
> OValue vmyDate;
> string smyDate;
> omyTable.GetFieldValue("MYDATE", &vmyDate);
> smyDate = vmyDate;
>
> IsNull is TRUE for all rows including those that have data, the other
> fields that are populated are not NULL.
>
> Any Ideas?
> steven

smyDate = vmyDate; is effectivly smyDate = (const char*)vmyDate; and (const char*)vmyDate returns C++ NULL pointer for database null values, and you end up with
smyDate = (const char*)NULL; whitch will throw exception.

So you'll have to test value for null, something like smyDate = (vmyDate.IsNull() ? "" : (const char*)vmyDate); or use try-catch mechanism.

BTW. You're using Oracle Objects for OLE, not OLEDB

Regards,
Boris Received on Sat Jul 21 2001 - 16:32:31 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US