Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Running DB2 commands in REXX: RC(-1) error

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Vivek Anand

New User


Joined: 04 Jun 2013
Posts: 19
Location: India

PostPosted: Thu Nov 28, 2013 5:09 pm    Post subject: Running DB2 commands in REXX: RC(-1) error
Reply with quote

Hi All,
I have a requirement to execute DB2 commands & SQL statements in REXX. Below is the code snippet

/* REXX */
ADDRESS TSO
'SUBCOM DSNREXX'
IF RC THEN
S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')

ADDRESS DSNREXX
'CONNECT' ITD2
'-DISPLAY DATABASE(NGA01D0) SPACENAM(NGA01T0)'
EXIT

The program runs fine until the CONNECT statement. However the DISPLAY DATABASE statement issues a RC(-1). I am unable to figure out the reason for this.

Could any one help me with this.
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1845
Location: UK

PostPosted: Thu Nov 28, 2013 6:30 pm    Post subject:
Reply with quote

You do show return code checking of the connect. How do you know that it connected OK?
Back to top
View user's profile Send private message
Vivek Anand

New User


Joined: 04 Jun 2013
Posts: 19
Location: India

PostPosted: Thu Nov 28, 2013 6:56 pm    Post subject:
Reply with quote

Nic Clouston wrote:
You do show return code checking of the connect. How do you know that it connected OK?


The CONNECT statement gave a RC = 0. So I presumed this was successful.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1235
Location: Israel

PostPosted: Thu Nov 28, 2013 8:12 pm    Post subject: Reply to: Running DB2 commands in REXX: RC(-1) error
Reply with quote

Remove SUBCOM and CONNECT from your code and try this:
Code:
/* rexx */
Queue "-DISPLAY DATABASE(NGA01D0) SPACENAM(NGA01T0)"
Queue "END"
Address TSO "DSN SYSTEM(ITD2)"


If ITD2 is not your system name but a variable containing your system name, then:
Code:
Address TSO "DSN SYSTEM("ITD2")"


If you have not changed your default Address, then this is enough:
Code:
"DSN SYSTEM("ITD2")"
Back to top
View user's profile Send private message
Vivek Anand

New User


Joined: 04 Jun 2013
Posts: 19
Location: India

PostPosted: Mon Dec 02, 2013 10:51 am    Post subject: Re: Reply to: Running DB2 commands in REXX: RC(-1) error
Reply with quote

Marso wrote:
Remove SUBCOM and CONNECT from your code and try this:
Code:
/* rexx */
Queue "-DISPLAY DATABASE(NGA01D0) SPACENAM(NGA01T0)"
Queue "END"
Address TSO "DSN SYSTEM(ITD2)"


If ITD2 is not your system name but a variable containing your system name, then:
Code:
Address TSO "DSN SYSTEM("ITD2")"


If you have not changed your default Address, then this is enough:
Code:
"DSN SYSTEM("ITD2")"


Hi Marso,
Thanks a lot, this works. Will I also be able to run SQL queries using the same process? I tried but could not figure out the correct syntax. Could you advice please.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1845
Location: UK

PostPosted: Mon Dec 02, 2013 3:26 pm    Post subject:
Reply with quote

Well, without seeing what syntax you used how can wee tell what you have done wrong? Are you using the syntax in the manual? Have you read the entire SQL/Rexx section of the manual?
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 656
Location: Whitby, ON, Canada

PostPosted: Mon Dec 02, 2013 9:10 pm    Post subject:
Reply with quote

-DISPLAY is a DB2 command, not an SQL statement. If you look at Marso's example, you will see that it places a DB2 command on the stack and then executes the "DSN" command. The "DSN" command starts up the DB2 command processor, and it automatically picks up the stacked command from the queue and runs it. The second stacked command, "END" shuts down the command processor.

DSNREXX is used to execute SQL statements, not DB2 commands.
Back to top
View user's profile Send private message
Vivek Anand

New User


Joined: 04 Jun 2013
Posts: 19
Location: India

PostPosted: Tue Dec 03, 2013 12:52 pm    Post subject:
Reply with quote

don.leahy wrote:
-DISPLAY is a DB2 command, not an SQL statement. If you look at Marso's example, you will see that it places a DB2 command on the stack and then executes the "DSN" command. The "DSN" command starts up the DB2 command processor, and it automatically picks up the stacked command from the queue and runs it. The second stacked command, "END" shuts down the command processor.

DSNREXX is used to execute SQL statements, not DB2 commands.


Hi,
Thanks for clarifying. Will look for other means to execute SQL statements.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1845
Location: UK

PostPosted: Tue Dec 03, 2013 2:49 pm    Post subject:
Reply with quote

You seem to have been doing it correctly for SQL statements but you have to use a different method for DB2 command,s as shown above, because they are NOT SQL.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. how to code for GDG in Rexx cvnlynn CLIST & REXX 13 Wed Aug 09, 2017 9:13 pm
This topic is locked: you cannot edit posts or make replies. rexx to create a tso command Bharath Vikraman CLIST & REXX 1 Tue Aug 08, 2017 3:32 pm
This topic is locked: you cannot edit posts or make replies. rexx code to create a ps file Bharath Vikraman CLIST & REXX 4 Mon Aug 07, 2017 10:30 am
No new posts Default Message in Rexx cvnlynn CLIST & REXX 9 Wed Aug 02, 2017 12:38 am
No new posts Calling CLIST through job and REXX Sahasra K CLIST & REXX 19 Tue Aug 01, 2017 10:25 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us