473,804 Members | 2,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

COBOL stored procedure

I am trying to learn how to use stored procedures written in COBOL so
I wrote 2 small programs to test it out: the stored procedure and the
the calling program. I have no problems compiling them but when the
calling program enters the SP, it either hangs or gives me sqlcode
-1131.

We are on AIX 5.2 (I think) running DB2 UDB ver 7.2 and MF COBOL 4.1.

Below are the programs I wrote:

Calling program (spcaller.sqb)
identification division.
program-id. spcaller.
environment division.
input-output section.
file-control.

working-storage section.
exec sql begin declare section end-exec.

01 work-area.
05 lnk-stored-proc pic x(12).
05 lnk-policy pic x(10).
05 lnk-plan pic x(3).

exec sql end declare section end-exec.

exec sql include sqlca end-exec.
exec sql include sqlda end-exec.

procedure division.
00000-main-rtn.

exec sql connect to noadmidb user dbmssi using dbmssi
end-exec
exec sql set schema dbipas end-exec
initialize work-area
accept lnk-policy from command-line
move "spprog" to lnk-stored-proc
display "calling spprog"
exec sql
call :lnk-stored-proc
(:lnk-policy, :lnk-plan)
end-exec
if sqlcode not= 0
display 'error in sp = ' sqlcode
else
display "policy number : " lnk-policy
display "plancode : " lnk-plan
end-if
exec sql connect reset end-exec
stop run.

The database name si "noadmidb" and the schema is "dbipas" but the
account running the program is "dbmssi". Our DBA says this account has
all privileges of the instance except for commands that alter the
database/tables such as DROP.

SP program: (spprog.cbl)
identification division.
program-id. spprog.
environment division.
input-output section.
file-control.

data division.
working-storage section.

linkage section.
01 lnk-policy pic x(10).
01 lnk-plan pic x(3).

procedure division using lnk-policy lnk-plan.
00000-main-rtn.

move "XXX" to lnk-plan
goback.

This used to be a little longer and had embedded SQL commands in it
but I removed them to try and figure out where the problem was.

I compiled the sp program using the commands:
cob -c -x spprog.cbl
cob -x -o spprog spprog.o -Q -bnoentry -Q -bE:noadmi.exp -Q -bI:
$DB2PATH/lib/db2g.imp -L$DB2PATH/lib -ldb2 -ldb2gmf

....and copied the executable file spprog to the $INSTHOME/sqllib/
function directory. I then prepped/bound/compiled the calling program
using the commands:
db2 prep spcaller.sqb bindfile target ibmcob
db2 bind spcaller.bnd
cob -c -x spcaller.cbl
cob -x -o spcaller spcaller.o -ldb2 -ldb2gmf -L$DB2PATH/lib

I also tried using "target mfcob" for db2 prep but with the same
results.

I then created the procedure with the CREATE PROCEDURE command as
follows:
db2 "create procedure dbipas.spprog (in policy char(10), out plan
char(3)) dynamic result sets 0 no sql language cobol external name
'spprog' parameter style general program type sub"

My co-worker also wrote a VB program to run the SP but it also hangs
when it tries to call it:
Option Explicit

Private Sub cmdOK_Click()
txtPlan.Text = ExecSP(txtPolNo .Text)
End Sub

Private Function ExecSP(ByVal sPolno As String) As String
Dim cmCallSP As Command
Dim parmSP As Parameter
Dim sSQLState As String
Dim g_sConnection As String

g_sConnection = "DSN=NONADMI;UI D=dbmssi;PWD=db mssi"
Screen.MousePoi nter = vbHourglass
Set cmCallSP = New Command
cmCallSP.Comman dText = "spprog"
cmCallSP.Comman dType = adCmdStoredProc
cmCallSP.Active Connection = g_sConnection

