Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Pro*C/C++ - How do I OPEN CURSOR and FETCH in different fucntions

Re: Pro*C/C++ - How do I OPEN CURSOR and FETCH in different fucntions

From: matt mcConnell <matt_at_ksd-intl.com>
Date: 2000/05/29
Message-ID: <39325275@212.18.160.197>#1/1

Yes, you can declare a cursor globally - all of Oracle's ProC example programs do it, in fact I think ProC sort of treats them globally even if they aren't declared as such.

I don't really understand what your two problems are - your SELECT is complex and hard to follow? I don't think you can easily break up a single select, though I guess you could make some smaller selects, store the data, and combine it yourself, but it doesn't seem worth the effort. Or, you can create the statement dynamically adding on several pieces building something complex from simple parts.

The program uses a lot of memory? Well, you can always reduce the amount by creating references to data instead of copying it but it all depends on your application.

In my experience, ProC makes you use statically allocated memory in a lot of situations and generally is pretty flaky about memory management. In some cases it wouldn't let me split things (like OPENs and FETCHes) into separate functions and I ended up with some pretty ugly stuff. I don't know what the solution is - perhaps if developers complain enough, Oracle will start testing its products before releasing them.

Good luck,

matt

---
The real problem is entropy.

"John Ralph" <cwrmusic_at_erols.com> wrote in message
news:39306B61.FCD57FBB_at_erols.com...

> I'm not sure about ProC, but if you were doing this in PL/SQL, you would
> just put the
> functions in the same package and declare the cursor global to the
> package.
>
> There is probably an analogous way to do this in ProC
>
> FWIW.
>
> Don Chambers wrote:
>
> > I am using Pro*C/C++ and need to have a function that sets up a cursor
> > and opens it but I do not need to fetch at this time. I need to fetch
> > from another function. How do I fetch in one function using a cursor
> > declared and opened in another function?
> > Is in possible to declare a cursor globally or as a member of a class?
> >
> > This is what I am trying to do. If you have a better idea let me
> > know.
> > I am creating a class for other developers in which they issue a
> > select statement and then move through the rows with a MoveNext
> > function which sets variables to the data selected. I currently have
> > the open and fetch in the same function and I load up a linked list
> > with all the data. My MoveNext function iterates through the list and
> > sets variables to the current items in the list. On the next MoveNext
> > call I move to the next element in the list. This causes two
> > problems:
> > 1) My Select fucntion is huge and hard to follow becasue all the
> > descriptor information (for dynamic SQL), the cursor logic, and the
> > linked list logic. If I keep this method I would at least like to
> > break it into multiple functions but am having problems becasue the
> > cursor can only be fetched in the function in which it is declared.
> > 2) On selects with many columns and rows the linked list grows
> > huge and consumes much memory. As the user iterates thorugh the list
> > and stores the values in other ways (an Array, Container, or their own
> > list) this doubles the amount of memory used.
> >
> >
> > Thanks,
> > Don
> > chambers_at_inquiregroup.com
>
Received on Mon May 29 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US