Advertisement

02.06.2008 at 11:06AM PST, ID: 23142284
[x]
Attachment Details

implement iterator layer around Pro*C embedded SQL (PL/SQL)

Asked by Infinity08 in PL / SQL, Oracle Database, C++ Programming Language

Tags: Oracle, Pro*C, PL/SQL, C++

Background : I'm trying to implement a C++ STL iterator like layer around Pro*C embedded SQL (PL/SQL). Basically, I'll need something like these methods :

        int select_init(string sql_cmd) {
            EXEC SQL DECLARE cur1 CURSOR FOR ...;
            EXEC SQL OPEN cur1;
        }

        int select_get(ResultType &result) {
            EXEC SQL FETCH cur1 INTO ...;
        }

        int select_close() {
            EXEC SQL CLOSE cur1;
        }

which would then be called in order for a given SQL request.

Called like this, there's no problem :

        select_init(cmd);
        while (select_get(res)) {
            // do something with res
        }
        select_close();

But what if I call a second select_init, before the select_close was called for the first ?

        select_init(cmd1);
        select_init(cmd2);

        // some more code

        select_close();
        select_close();

The problem is that two cursors are now opened with the same identifier (cur1). That won't work like this afaik.


Now, finally on to my questions :

1) has something like this already been done, and where can I find it ?
2) is my approach good, or would you do it differently ?
3) if my approach is good, how do I solve the described problem ? Is there a way to get different cursor id's for subsequent calls to select_open ?


I tried to be as brief as possible in my question, so if I left anything important out, please let me know :)Start Free Trial
 
Keywords: implement iterator layer around Pro*C …
 
Loading Advertisement...
 
[+][-]02.06.2008 at 10:40PM PST, ID: 20838722

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PL / SQL, Oracle Database, C++ Programming Language
Tags: Oracle, Pro*C, PL/SQL, C++
Sign Up Now!
Solution Provided By: sdstuber
Participating Experts: 1
Solution Grade: A
 
 
[+][-]02.06.2008 at 11:43PM PST, ID: 20838929

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.07.2008 at 08:36AM PST, ID: 20842278

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02.07.2008 at 09:19AM PST, ID: 20842721

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.07.2008 at 09:55AM PST, ID: 20843097

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.07.2008 at 11:02AM PST, ID: 20843854

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906