bajistaman
Programmer
I am working on a mainframe, OS/390, DB2 version 7. I go into DB2 Interactive (DB2I Primary Menu) to run my SPUFI:
SELECT * FROM DB2_table_name;
I get this connection error:
SQLCODE = -204, ERROR: DB2_table_name IS AN UNDEFINED NAME
I get this error because I am running on a local DB2 Subsystem, named localA, but the table I am accessing is on a remote DB2 Subsystem, called remoteB (resides on a different server).
To fix that problem, on my DB2I Spufi screen I set my 'CONNECT LOCATION' to the remote location:
For remote SQL processing:
10 CONNECT LOCATION ===> remoteB
and rerun my spufi successfully:
DSNE625I CONNECT TO LOCATION remoteB PERFORMED, SQLCODE IS 0
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
My problem is: I want to run the SELECT statement from my REXX, which looks like:
SQLSTMT = "SELECT * FROM DB2_table_name"
ADDRESS TSO "SUBCOM DSNREXX" /* HOST CMD ENV AVAILABLE ? */
IF RC THEN S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')
ADDRESS DSNREXX "CONNECT" localA /*tried remoteB as well - neither works*/
ADDRESS DSNREXX "EXECSQL PREPARE S1 FROM :SQLSTMT1"
etc...
The above works when my DB2_table_name is on a local DB2 subsystem, but fails with the connection error when the table is on a remote subsystem. How do I execute the 'CONNECT LOCATION ===> remoteB' from within my REXX? What is it that DB2I is doing 'behind the scenes' to allow remote SQL processing, and how do I mimic that within my REXX?
Thanks for your help.
SELECT * FROM DB2_table_name;
I get this connection error:
SQLCODE = -204, ERROR: DB2_table_name IS AN UNDEFINED NAME
I get this error because I am running on a local DB2 Subsystem, named localA, but the table I am accessing is on a remote DB2 Subsystem, called remoteB (resides on a different server).
To fix that problem, on my DB2I Spufi screen I set my 'CONNECT LOCATION' to the remote location:
For remote SQL processing:
10 CONNECT LOCATION ===> remoteB
and rerun my spufi successfully:
DSNE625I CONNECT TO LOCATION remoteB PERFORMED, SQLCODE IS 0
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
My problem is: I want to run the SELECT statement from my REXX, which looks like:
SQLSTMT = "SELECT * FROM DB2_table_name"
ADDRESS TSO "SUBCOM DSNREXX" /* HOST CMD ENV AVAILABLE ? */
IF RC THEN S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')
ADDRESS DSNREXX "CONNECT" localA /*tried remoteB as well - neither works*/
ADDRESS DSNREXX "EXECSQL PREPARE S1 FROM :SQLSTMT1"
etc...
The above works when my DB2_table_name is on a local DB2 subsystem, but fails with the connection error when the table is on a remote subsystem. How do I execute the 'CONNECT LOCATION ===> remoteB' from within my REXX? What is it that DB2I is doing 'behind the scenes' to allow remote SQL processing, and how do I mimic that within my REXX?
Thanks for your help.