Using Host Arrays with Dynamic SQL Method 4

From: <bk768_at_my-dejanews.com>
Date: Wed, 11 Nov 1998 17:25:13 GMT
Message-ID: <72ch9q$v9j$1_at_nnrp1.dejanews.com>



Hi! Has anyone had problems when trying to use host arrays with dynamic SQL method 4? The following scenario seems to strike me as a major shortcoming to using method 4 with host arrays...

I am currently writing a program that INSERTs multiple rows of data at a time into a table where the number of columns are unknown until runtime. Descriptor entries are thus made for V[i] to the host array address and L[i] to the size of each element within the host array.

The problem is when I want to insert host arrays of char *s. The pro*C/C++ compiler seems to expect the creation of a 2D array (ie char blah[10][20]) that is statically declared and thus is allocated as sequential units in memory. This poses a problem if the number of columns I expect to insert is indeterminate until runtime because dynamically allocated 2D arrays are not sequential in memory (an array of char *s pointing to an array of chars). This seems to defeat the entire point of dynamic SQL method 4 since the number of statically declared 2D arrays needs to be determined at precompile time!

The oracle manuals have an example of this shortly before it's listing of sample10.pc. Unfortunately, it still illustrates the same shortcoming: the number of 2D arrays have been locally declared off the stack at compile time even though the SQL statement itself is dynamically created at runtime.

The only workaround I can think of is if the V[i] descriptor entry treats a malloced array of chars in the same manner as a statically declared two dimensional array of chars. In other words, if:

char blah[10][20] (stack) = char blah[200] (heap)?

Does the descriptor entry V[i] treat those two host arrays as functionally equivalent?

Any feedback is greatly appreciated.
-bk

[Quoted] -----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Wed Nov 11 1998 - 18:25:13 CET

Original text of this message