MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need to insert NULL in few columns of DB2 using REXX

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
ASHOKRAJ
Beginner


Joined: 15 Dec 2008
Posts: 2
Topics: 1

PostPosted: Thu Feb 05, 2009 6:31 am    Post subject: Need to insert NULL in few columns of DB2 using REXX Reply with quote

Hi,
Need to Insert rows into a DB2 table,which accepts NULL value in few columns - Using REXX. Struck up with this..

Below is the REXX code, having declaration, preparation and execution statements
REXX CODE
Code:

============================================
...
..
F14 = 0
F15 = 0
F16 = 0
F17 = 0
..
Address DSNREXX "CONNECT "DB2V                                         
SQLSTMT = "INSERT INTO TDB296.VSXCTRY VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"                                   
Address DSNREXX                                                         
"EXECSQL DECLARE C7 CURSOR FOR S7"                                     
SAY 'Declare SQLcode: ' SQLCODE                                         

"EXECSQL PREPARE S7 FROM :SQLSTMT"                                     
SAY 'Prepare SQLcode: ' SQLCODE                                         

"EXECSQL EXECUTE S7 USING :F1,:F2,:F3,:F4,:F5,:F6,:F7,:F8,:F9,:F10,:F11,
 ,:F12,:F13,:F14,:F15,:F16,:F17,:F18,:F19,:F20,:F21,:F22,:F23,:F24,:F25"   SAY 'Insert SQLcode: ' SQLCODE                                         
============================================

NOTE: SQLCODE is 0 for Declaration and preparation. but SQLCODE is -104 for Insertion (Execution).

Need tips to resolve this issue.

Best regards,
Ashok
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Thu Feb 05, 2009 10:14 am    Post subject: Reply with quote

If you read the manual you will find that it says that a Rexx null IS NOT THE SAME as a DB2 null. To insert a NULL into DB2 you have to set the null indicator to a negative value.
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Thu Feb 05, 2009 11:04 am    Post subject: Reply with quote

ASHOKRAJ,

-104 is a syntax error. Use TRACE to display the generated SQL statement; also, display SQLERRM to see some more info.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ASHOKRAJ
Beginner


Joined: 15 Dec 2008
Posts: 2
Topics: 1

PostPosted: Thu Feb 05, 2009 11:39 pm    Post subject: Reply with quote

Hi kolusu,
How to use the TRACE for display? Also I have directly tried displaying SQLERRM, it is not getting the value...hope below lines need modification..

-------------------------------
IF LASTSQL /= '0' THEN DO
SAY 'Insertion not success'
SAY 'SQLERRM is:' SQLERRM
END
-------------------------------

Regards,
Ashok
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Fri Feb 06, 2009 2:58 pm    Post subject: Reply with quote

Look up the Rexx Language Reference for the TRACE command
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group