Guys, here we go.
CREATE TABLE VINAYTM.REXXTEST
( USERID CHAR(8) NOT NULL WITH DEFAULT,
ROW_NO INTEGER NOT NULL,
NAME CHAR(20));
Inserted 3 rows
SELECT * FROM REXXTEST
(here my userid is VINAYTM, so no need of table owner)
ROW
USERID NO NAME
-------- ----------- --------------------
1 -
vinay1 2 first
vinay2 3 -
** END ***
I wrote one simple db2 PL1 program for you.
TESTPGM:PROC OPTIONS(MAIN);
DCL IND FIXED BIN(15) INIT(0); -- for NULL INDICATOR
DCL MYNAME CHAR(20) INIT('VINAY KUMAR');
DCL ROWNO FIXED BIN(31) INIT(0); --> didnt use this one
EXEC SQL INCLUDE SQLCA;
PUT SKIP LIST ('BEFORE, NAME = '||MYNAME);
PUT SKIP LIST ('BEFORE, INDICATOR = '||IND);
EXEC SQL
SELECT NAME INTO :MYNAME:IND FROM VINAYTM.REXXTEST
WHERE ROW_NO = 1;
IF SQLCA.SQLCODE = 0 THEN
DO;
PUT SKIP LIST ('AFTER , NAME = '||MYNAME);
PUT SKIP LIST ('AFTER , INDICATOR = '||IND);
END;
ELSE
DO;
PUT SKIP LIST ('FAILED');
PUT SKIP LIST ('SQLCODE IS '||SQLCA.SQLCODE);
END;
END TESTPGM;
Here is the execution results:
BEFORE, NAME = VINAY KUMAR
BEFORE, INDICATOR = 0
AFTER , NAME = VINAY KUMAR
AFTER , INDICATOR = -1
***
So the conclusion part is, If DB2 encounters a null vaue then it doest touch the HOST variable, it just sets the value of NULL INDICATOR variable. Here we can see indicator variable is changed from 0 to -1 but the name is untouched.
Quote:
Originally Posted by Brett Kaiser
great, got it it, understand, so what's in the host variable?
Label me an idiot
|
So the host variable would still contain the value it was having earlier to this statement execution. I realise this concept from one of the manuals but wanted to confirm it today. By the way you are not an Idiot -

) cheers