View previous topic :: View next topic
|
Author |
Message |
esaccy Currently Banned New User
Joined: 19 Feb 2005 Posts: 22
|
|
|
|
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 |
|
|
Yoyoyo
New User
Joined: 19 Sep 2006 Posts: 26
|
|
|
|
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 |
|
|
ovreddy
Active User
Joined: 06 Dec 2004 Posts: 211 Location: Keane Inc., Minneapolis USA.
|
|
|
|
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 |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
|
|