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

assign a null value to a host variable


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
esaccy
Currently Banned

New User


Joined: 19 Feb 2005
Posts: 22

PostPosted: Wed Nov 01, 2006 4:17 pm
Reply with quote

Hi All,
I supposed to assign a null value to a host variable.
I am getting sqlcode of 30n instead of 305
Why this happens?
Back to top
View user's profile Send private message
Yoyoyo

New User


Joined: 19 Sep 2006
Posts: 26

PostPosted: Wed Nov 01, 2006 5:13 pm
Reply with quote

Hey Esaccy,

Quote:
I am getting sqlcode of 30n instead of 305


Let us know whether you got the SQLCODE "30n" or you meant something else!

YoYoYo
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Wed Nov 01, 2006 6:41 pm
Reply with quote

Hi,

Move -1 to the indicator variable corresponding to the host variable which you want to make null.

Eg: To make :HV00-COL1 value to null

MOVE -1 TO VHV00COL1

Thanks,
Reddy
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Nov 01, 2006 6:57 pm
Reply with quote

esaccy,

First, when you display the SQLCODE, move it to a PIC -9(3) field first and then display that. the ?N? in the 30N includes the sign. If you look at the HEX value of ?N? you will find x?D5?, where the ?D? is the ?-? sign.

Second, you cannot assign a null value to a host variable. What you can do is assign a null indicator to a host variable.

SELECT COL_VAR
FROM TABLE
INTO :HOST-COL-VAR:HOST-COL-VAR-IND

Where HOST-COL-VAR is, well, you host variable and HOST-COL-VAR-IND is the host null indicator. It must be defined as a 9(4) COMP field. After you select, a value of 0 (zero) indicated the DB2 col value is NOT null and the host variable contains valid data, and a value of -1 indicates the DB2 value is null and the Host variable does not contain valid data (usually low-values, but not guaranteed)

Dave
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 -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts access the last host command CLIST & REXX 2
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
Search our Forums:

Back to Top