Re: using host arrays in PRO*C

From: Tommy Wareing <p0070621_at_brookes.ac.uk>
Date: 1995/08/16
Message-ID: <40sbs6$io8_at_cs3.brookes.ac.uk>#1/1


In article <40qp9l$l35_at_homer.alpha.net>, Saad Ahmad says...
>
>Shneor Berezin (sber_at_netcom.com) wrote:
>> I wonder how the dimension of host arrays in PRO*C is determined by Oracle.
>> Looking at the generated C code, only the address of the array is being
>> passed to sqlcex.
>> The dummy at Oracle technical support told me, that this is proprietary
>> information and I don't need to know. Unbelievable!!!
>> Personally, I don't know of any reliable way of determining the size of
>> an array allocated on the heap. Has anybody tried to use a host array
>> allocated on the heap? Would it help if I use a FOR clause?
>
>*probably* by using the sizeof feature of the compiler. That is
>how charater arrays (strings) are processed .. and that is no
>propriety info since oralce manuals tell that.

Yes, we have no brain, we have no brain today...

If sizeof were being being used, this would be very obvious in the c code.

The number of iterations to perform is controlled by the variable sqlstm.iters, which is set explicitly when a fetch is performed (before sqlcex is called). The value used is determined by the pre-compiler when it builds its list of host variables, or can be set by using the FOR clause in the sql statement.

Shneor, what do you mean by 'an array allocated on the heap?'.

If this is a normal array, as declared by int array[10]; then the pre-compiler determines it's size by examining the thing in [] and gets the answer 10 (this is why PRO*C v.1 can't handle pre-processor variables). You can get the number of elements by using sizeof(array)/sizeof(array[0]). In this case, you don't need to use the FOR clause.

If you mean that the space has been allocated by using malloc, then you don't have an array, you have a pointer. There is no way of after the event of determining the amount of space allocated (without intimate knowledge of your malloc package), so it is up to the programmer to record this. In this case, you can use the FOR clause very effectively.

-- 
 _________________________   __________________________________________
/  Tommy Wareing          \ /  I've been looking for an original sin,  \
|  p0070621_at_brookes.ac.uk  X   One with a twist and a bit of a spin    |
\  0865-483389            / \     -- Pandora's Box, Jim Steinman       /
 ~~~~~~~~~~~~~~~~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Received on Wed Aug 16 1995 - 00:00:00 CEST

Original text of this message