Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 474299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:16:25+00:00 2026-05-13T00:16:25+00:00

I have a REXX job that needs to read from both Teradata (using BTEQ)

  • 0

I have a REXX job that needs to read from both Teradata (using BTEQ) and DB2. At present, I can get it to either read from Teradata or DB2, but not both. When I try to read from both, the Teradata one (which runs first) works fine but the DB2 read gives an error of RC(1) upon attempting to open the cursor.

Code to read from Teradata (by and large copied from http://www.teradataforum.com/teradata/20040928_131203.htm):

ADDRESS TSO "DELETE BLAH.TEMP"
"ALLOC FI(SYSPRINT) DA(BLAH.TEMP) NEW CATALOG SP(10 10) TR RELEASE",
   "UNIT(SYSDA) RECFM(F B A) LRECL(133) BLKSIZE(0) REUSE"
"ATTRIB FBATTR LRECL(220)"
"ALLOC F(SYSIN) UNIT(VIO) TRACKS SPACE(10,10) USING(FBATTR)"
/* Set up BTEQ script */
QUEUE ".RUN FILE=LOGON"
QUEUE "SELECT COLUMN1 FROM TABLE1;"
/* Run BTEQ script */
"EXECIO * DISKW SYSIN (FINIS"
"CALL 'SYS3.TDP.APPLOAD(BTQMAIN)'"; bteq_rc = rc
"FREE FI(SYSPRINT SYSIN)"
/* Read and parse BTEQ output */
"EXECIO * DISKR SYSPRINT (STEM BTEQOUT. FINIS"
DO I = 1 to BTEQOUT.0
   ...
END

Code to read from DB2:

ADDRESS TSO "SUBCOM DSNREXX"
IF RC THEN rcDB2 = RXSUBCOM('ADD','DSNREXX','DSNREXX')
ADDRESS DSNREXX "CONNECT " subsys

sqlQuery = "SELECT COLUMN2 FROM TABLE2;"

ADDRESS DSNREXX "EXECSQL DECLARE C001 CURSOR FOR S001"
IF SQLCODE <> 0 THEN DO
   SAY 'DECLARE C001 SQLCODE = ' SQLCODE
   EXIT 12
END
ADDRESS DSNREXX "EXECSQL PREPARE S001 FROM :sqlQuery"
IF SQLCODE <> 0 THEN DO
   SAY 'PREPARE S001 SQLCODE = ' SQLCODE SQLERROR
      EXIT 12
END
ADDRESS DSNREXX "EXECSQL OPEN C001"
IF SQLCODE <> 0 THEN DO
   SAY 'OPEN C001 SQLCODE = ' SQLCODE
   EXIT 12
END

ADDRESS DSNREXX "EXECSQL FETCH C001 INTO :col2"
IF SQLCODE <> 0 THEN DO
   SAY 'FETCH C001 SQLCODE = ' SQLCODE
   EXIT 12
END

I suspect that this has something to do with my use of SYSPRINT and SYSIN. Anyone know how I can get this to work?

Thanks.

Edit

The question as stated was actually wrong. Apologies for not correcting this earlier.

What I had really done was have this:

ADDRESS TSO "SUBCOM DSNREXX" 
IF RC THEN rcDB2 = RXSUBCOM('ADD','DSNREXX','DSNREXX') 
ADDRESS DSNREXX "CONNECT " subsys 

…followed by a small read from DB2, then followed by the code to read from Teradata, followed by more code to read from DB2. When this was changed to reading from Teradata first before having anything to do with DB2 at all, it worked.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T00:16:25+00:00Added an answer on May 13, 2026 at 12:16 am

    I don’t think this has anything to do with SYSPRINT or SYSIN.

    I think you are getting TSO RC = 1, not SQLCODE = 1 (because there is no SQLCODE of 1.

    1 is a warning, -1 is an error. You can look this up in the DB2 Application Programming
    and SQL Guide

    Turn on TRACE R and run it.

    There are variables (shown below) that display info about the error/warning.

    22 *-* ADDRESS DSNREXX "EXECSQL OPEN C1"                                  
       >>>   "EXECSQL OPEN C1"                                                
       +++ RC(1) +++                                                          
    23 *-* IF SQLCODE <> 0                                                    
    28 *-* SAY 'SQLSTATE='sqlstate', SQLERRMC='sqlerrmc', SQLERRP='sqlerrp    
    

    SQLSTATE=00000, SQLERRMC=, SQLERRP=DSN
    29 – SAY ‘SQLERRD=’sqlerrd.1’, ‘sqlerrd.2’, ‘sqlerrd.3’, ‘sqlerrd.4′,’,
    sqlerrd.5′, ‘sqlerrd.6
    SQLERRD=0, 0, 0, -1, 0, 0
    32 – SAY ‘SQLWARN=’sqlwarn.0’, ‘sqlwarn.1’, ‘sqlwarn.2’, ‘sqlwarn.3′,’,
    sqlwarn.4′, ‘sqlwarn.5’, ‘sqlwarn.6’, ‘sqlwarn.7′,’,
    sqlwarn.8′, ‘sqlwarn.9’, ‘sqlwarn.10
    SQLWARN= , N, , , , 2, , , , ,

    For example, it could be that when both are used together, there is not enough memory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have an app that can use tts to read text messages. It can also
I'd like to parse REXX source so that I can analyse the structure of
have a look at the code from an xml file where i am using
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have you managed to get Aptana Studio debugging to work? I tried following this,
Have you refactored from an ActiveRecord to a DataMapper pattern? What conditions prompted the
Have converted devise new session from erb to Haml but doens't work, this is
have anyone can tell me what syntax error on this actionscript (actionscript3.0)? var rotY:
Have a bunch of WCF REST services hosted on Azure that access a SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.