Cobol and Oracle HELPPP 
Author Message
 Cobol and Oracle HELPPP

Hi,

I am using oracle and cobol. In my cobol program I declare
a cursor like this

Program A;

 Exec Sql
    declare my_curs cursor
    for select from my_tabel
 End Sql.

Somewhere in my program I want to call another program
like this
 call "progb"

In program B I want to make use of the cursor
which is declared in program A. So how do I
pass the information about the open cursor
from program A to program B

Thanks a lot




Sun, 11 Nov 2001 03:00:00 GMT  
 Cobol and Oracle HELPPP


Quote:
> Hi,

> I am using oracle and cobol. In my cobol program I declare
> a cursor like this

> Program A;

>  Exec Sql
>     declare my_curs cursor
>     for select from my_tabel
>  End Sql.

> Somewhere in my program I want to call another program
> like this
>  call "progb"

> In program B I want to make use of the cursor
> which is declared in program A. So how do I
> pass the information about the open cursor
> from program A to program B

I have not tried it, but I note that the DECLARE CURSOR ends up as all
comments when pre-compiled - so it's not an issue.  I see no reason
why you can't just reference the cursor in the called program - if
statically linked.  Unless the pre-compiler complains that the cursor
is not opened or something!

You can use a WHERE clause to operation on the current cursor rows by
using:

CURRENT OF cursorname

Does any of this help?

-------------------------
Trust the computer industry to shorten "Year 2000" to Y2K.  It was
this
kind of thinking that caused the problem in the first place.

Try a better search engine: http://www.google.com

Visit my updated website at
http://www.geocities.com/Eureka/2006/



Sun, 11 Nov 2001 03:00:00 GMT  
 Cobol and Oracle HELPPP
Johan,

There is a really good Murach book (the author is Eckols) on COBOL/DB2 -
most everything that applies to DB2 SQL applies to Oracle SQL.  Anyhow,
you might rephrase your topic as COBOL/SQL help - I tried to fish for
others who are using COBOL/Oracle and there weren't any responses.  I
really good DB2 programmer can probably help you.

Back to your question:
If you just need the cursor declaration, I think you can make your
cursor declaration an included member (similar to a copybook) and
INCLUDE it in both program A and program B.

EXEC SQL
  INCLUDE whatever
END-EXEC

If you need information that has been determined by program A (i.e.,
some value that it has accepted or some flag that has been set), you
need to pass the information to program B the same way you would pass
variables to another called program.  There are a few ways to do this,
but I'll assume that you know how to do this.  

Matt



Sun, 11 Nov 2001 03:00:00 GMT  
 Cobol and Oracle HELPPP

Quote:

> I have not tried it, but I note that the DECLARE CURSOR ends up as all
> comments when pre-compiled - so it's not an issue.  I see no reason
> why you can't just reference the cursor in the called program - if
> statically linked.  Unless the pre-compiler complains that the cursor
> is not opened or something!

How does the precompiler know what to replace for the fetch?  You
would need some magic to actually get the cursor identifier into
the subprogram and then call it there.

Johan,

Already suggested is the INCLUDE (declare the cursor twice).
Another solution is Dynamic SQL  the interface is not compiled out
of the code and therefore you might have something to pass around.

I strongly recommend a redesign though.  Encapsulation says that
the data access should be exclusive to a single routine not
scattered.

Ken



Mon, 12 Nov 2001 03:00:00 GMT  
 Cobol and Oracle HELPPP


Quote:

>> I have not tried it, but I note that the DECLARE CURSOR ends up as all
>> comments when pre-compiled - so it's not an issue.  I see no reason
>> why you can't just reference the cursor in the called program - if
>> statically linked.  Unless the pre-compiler complains that the cursor
>> is not opened or something!

>How does the precompiler know what to replace for the fetch?  You
>would need some magic to actually get the cursor identifier into
>the subprogram and then call it there.

>Johan,

>Already suggested is the INCLUDE (declare the cursor twice).
>Another solution is Dynamic SQL  the interface is not compiled out
>of the code and therefore you might have something to pass around.

Declaring the cursor in the sub program should do it.  Remember the
DECLARE gets precompiled to comments, so it won't hurt to have it in
both places - but I still don't know if it will actually work - I have
not tried it.


Tue, 13 Nov 2001 03:00:00 GMT  
 Cobol and Oracle HELPPP
You should try Host variables when passing variables from one program to
another.

you 'll have your declare statement:

Exec sql
 declare whatever cursor
end exec

your fetch statement:
exec sql

fetch whatwver into

:wk-host-var-1
:wk-host-var-2
etc

end exec

after, all you have to do is to pass your host variables to your calling
program:

cal prg-b using wk-grp-host-variable

maybe there are better ways to do this but this one woks for sure.

Carefull with those host variables. You should read your Oracle manual
to know all about them.

Hope this help

jr Duval


Johan den Boer a crit :

Quote:
> Hi,

> I am using oracle and cobol. In my cobol program I declare
> a cursor like this

> Program A;

>  Exec Sql
>     declare my_curs cursor
>     for select from my_tabel
>  End Sql.

> Somewhere in my program I want to call another program
> like this
>  call "progb"

> In program B I want to make use of the cursor
> which is declared in program A. So how do I
> pass the information about the open cursor
> from program A to program B

> Thanks a lot





Thu, 15 Nov 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. HELPPP ! I need Clarion 5b patch

2. helppp

3. Skills Needed: UNIX-C, COBOL/BAL, IMS DBA, IMS, DB2 DBA, Oracle DBA, Smalltalk

4. ORACLE-COBOL-ACCESS-VISUAL BASIC-FORTRAN

5. IMS-DB/DC, DB2, COBOL, ORACLE, ACCESS, VISUAL VASIC, UNIX

6. Linking / debugging with MicroFocus NetExpress and Oracle Pro*COBOL

7. MF - Cobol to Oracle HOW, what ways? (migration)

8. Microfocus Cobol + Oracle

9. IBM COBOL for AIX and Oracle

10. Oracle/COBOL/Linux

11. PRO*cobol for linux oracle

12. Fujitsu COBOL on Sun Solaris with Oracle 8i

 

 
Powered by phpBB® Forum Software