Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Oracle Server > OCI - Best way ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 16658 of 17418
Post > Topic >>

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

by yojrod@[EMAIL PROTECTED] Jun 2, 2008 at 02:17 PM

Info:
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);
	arrayindex++;
	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 s****adically (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.
 




 1 Posts in Topic:
OCI - Best way to retrieve NUMBER(20) values?
yojrod@[EMAIL PROTECTED]   2008-06-02 14:17:20 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 1:21:46 CST 2008.