473,782 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DB2 Stored Procedure in REXX

Hi all,

Can someone help me out? I've been struggling with this for almost a
week and still have no clue what's wrong.

Basically I want to write a DB2 stored procedure for OS/390 in REXX.
In this procedure it reads a dataset and return the first line of the
dataset. I met two problems:

Problem 1:
WLM environment does not start automatically when the DB2 stored
procedure is called.

Problem 2:
TSO Commands, such as ALLOCATE and FREE cannot be executed in the REXX
stored procedure, but TSO REXX commands can (like EXECIO, TE, TS).

My story is listed below:

REXX Procedure - JEFF.PDS.REXX(R XREAD1):

ARG fileName
say ADDRESS();
"ALLOC FI(FILEDD) DA('"fileName"' ) SHR REUSE"
"EXECIO 1 DISKR FILEDD (STEM lines."
fileTxt = lines.1
"EXECIO 0 DISKR FILEDD (FINIS"
"FREE FI(FILEDD)"
EXIT fileTxt
Command used to create the DB2 stored procedure JEFF.RXREAD1:

CREATE PROCEDURE RXREAD1(
IN FILENAME CHAR(44),
OUT FILETXT VARCHAR(256))
LANGUAGE REXX
EXTERNAL NAME RXREAD1
NO COLLID
NO SQL
ASUTIME NO LIMIT
RUN OPTIONS 'TRAP(ON)'
WLM ENVIRONMENT WLMENV1
PARAMETER STYLE GENERAL
SECURITY DB2
DYNAMIC RESULT SET 1
COMMIT ON RETURN NO;

Definition of WLM application environment WLMENV1:

Appl Environment Name . . WLMENV1
Description . . . . . . . Stored Procedures
Subsystem type . . . . . DB2
Procedure name . . . . . DSN1WLM1
Start parameters . . . . DB2SSN=&IWMSSNM ,NUMTCB=2,APPLE NV='WLMENV
1'
Limit on starting server address spaces for a subsystem instance:
No limit
I got a time-out error when I issued a CALL from the client program
(DB2 Client Command Center):
CALL RXREAD1("JEFF.T EST", ?)

It hangs there until return a time-out error message:

------------------------------ Command Entered
------------------------
CALL RXREAD1("JEFF.T EST", ?)
-----------------------------------------------------------------------
SQL0471N Invocation of routine "JEFF .RXREAD1 " failed
due to reason "00E79002". SQLSTATE=55023

