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

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


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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: 2455
Location: Hampshire, UK

PostPosted: Thu Nov 28, 2013 6:30 pm
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
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: 1353
Location: Israel

PostPosted: Thu Nov 28, 2013 8:12 pm
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
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: 2455
Location: Hampshire, UK

PostPosted: Mon Dec 02, 2013 3:26 pm
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: 765
Location: Whitby, ON, Canada

PostPosted: Mon Dec 02, 2013 9:10 pm
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
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: 2455
Location: Hampshire, UK

PostPosted: Tue Dec 03, 2013 2:49 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top