Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: OpenESQL and EXEC ADO

$
0
0

Hi Ahmet,

I am assuming that the code posted here is the version that works correctly because the cursor names are different in each paragraph, is that correct?

Cursor names must be unique within a program. In fact if you declare a cursor with the same name more than once then you should get an error from the precompiler ES0100-Duplicate cursor name.

The precompiler goes through the source code looking for blocks of code between EXEC SQL and END-EXEC and it does not take into account the logic of your evaluate statements.

If you want to define a cursor once and then reference it using different select statements then you would need to use dynamic sql.

Example:

   exec sql
       declare customerscursor dataset cursor for stmt1
   end-exec

all-customers.

    move "select customer_id, customer_name, country from customer" to prep
    exec sql
       prepare stmt1 from :prep
    end-exec

    exec sql
       open customerscursor
    end-exec
...

customers-by-country.

    move "select * from customer where country = ?" to prep

    exec sql
       prepare stmt1 from :prep
    end-exec

    exec sql
       open customerscursor using :report-term
    end-exec

...


Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>