I am getting the RC=-1 while executing the below REXX code. I am trying to insert a row in the DB2 table by comparing two files.
below is the code I am using..please suggest the reason for RC=-1
"EXECIO * DISKR MYINPUT (STEM INDATA. FINIS"
IND = 1
LINECNT = 0
DO A = 1 TO INDATA.0
PARSE VAR INDATA.A WHOLESTRING
X = STRIP(SUBSTR(WHOLESTRING,1,9))
Y = STRIP(SUBSTR(WHOLESTRING,21,8))
SQLSTMT = "INSERT INTO A027412.MPS_CON_USER",
" VALUES ('"||X||"','"||Y||"',CURRENT_TIMESTAMP)"
"EXECSQL EXECUTE IMMEDIATE :SQLSTMT"
SAY 'A RECORD INSERTED'
SAY 'PROGRAM COMPLETED'
Joined: 03 Oct 2009 Posts: 1786 Location: Bloomington, IL
We do not use DSNREXX in our shop (we use RXTASQL instead), but a RC = -1 after addressing the DSNREXX environment suggests that your SQL is in error. In addition to running with a TRACE option, I recommend that you display SQLCODE or SQLSTATE.
This approach works well, but I got tired of including code like that
in each of my DSNREXX programs. (Okay, so call me lazy).
I have replaced it with something simpler:
SQLerr: say "SQL Error: " SQLCODE
address link "RXSQLCA"
RXSQLCA is a program that invokes IRXEXCOM
in order to retrieve the SQLCA variables set by DSNREXX,
and then calls DSNTIAR on your behalf.
The DSNTIAR message is copied to a Rexx variable called SQLERRMSG.
If you are interested, you can download it
(it's written in Cobol) from IBM's DB2 Trading Post web page.