IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

COBOL/DB2 Stored Procedure


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mad_guy
Currently Banned

New User


Joined: 15 Jan 2010
Posts: 31
Location: India/UK

PostPosted: Fri Jan 15, 2010 11:37 pm
Reply with quote

My requirements are:

java front end will call the stored procedure and the COBOL-DB2 stored procedure will select (more than 10000 rows), insert ,update or delete in DB2 table.

I have some basic questions:

1) How DB2 stored procedure will get linked with the cobol program?
2) If I want to run the whole process on the mainframe only, how to do?
3) How to fetch the multiple records by stored procedure and COBOL program? In the case of running the whole process on the mainframe where to get the output?
4) How to call? Do I need to call the stored procedure, and then that will call the corresponding COBOL program? or else how?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Jan 16, 2010 12:44 am
Reply with quote

Hello,

See if the SP links in this topic (provided by DBZ) help you:

ibmmainframes.com/viewtopic.php?t=44950
Back to top
View user's profile Send private message
ajeshrn

New User


Joined: 25 Mar 2009
Posts: 78
Location: India

PostPosted: Mon Jan 18, 2010 4:18 pm
Reply with quote

1)How DB2 stored procedure will get linked with the cobol program?

This is possible.
U should create a DB2 stored procedure, this DB2 procedure will have the create procedure ddl statements along with the input and output parameters declared. This procedure should intern call a COBOL program.In my shop we used to call it SL1 and SPS components. Ths SL1 component will have the declarations, which will be internally passing the values to the SPS component, which is actually a COBOL-DB2 program.
Language should be COBOL instead of SQL


2)If I want to run the whole process on the mainframe only, how to do?

If you want to run the whole process means, do u want to test the COBOL-DB2 stored procedure? If so we have tools like Stored Procedure builder. Else you can even check the same by coding a cobol program which internally calls the stored procedure. You should use Allocate and associate cursors to fetch the results.


3)How to fetch the multiple records by stored procedure and COBOL program? In the case of running the whole process on the mainframe where to get the output?

In case you are trying to display them in the Web screens, then as I said before you have to code the SL1, SPS components. In the SPS you have to open a cursor and leave the same open.No need to fetch. Now from your web technology , you need to get the resultsets and show them in the screen. If you are trying to show thenm in the cobol sysouts, you have to use allocate and associate cursors and iterate them using the cobol program and display in sysout or write them into a file.

4)How to call? Do I need to call the stored procedure, and then that will call the corresponding COBOL program? or else how?

As of I know, you just need to call the stored procedure(SL1). That internally will invoke the SPS component. Both SL1 and SPS will have the same name.
Back to top
View user's profile Send private message
mad_guy
Currently Banned

New User


Joined: 15 Jan 2010
Posts: 31
Location: India/UK

PostPosted: Wed Jan 27, 2010 8:50 pm
Reply with quote

Hi... how do I call a store proc from another batch cobol program in mainframe?
I have staged the store proc source (in my shop its called SRR) in CHANGEMAN... and created the store proc in DB2 region.
Now I am trying to call the store proc from another cobol progrm:- like this:-
EXEC SQL
CALL ADDD5.ADDD5UPD.SKL_CANCEL_AUDIT( :WS-AUD-ID
,:WS-RETURN-TYPE
,:WS-ERROR-CODE
,:WS-ERROR-DESC
)
END-EXEC.

but I m getting -922 (authorisation error)
in JCL i m only mentioning the calling cobol program like this:--
//SYSTSIN DD *
DSN SYSTEM(DSND)
RUN PROGRAM(CALLSTP) PLAN(ADDD5BAT)
END
/*
but I m getting -922 (authorisation error)
Pls help.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jan 27, 2010 9:35 pm
Reply with quote

Hello,

You need to talk with your manager or the security people to have your id given the needed permission(s).
Back to top
View user's profile Send private message
mad_guy
Currently Banned

New User


Joined: 15 Jan 2010
Posts: 31
Location: India/UK

PostPosted: Wed Jan 27, 2010 9:52 pm
Reply with quote

I have been given the permission to the particular db2 region and create privilege, but still getting the error.
Could you pls tell me the procedure to execute a store proc calling from batch COBOL?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jan 27, 2010 10:05 pm
Reply with quote

Hello,

Quote:
I have been given the permission to the particular db2 region and create privilege,
Either the permissions granted were not complete or you are specifying something that you do not have permission to access.

You need to resolve the permission problem(s) and only someone on your system can help with this. . .
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Thu Jan 28, 2010 2:03 am
Reply with quote

Once you get your permission worked out...

In our shop, the actual logic of the SP is nothing more than a Cobol-DB2 program.

The creation of the SP within the DB2 region (workoad manager) is for non-mainframe access.

If we want to call the same logic from the mainframe, we simply call it like any other cobol-db2 subroutine.

I hope this helps you out....
Back to top
View user's profile Send private message
ajeshrn

New User


Joined: 25 Mar 2009
Posts: 78
Location: India

PostPosted: Thu Jan 28, 2010 5:52 pm
Reply with quote

Hi mad_guy,

Can you please let us know the steps you followed after creating the procedure. Have you registered the stored Procedure, ie did u execute the create procedure statement. Also the GRANT access should be given for the procedure.

Just give a try calling the procedure like

EXEC SQL
CALL SYSPROC.<Stored Procedure Name>( :WS-AUD-ID
,:WS-RETURN-TYPE
,:WS-ERROR-CODE
,:WS-ERROR-DESC
)
END-EXEC.
Back to top
View user's profile Send private message
mad_guy
Currently Banned

New User


Joined: 15 Jan 2010
Posts: 31
Location: India/UK

PostPosted: Fri Jan 29, 2010 3:15 pm
Reply with quote

Thanks every one..
Finally.. I am able to see the store proc running...from another batch cobol...
now..lets see..how its work..while java invoke the stored proc..and reurn result sets...
java team is not ready yet...so..have enough time..
Thanks again...to dick scherrer,ajeshrn, daveporcelan...
I will be needing ur help..in near future also....
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Jan 29, 2010 8:09 pm
Reply with quote

Good to hear there is progress icon_smile.gif

Someone will be here when there are more "opportunities". . .

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top