Set parmSP = cmCallSP.Create Parameter("poli cy", adChar,
adParamInput, 10, sPolno)
Call cmCallSP.Parame ters.Append(par mSP)
Set parmSP = cmCallSP.Create Parameter("plan ", adChar,
adParamOutput, 3)
Call cmCallSP.Parame ters.Append(par mSP)

cmCallSP.Execut e

ExecSP = cmCallSP.Parame ters("plan").Va lue
End Function

Can anyone tell me what I'm doing wrong? We have tons of COBOL
programs that I would like to use as stored procs so they can be
called by VB6 programs running on Windows XP or 2000.

Thanks in advance for your help.

Apr 3 '07 #1
0 5804

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5006
by: Thomasb | last post by:
Hi! In our company we have a huge amount of COBOL sub-routines that are called from other COBOL-programs. Now we are looking for a method to call them from Windows/Web applications. One idea is to wrap the sub-routine call in a DB2 stored procedure and call the procedure from our Web application.
2
1434
by: singlal | last post by:
Hi, my question was not getting any attention because it moved to 2nd page; so posting it again. Sorry for any inconvenience but I need to get it resolved fast. Need your help! **************************************************************************************************** Original Question: -------------------- Has anyone called a COBOL subroutine using COBOL CALL from a COBOL/DB2
1
5717
by: JLE | last post by:
I'm new to stored procedures, however, the passing of parameters using a group item in the calling cobol program seems incorrect to me. Would this work? Calling COBOL pgm is calling a stored procedure using a group 01 level and the receiving COBOL procedure has 01 levels for each parameter. Environment is z/OS, DB2, CICS, COBOL, LE. The procedure is local using WLM. DB2 version is 7.x and CICS is TS 2.2, I think.
0
2360
by: Springflower | last post by:
Hi, I am new to using DB2 Development Center. I had downloaded the trial version(8.2) of latest DB2 UDB and want to write a stored procedure in COBOL. When I chose the oprion the wrting a new stored procedure, it had given me the following two language options:
0
3497
by: bog39 | last post by:
We have z/os and DB/2 V. 8 running. I try to create a new UDF using the command CREATE FUNCTION: CREATE FUNCTION CNGETADR (INTEGER) RETURNS CHAR(50) EXTERNAL NAME CNADR001 PARAMETER STYLE DB2SQL WLM ENVIRONMENT WLMENV LANGUAGE COBOL DETERMINISTIC NO SQL NO DBINFO
0
2531
by: gtan | last post by:
How can I call a stored procedure when one of the parameters is a cursor? Shouldn't the COBOL code looks something like this? : EXEC SQL CALL CMQRACIN(<what do i place here?> :S-FINANCE-IN-DATA.ACCT-ID); END-EXEC By the way, the stored procedure looks like this:
4
3142
by: PJackson | last post by:
I have been given the task of taking a 3,200 line COBOL stored procedure and duplicating the same functionality in UDB 7.2 on the Windows platform with a procedural SQL stored procedure. I have fiddled with procedural SQL stored procs on UDB, but mostly short,trivial ones. Looking for good advice, links, etc. on the best approach to this. There doesn't seem to be the concept of subroutines within a stored proc, so I am guessing one main...
2
6419
by: pompeyoc | last post by:
Hi, I am a newbie when it comes to stored procs and i would like to learn how to call a COBOL program from a stored procedure. The SP can either be an DB2 SQL SP or an external COBOL/DB2 SP. I can use either depending on which is more efficient. One of the older posts ("Calling a COBOL Subroutine from COBOL/DB2 Stored Procedure" Dec 2005) suggested this is possible but I couldn't follow the explanation and there wasn't any examples....
1
2894
by: rsreeni | last post by:
Hi, We are planning to use Cobol Stored procedures for doing our Data retrieval from DB2 Tables. The stored procedure(s) will be called from J2EE application via Db2 Connect. Does the linkage restriction of 32K apply to the parameters getting passed into COBOL DB2 Stored procedures also? Thanks, -Sreeni
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9571
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10561
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.