So I read some manuals and wrote a WLM-environment start-up script and
put in the PROCLIB:
ADCD.ZOSV1R2.PR OCLIB(DSN1WLM1)
//*************** *************** *************** *************** *
//* JCL PROCEDURE FOR THE STARTUP OF THE
//* DB2 STORED PROCEDURES ADDRESS SPACE
//* RGN -- THE MVS REGION SIZE FOR THE ADDRESS SPACE.
//* DB2SSN -- THE DB2 SUBSYSTEM NAME.
//* NUMTCB -- THE NUMBER OF TCBS USED TO
//* PROCESS END USER REQUESTS.
//*
//*************** *************** *************** *************** *
//DSN1WLM1 PROC RGN=24M,DB2SSN= DSN1,NUMTCB=8,A PPLENV=
//IEFPROC EXEC PGM=DSNX9WLM,RE GION=&RGN,TIME= NOLIMIT,
// PARM='&DB2SSN,& NUMTCB,&APPLENV .'
//STEPLIB DD DISP=SHR,DSN=DS N710.RUNLIB.LOA D
// DD DISP=SHR,DSN=CE E.SCEERUN
// DD DISP=SHR,DSN=DS N710.SDSNLOAD
//SYSEXEC DD DSN=JEFF.PDS.RE XX,DISP=SHR
//SYSTSPRT DD SYSOUT=*
The time out problem still existed.
Then I wrote another JCL to start the WLM address space manually:
JEFF.PDS.REXX(J EFFCHEK)
//JEFFCHEK JOB (999,POK),'SAVE TIME',NOTIFY=&S YSUID.,
// CLASS=A,MSGCLAS S=T,REGION=5000 K,
//* TYPRUN=SCAN,
// MSGLEVEL=(1,1)
// EXEC DSN1WLM1,DB2SSN =DSN1,NUMTCB=8, APPLENV=WLMENV1
/*
//
I submited job JEFFCHEK and called the procedure again:

CALL RXREAD1("JEFF.T EST", ?)
------------------------------ Command Entered
------------------------
CALL RXREAD1("JEFF.L UCIDRDR", ?)
-----------------------------------------------------------------------
FILETXT: LINES.1
"RXREAD1" RETURN_STATUS: "0"
It returned something, but not the first line of the dataset. I
checked the output of SYSTSPRT of job JEFFCHEK, it has:
TSO
3 *-* "ALLOC FI(FILEDD) DA('"fileName"' ) SHR REUSE"
+++ RC(-3) +++
IRX0555E The input or output file FILEDD is not allocated. It cannot
be opened for I/O.
IRX0670E EXECIO error while trying to GET or PUT a record.
7 *-* "FREE FI(FILEDD)"
+++ RC(-3) +++

Based on my understanding, it means the host commands: ALLOC and FREE
could not be executed.

Can somebody tell me what's wrong? Any comments are welcome.

Thanks!

Jeff Wang
Afshar Consulting Group
Nov 12 '05 #1
7 15596
I think the file must be preallocated in the startup jcl.

PM
"Jeff Wang" <je**********@y ahoo.com> a écrit dans le message de
news:99******** *************** ***@posting.goo gle.com...
Hi all,

Can someone help me out? I've been struggling with this for almost a
week and still have no clue what's wrong.

Basically I want to write a DB2 stored procedure for OS/390 in REXX.
In this procedure it reads a dataset and return the first line of the
dataset. I met two problems:

Problem 1:
WLM environment does not start automatically when the DB2 stored
procedure is called.

Problem 2:
TSO Commands, such as ALLOCATE and FREE cannot be executed in the REXX
stored procedure, but TSO REXX commands can (like EXECIO, TE, TS).

My story is listed below:

REXX Procedure - JEFF.PDS.REXX(R XREAD1):

ARG fileName
say ADDRESS();
"ALLOC FI(FILEDD) DA('"fileName"' ) SHR REUSE"
"EXECIO 1 DISKR FILEDD (STEM lines."
fileTxt = lines.1
"EXECIO 0 DISKR FILEDD (FINIS"
"FREE FI(FILEDD)"
EXIT fileTxt
Command used to create the DB2 stored procedure JEFF.RXREAD1:

CREATE PROCEDURE RXREAD1(
IN FILENAME CHAR(44),
OUT FILETXT VARCHAR(256))
LANGUAGE REXX
EXTERNAL NAME RXREAD1
NO COLLID
NO SQL
ASUTIME NO LIMIT
RUN OPTIONS 'TRAP(ON)'
WLM ENVIRONMENT WLMENV1
PARAMETER STYLE GENERAL
SECURITY DB2
DYNAMIC RESULT SET 1
COMMIT ON RETURN NO;

Definition of WLM application environment WLMENV1:

Appl Environment Name . . WLMENV1
Description . . . . . . . Stored Procedures
Subsystem type . . . . . DB2
Procedure name . . . . . DSN1WLM1
Start parameters . . . . DB2SSN=&IWMSSNM ,NUMTCB=2,APPLE NV='WLMENV
1'
Limit on starting server address spaces for a subsystem instance:
No limit
I got a time-out error when I issued a CALL from the client program
(DB2 Client Command Center):
CALL RXREAD1("JEFF.T EST", ?)

It hangs there until return a time-out error message:

------------------------------ Command Entered
------------------------
CALL RXREAD1("JEFF.T EST", ?)
-----------------------------------------------------------------------
SQL0471N Invocation of routine "JEFF .RXREAD1 " failed
due to reason "00E79002". SQLSTATE=55023

So I read some manuals and wrote a WLM-environment start-up script and
put in the PROCLIB:
ADCD.ZOSV1R2.PR OCLIB(DSN1WLM1)
//*************** *************** *************** *************** *
//* JCL PROCEDURE FOR THE STARTUP OF THE
//* DB2 STORED PROCEDURES ADDRESS SPACE
//* RGN -- THE MVS REGION SIZE FOR THE ADDRESS SPACE.
//* DB2SSN -- THE DB2 SUBSYSTEM NAME.
//* NUMTCB -- THE NUMBER OF TCBS USED TO
//* PROCESS END USER REQUESTS.
//*
//*************** *************** *************** *************** *
//DSN1WLM1 PROC RGN=24M,DB2SSN= DSN1,NUMTCB=8,A PPLENV=
//IEFPROC EXEC PGM=DSNX9WLM,RE GION=&RGN,TIME= NOLIMIT,
// PARM='&DB2SSN,& NUMTCB,&APPLENV .'
//STEPLIB DD DISP=SHR,DSN=DS N710.RUNLIB.LOA D
// DD DISP=SHR,DSN=CE E.SCEERUN
// DD DISP=SHR,DSN=DS N710.SDSNLOAD
//SYSEXEC DD DSN=JEFF.PDS.RE XX,DISP=SHR
//SYSTSPRT DD SYSOUT=*
The time out problem still existed.
Then I wrote another JCL to start the WLM address space manually:
JEFF.PDS.REXX(J EFFCHEK)
//JEFFCHEK JOB (999,POK),'SAVE TIME',NOTIFY=&S YSUID.,
// CLASS=A,MSGCLAS S=T,REGION=5000 K,
//* TYPRUN=SCAN,
// MSGLEVEL=(1,1)
// EXEC DSN1WLM1,DB2SSN =DSN1,NUMTCB=8, APPLENV=WLMENV1
/*
//
I submited job JEFFCHEK and called the procedure again:

CALL RXREAD1("JEFF.T EST", ?)
------------------------------ Command Entered
------------------------
CALL RXREAD1("JEFF.L UCIDRDR", ?)
-----------------------------------------------------------------------
FILETXT: LINES.1
"RXREAD1" RETURN_STATUS: "0"
It returned something, but not the first line of the dataset. I
checked the output of SYSTSPRT of job JEFFCHEK, it has:
TSO
3 *-* "ALLOC FI(FILEDD) DA('"fileName"' ) SHR REUSE"
+++ RC(-3) +++
IRX0555E The input or output file FILEDD is not allocated. It cannot
be opened for I/O.
IRX0670E EXECIO error while trying to GET or PUT a record.
7 *-* "FREE FI(FILEDD)"
+++ RC(-3) +++

Based on my understanding, it means the host commands: ALLOC and FREE
could not be executed.

Can somebody tell me what's wrong? Any comments are welcome.

Thanks!

Jeff Wang
Afshar Consulting Group

Nov 12 '05 #2
Maybe you can use something like dynalloc?

b.t.w. my rexx DB2 SP skills is pretty low...

PM
Nov 12 '05 #3
i tried to recreate your proc on my test system
(z/OS 1.4, DB2 V7.1), and found:

- WLM address space starts correctly
(note that you must set NUMTCB to 1 for REXX SP's).

- The REXX Stored procedure correctly receives the
file name that is passed to it as an argument.

- my TSO ALLOC command gets RC(-3) just as yours.

Now, in the REXX REFERENCE manual, Chapter 8.6,
'Summary of Writing Execs for Different Address Spaces',
there is a summary table listing the the REXX keyword instructions,
built- in functions, TSO/E external functions, TSO/E REXX commands,
and other services you can use for execs that run in TSO/E and
non-TSO/E address spaces.

ALLOCATE seems to be available *ONLY* in TSO/E address spaces.
EXECIO however is available.

What could be a solution is to link to a program that can do
DYNALLOC, but you would have to write that.
Nov 12 '05 #4
Thank you PM and heinz. I appreciate your help.

I changed NUMTCB to 1, WLM address space still didn't start
automatically. I am checking it.

Yes, I read the REXX REFERENCE manual, it says that ALLOCATE is only
available in TSO/E address spaces. I printed out the running address
space using "say ADDRESS()" in the REXX script and it returned "TSO".
Did it mean that the REXX procedure was actually running in TSO/E
address space? If yes, why couldn't it execute ALLOCATE statement?

Never used DYNALLOC before. What kind of program can do DYNALLOC?

Thanks again,
Jeff
he***********@g mx.net (Heinz Buehler) wrote in message news:<5f******* *************** ****@posting.go ogle.com>...
i tried to recreate your proc on my test system
(z/OS 1.4, DB2 V7.1), and found:

- WLM address space starts correctly
(note that you must set NUMTCB to 1 for REXX SP's).

- The REXX Stored procedure correctly receives the
file name that is passed to it as an argument.

- my TSO ALLOC command gets RC(-3) just as yours.

Now, in the REXX REFERENCE manual, Chapter 8.6,
'Summary of Writing Execs for Different Address Spaces',
there is a summary table listing the the REXX keyword instructions,
built- in functions, TSO/E external functions, TSO/E REXX commands,
and other services you can use for execs that run in TSO/E and
non-TSO/E address spaces.

ALLOCATE seems to be available *ONLY* in TSO/E address spaces.
EXECIO however is available.

What could be a solution is to link to a program that can do
DYNALLOC, but you would have to write that.

Nov 12 '05 #5
Dynalloc is most likely encoutered as an assembler / cobol module that you
call. (ask your sysprog)
it's a macro for the io svc 99.
It's used to query/modify the 'file' control blocks.
I'm pretty sure you'll find something about it on the net if you search for
: dynalloc rexx svc 99

There are many uses for it.
ex : you have a dd in your jcl, in your pgm, you reassign the dd to a new
dsn, open it, read it....
You can again reassign the dd to a new dsn, open it, read it....
You normally use this if you can't concat the dsn in the jcl (for whatever
reason. ex: no key, no date, ...)
dd dsn
dsn
dsn
or you don't want to use 20 dd in the jcl and programatically find what file
contains what...

Often used in situations like :
tso list* lvl(...) in dsnx
pgm1 has dd dsny
pgm1 opens dsnx that contains file names and boucles with dynalloc to
process them.

I can't help you more on this topic as my rexx/exec2 knowledge is fading...

PM
Nov 12 '05 #6
PM,

Thanks a lot for your help. I also learned from David on another board
that I can use BPXWDYN in REXX, which probably invokes dynalloc
function. However, it seems that BPXWDYN is only supported in some
latest version of z/OS. If I need to run the REXX procedure on OS/390,
I may still need to write another module to call dynalloc function, as
you said.

Thanks again,
Jeff

"PM \(pm3iinc-nospam\)" <PM(pm3iinc-nospam)@sympati co.ca> wrote in message news:<Cb******* **************@ news20.bellglob al.com>...
Dynalloc is most likely encoutered as an assembler / cobol module that you
call. (ask your sysprog)
it's a macro for the io svc 99.
It's used to query/modify the 'file' control blocks.
I'm pretty sure you'll find something about it on the net if you search for
: dynalloc rexx svc 99

There are many uses for it.
ex : you have a dd in your jcl, in your pgm, you reassign the dd to a new
dsn, open it, read it....
You can again reassign the dd to a new dsn, open it, read it....
You normally use this if you can't concat the dsn in the jcl (for whatever
reason. ex: no key, no date, ...)
dd dsn
dsn
dsn
or you don't want to use 20 dd in the jcl and programatically find what file
contains what...

Often used in situations like :
tso list* lvl(...) in dsnx
pgm1 has dd dsny
pgm1 opens dsnx that contains file names and boucles with dynalloc to
process them.

I can't help you more on this topic as my rexx/exec2 knowledge is fading...

PM

Nov 12 '05 #7
Jeff,
this REXX procedure works now,
but we are on z/OS 1.4 ...

/*REXX*/
ARG fileName
say ' '
say 'STORED PROCEDURE: RXREAD1'
say 'Filename :'fileName ;
- - - - - - - - - - - - - - - - 12 Line(s) not
fileName = "'" !! strip(fileName) !! "'"
a_string = 'alloc dd(FILEDD) da('filename') shr reuse'
say a_string

