Home » Developer & Programmer » Precompilers, OCI & OCCI » how to get a columns as NUMBER(30) (oracle oci windows)
how to get a columns as NUMBER(30) [message #340711] Wed, 13 August 2008 21:10 Go to next message
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 #340719 is a reply to message #340711] Wed, 13 August 2008 23:57 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
If the column size is larger than 10 then it is not an integer in the scope of int. Use "long long".

Regards
Michel
Re: how to get a columns as NUMBER(30) [message #341091 is a reply to message #340719] Sat, 16 August 2008 05:37 Go to previous messageGo to next message
vicenzo
Messages: 28
Registered: December 2007
Location: Paris
Junior Member
OCI does not support 64bits integer binds with SQLT_INT, SQLT_UINT or SQLT_NUM...

You have to use OCINumber type and SQLT_VNU code to get it work right
Re: how to get a columns as NUMBER(30) [message #341108 is a reply to message #341091] Sat, 16 August 2008 09:49 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Metalink notes:
702778.994 Inserting a Number larger than 4 bytes (32 bits)
609767.992 How to Bind a 64 Bit Integer in OCI

Regards
Michel
Re: how to get a columns as NUMBER(30) [message #341111 is a reply to message #341108] Sat, 16 August 2008 10:22 Go to previous messageGo to next message
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 #341115 is a reply to message #341111] Sat, 16 August 2008 10:42 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I did not refute what you said, I just gave some notes that give examples of how to workaround this including one that follows the way you said.

Regards
Michel
Re: how to get a columns as NUMBER(30) [message #341116 is a reply to message #341115] Sat, 16 August 2008 10:51 Go to previous message
vicenzo
Messages: 28
Registered: December 2007
Location: Paris
Junior Member
hi Michel,

Sorry for my 'direct' answer... Embarassed

I just wanted to give more details about my previous post.

Your links were good Smile

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

Previous Topic: Connectivity between C and Oracle
Next Topic: ProC Host Variables as global
Goto Forum:
  


Current Time: Sat Dec 03 08:23:54 CST 2016

Total time taken to generate the page: 0.04928 seconds