how to get a columns as NUMBER(30) [message #340711] |
Wed, 13 August 2008 21:10 |
mark.quxiao
Messages: 1 Registered: August 2008
|
Junior Member |
|
|
in my oci applications,if i get a column of number that is in the scope of int,i can use value = *(int *)field.data; get the value,but if the column size is larger than 10,the code can't be available,how can i get the value,thanks
|
|
|
|
|
|
Re: how to get a columns as NUMBER(30) [message #341111 is a reply to message #341108] |
Sat, 16 August 2008 10:22 |
vicenzo
Messages: 28 Registered: December 2007 Location: Paris
|
Junior Member |
|
|
As I said before, you have OCINumber and SQLT_VNU.
Here is an extract from an answer i've made in the OCI Oracle for a similar question :
Quote: | SQLT_INT or SQLT_UIN are limited to 32bits integers.
To use 64bits integers, the C type is long long and unsigned long long.
The only way i found in order to manipualte 64bits integer properly is using OCINumber.
By example in order to define an output placeholder to get data from an number(20) column, you have to :
* define using SQLT_VNU with size = sizeof(OCINumber)
* fetch
* then the buffer is an OCINumber
* use OCINumberToInt() with the sizeof(long long) for rsl_lenght parameter
* then you've got a correct value
You can use as well OCINumberSign() before calling OCINumberToInt() to find out if the value is signed or not, then you pass an unsigned long long or signed long long to OCINumberToInt()
What i said for defining works as well for binding.
Binding 64 bits integers can only be done using SQLT_VNU and OCINumber...
* bind using SQLT_VNU with size = sizeof(OCINumber) and pass the adress of an OCINumber placeholder
* Use OCINumberFromInt() with the sizeof(long long) for rsl_lenght parameter
* Execute
* then you've got a correct value into DB
|
|
|
|
|
Re: how to get a columns as NUMBER(30) [message #341116 is a reply to message #341115] |
Sat, 16 August 2008 10:51 |
vicenzo
Messages: 28 Registered: December 2007 Location: Paris
|
Junior Member |
|
|
hi Michel,
Sorry for my 'direct' answer...
I just wanted to give more details about my previous post.
Your links were good
btw, handling all types of integers from short to long long, including signed and unsigned is always a bit tricky with OCI.
That's why with OCILIB, all of these is handled 'behind the scene' and you don't have to care about it.
You just have to get the data through the type you want.
Regards,
Vincent
[Updated on: Sat, 16 August 2008 10:52] Report message to a moderator
|
|
|