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

RC=-1 while trying to insert a row a DB2 table using REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
uday bhaskar

New User


Joined: 18 Mar 2007
Posts: 15
Location: Columbus

PostPosted: Wed Mar 02, 2011 12:34 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Mar 02, 2011 12:37 am
Reply with quote

Hello,

Run with and Post the trace.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Wed Mar 02, 2011 1:42 am
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Mar 02, 2011 3:53 pm
Reply with quote

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
View user's profile Send private message
uday bhaskar

New User


Joined: 18 Mar 2007
Posts: 15
Location: Columbus

PostPosted: Wed Mar 02, 2011 8:32 pm
Reply with quote

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
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Wed Mar 02, 2011 11:30 pm
Reply with quote

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
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 -> CLIST & REXX

 


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 Load new table with Old unload - DB2 DB2 6
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