Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tough C++/Oracle Question...

Status
Not open for further replies.

DCCoolBreeze

Programmer
Jul 25, 2001
208
US
1. I have a table in Oracle that contains a NUMERIC field
2. I INSERT the variable unsigned long long llValue[3] into
the numeric field by INSERT ....
Values(llValue[0] | llValue[1] | llValue[2]);
This works great...

Now the problem...
How can I read this variable back into the array? I have tried several things without success. I have tried char strings, byte strings, the array and structures. I am beginning to believe that it can not be done...

Anyone out there know who to do this??
 
Hi,
what value does

(llValue[0] | llValue[1] | llValue[2])

actually store in the database? If this is a C value you are Actually BITWISE OR'ing the values. this means if you have

1 2 4 the value you store is 7

but take the values

1 2 3 the value you store is 3

3 0 0 The value you store is 3

3 3 3 the Value you store is 3

How can you then take the value from the database (3 in this example) and try to convert it back to the orginal 3 values? There are too many combinations which resolve to the BIT pattern 3.

Now maybe if llvalue[x] is always < 255 you could do something like.....

((lvalue[0] << 16) | (lvalue[1] << 8) | lvalue[2])

then you could get the values back out by

sel numfield from table;

lvalue[0] = ( numfield >> 16) % 256
lvalue[1] = (numfield >> 8) % 256
lvalue[2] = (numfield %256)
 
Sorry. I made a mistake on the statement
(llValue[0] | llValue[1] | llValue[2])
It is actually
:)llValue[0] || :llValue[1] || :llValue[2])

This is oracles way of concatenating values so in memory you would see this

llValue[0]llValue[1]llValue[2] ==> which equals 192-bit value in my case.

I am getting the error
ORA-01455: converting column overflows integer datatype

As I research this it looks like it might be a bug in Oracle. I am using 8.1.7.2

 
I understand the insert I did better now. I thought that the value[0] || value[1] || ... would actually concatenate the bytes of value [0] and value[1]...for example.

value[0] = 1
value[1] = 2
value = hex 0x0201 = 513
This is not the case. The value saved in to field is 12.

I need to save a 128+bit value to a NUMERIC field and them extract it.
 
Re-create the original array , including the recalcitrant value now in the Record
that makes up the array
G_ Luck!
Galileean_USA96@HOtmail.Com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top