Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: RC=-1 while trying to insert a row a DB2 table using REXX
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

Site Director


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

PostPosted: Wed Mar 02, 2011 12:37 am    Post subject:
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: 1746
Location: Bloomington, IL

PostPosted: Wed Mar 02, 2011 1:42 am    Post subject:
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    Post subject:
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.

http://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    Post subject: Reply to: RC=-1 while trying to insert a row a DB2 table usi
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: 642
Location: Whitby, ON, Canada

PostPosted: Wed Mar 02, 2011 11:30 pm    Post subject:
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 www.idug.org
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Calling REXX code from ISPF panel sanchita dey TSO/ISPF 4 Mon Jan 02, 2017 5:13 pm
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us