Garayed.com  

Go Back   Garayed.com > Oracle
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-02-2008, 09:17 PM
yojrod@gmail.com
 
Posts: n/a
Default OCI - Best way to retrieve NUMBER(20) values?

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:42 PM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.