RX_RC = BPXWDYN(a_strin g)
do i=1 to s99msg.0
say s99msg.i
end
say 'ALLOC RC='Rx_RC
drop lines

"EXECIO 1 DISKR FILEDD (STEM lines."
fileTxt = lines.1
say 'File Text (first Line):'fileTxt

"EXECIO 0 DISKR FILEDD (FINIS"

Rx_RC = bpxwdyn("FREE FI(FILEDD)")
do i=1 to s99msg.0
say s99msg.i
end
say 'FREE RC='Rx_RC

EXIT fileTxt

regards, Heinz
Nov 12 '05 #8

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

Similar topics

3
22146
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my application server can talk to the database. I've determined the failure occurs when the the following statement is executed: cstmt.execute(); (due to the failure of println statements placed afterwards). I get the following error after trying to...
4
3191
by: Rhino | last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a Throwable back to the calling program as an OUT parameter? If yes, what datatype should I use when registering the Throwable as an OUT parameter and what datatype should I use in the CREATE PROCEDURE and DROP PROCEDURE statements? Here's what I tried: - the method signature for the stored procedure included: Throwable throwable
8
7944
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have created a temporary database with a tables space. Verified that DECLARE GLOBAL TEMPORARY TABLE TEMP (A INTEGER); INSERT INTO SESSION.TEMP VALUES(10); SELECT A FROM SESSION.TEMP; works from a query tool.
2
2639
by: dragonmsw | last post by:
I'm having a problem invoking DB2 Stored Procedures from REXX. I've written a generic SP tester where you enter the schema and name of the SP. The next panel displays the parms for the SP and allows you to fill in the ones you need to and then invokes the SP. I'm having two problems in particular that relate to specifying parms for the SP call. (1) I can't make it work at all for a VARCHAR parm. Everytime there is a VARCHAR parm,...
2
1653
by: Massimiliano Campagnoli | last post by:
What are the supported languages to write stored procedure in db2 v8.2 for linux ? Is object rexx included ?
2
5459
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
12
2956
by: Tony Belding | last post by:
I'm interested in using an off-the-shelf interpreted language as a user-accessible scripting language for a MUCK. I'm just not sure if I can find one that does everything I need. The MUCK must be able to call the interpreter and execute scripts with it, but the interpreter must also be able to call functions in the MUCK code. And then there's the security issue that really worries me. . . I have to be able to limit what the interpreter...
2
3863
by: Tonkuma | last post by:
I called Stored Procedure written in SQL from Object REXX on Windows like this CALL SQLEXEC 'CALL MigrateDECODE(:inString,:Converted)' CALL CHECKERR 'CALL MigrateDECODE' (CHECKERR was copied from DB2 sample program) But, it returned -444 as followings. How can I call Stored Procedure written in SQL from REXX? --- error report --- ERROR occurred : CALL MIGRATEDECODE SQLCODE : -444
2
10583
by: savio XCIX | last post by:
I created the following stored procedure: ======= CREATE PROCEDURE TBLNAME.proc_test (IN p_custnum VARCHAR(8), IN p_zipcode CHAR(5), OUT r_valid CHAR(1), OUT r_bal DECIMAL(9,2)) LANGUAGE SQL BEGIN
0
9641
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
10146
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
10080
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,...
0
9944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.