OCI - Best way to retrieve NUMBER(20) values?

From: <yojrod_at_gmail.com>
Date: Mon, 2 Jun 2008 14:17:20 -0700 (PDT)
Message-ID: <aa6869b3-f478-42a8-9f59-4604b3532a4f@2g2000hsn.googlegroups.com>

Windows XP Pro SP2
Oracle 10G Express Edition
V8 Oracle Call Interface (OCI)
MSVC 8.0 I have a table that has a value column of type NUMBER(20). This column holds unsigned 64 bit integers. However, I have had some trouble retrieving these values using OCI. I need to have these values as unsigned __int64 in order to use them in my application.

Attempt 1: I have tried using rset->getNumber().

char cstr[2048];
unsigned __int64 * FVecList; // properly malloced

while (rset->next ())

	Number num = rset->getNumber(1);
	// I'm actually quite stuck here. I'm not sure how to convert the
"data" of the Number object to unsigned __int64.
	// The Number object seems to have methods for a variety of data
types, but not unsigned 64 bit integers. }

Attempt 2: I have tried selecting data from this column with to_char(value) and then using rset->getString():

char cstr[2048];
unsigned __int64 * FVecList; // properly malloced

while (rset->next ())

	string * currStr = new string(rset->getString(1));
	strcpy(cstr, currStr->c_str());
	FVecList[arrayindex] = _strtoui64(cstr, NULL, 10);
	delete currStr; // this causes crashes


This works as intended. However, task mananger indicates a significant memory leak because 1) I can't confidently delete currStr without having my application crash sporadically (not sure why, deleting objects is pretty trivial), and 2) rset->getString() seems to allocate memory as well (why, I don't know, and I don't know how to deallocate it).

Any help is appreciated or recommendations welcome on the best way to read this data.

Thanks in advance. Received on Mon Jun 02 2008 - 16:17:20 CDT

Original text of this message