dbTalk Databases Forums  

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

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss OCI - Best way to retrieve NUMBER(20) values? in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
yojrod@gmail.com
 
Posts: n/a

Default OCI - Best way to retrieve NUMBER(20) values? - 06-02-2008 , 04: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 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.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.