Re: OCI question

From: Tom Poindexter <tpoindex_at_nyx.cs.du.edu>
Date: 1996/08/05
Message-ID: <4u59ig$4kc_at_nyx.cs.du.edu>#1/1


In article <31fe3177.685147019_at_news.tncnet.com>, Simon Lee <simonl_at_dataworks.com> wrote:
>On 30 Jul 1996 00:32:02 GMT, surman_at_dlsun338.us.oracle.com (Scott
>Urman) wrote:

 [...]
>:Use odescr(). It will tell you exactly what Oracle is planning on returning -
>:each column, its datatype, and its size. You then allocate memory to hold this
>:info and point to it using odefin(). Then fetch using ofen() or ofetch().

[...]
>The problem I'm having is not how to get the info, but to figure out
>the most efficient way to allocate memory to store the info for a
>dynamic SQL query. If I get a statement like "select * from table", I
>don't know how many columns will be returned, so I don't know how much
>memory to allocate without doing a lot of little allocations. I could

You can take a look at my implementation of handling dynamic allocation in my Oratcl package, an Oracle extension for Tcl.

        ftp://ftp.neosoft.com/pub/tcl/NEW/oratcl-2.4b3.tar.gz

Oratcl builds a list of structures with allocations to hold the result columns. The array fetch (ofen) is then used to populate the bind columns. As far as effeciency goes, I don't think there are too many ways of doing it faster. Perhaps a fixed set of ColBufs (see the code), since there is an upper limit on the number of columns that can be returned, but that doesn't seem like a burning problem.

This code is designed to be used with Tcl, and also contains an experimental C interface (./oratcl-capi).

-- 
Tom Poindexter   
tpoindex_at_nyx.net
http://www.nyx.net/~tpoindex/
Received on Mon Aug 05 1996 - 00:00:00 CEST

Original text of this message