View previous topic :: View next topic
|
Author |
Message |
uday bhaskar
New User
Joined: 18 Mar 2007 Posts: 15 Location: Columbus
|
|
|
|
Hi,
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",
"(REPORT_TYPE,USER_ID,FOUND_TIME)",
" VALUES ('"||X||"','"||Y||"',CURRENT_TIMESTAMP)"
ADDRESS DSNREXX
"EXECSQL EXECUTE IMMEDIATE :SQLSTMT"
SAY RC
SAY 'A RECORD INSERTED'
END
SAY 'PROGRAM COMPLETED'
ADDRESS TSO
"FREE F(MYINPUT)"
EXIT |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Run with and Post the trace. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 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. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
The following are posts that I have found (in another forum)
that were so informative that I am posting them here (probably already have once):
by acevedo:
Quote: |
you could improve your message adding the sqlcode explanation...
Code:
/*--------------------------------------------------------------------*/
/* Desc.: traducir sqlcode */
/* Parms: sqlcode __________________________________*/
/* Retrn: _______ ____________________________________________________*/ /*--------------------------------------------------------------------*/
traducir_sqlcode:
arg sqlcode
/* formatear sqlca para el dsntiar */
sqlc = d2x(sqlcode,8)
sqlc = x2c(sqlc)
sqlca = 'SQLCA 'x2c(00000088)sqlc||x2c(0000)||copies(' ',78)
sqlca = sqlca| |copies(x2c(00),24)copies(' ',16)
tiar_msg = x2c(0190)copies(' ',400)
text_len = x2c(00000050)
address attchpgm 'dsntiar sqlca tiar_msg text_len'
return strip(substr(tiar_msg,4,400))
|
by don.leahy
Quote: |
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:
Code: |
SQLerr: say "SQL Error: " SQLCODE
address link "RXSQLCA"
say SQLERRMSG
exit(20)
|
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.
www-1.ibm.com/support/docview.wss?rs=64&uid=swg27008711
|
If nothing else, the COBOL pgm RXSQLCA shows how to invoke IRXEXCOM
to retrieve variables. |
|
Back to top |
|
|
uday bhaskar
New User
Joined: 18 Mar 2007 Posts: 15 Location: Columbus
|
|
|
|
Thanks a lot dbzTHEdinosauer,Akatsukami and dick for your suggestions and for your prompt reply. I will defintely try with the options you suggested and I will let you guys know what worked for me. |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
RXSQLCA is no longer available at the IBM DB2 Trading post. They re-organized that site several months ago and required all contributors to re-submit their stuff. I haven't done that yet.
RXSQLCA can also be found in "The Code Place" page on Use [URL] BBCode for External Links |
|
Back to top |
|
|
|