View previous topic :: View next topic
|
Author |
Message |
AnuB Currently Banned New User
Joined: 29 Aug 2005 Posts: 33
|
|
|
|
What is a Null Identifier ?
I am aware of Null value in a Database & Null Statement in COBOL, but
i dont know waht's a Null Identifier.
Pls help me out.
Thanks,
Anu. |
|
Back to top |
|
|
mathiprakash
New User
Joined: 29 Apr 2005 Posts: 14 Location: Pune, India.
|
|
|
|
Hi AnuB,
Null Identifier will be used in case of embedded SQL. Let me explain this with example.
Consider this embedded query.
EXEC SQL
SELECT
EMP_PHONE_NUM
INTO
:EMP-PHONE-NUM
WHERE
EMP_NAME = 'AnuB'
END-EXEC
Here suppose the employee phone number in the database may have null values as well.
Now what will be the SQL code.
will it be successful? The Answer is NO. It will show negative SQL code.
Because the Null value from the database can't be assigned to the host variable. And your program will abend.
So in this case to avoid the sql error we will code the SQL as follows.
EXEC SQL
SELECT
EMP_PHONE_NUM
INTO
:EMP-PHONE-NUM :IND-EMP-PHONE
WHERE
EMP_NAME = 'AnuB'
END-EXEC
In this case the SQL wont get the error. Simply it will set the IND-EMP-PHONE (null indicator) to negative value (say -1 or -2)
Now the sql will be successful. Now you can put one condition to check whether the filed has null value by looking the Null indicator variable.
Regards,
Matty |
|
Back to top |
|
|
AnuB Currently Banned New User
Joined: 29 Aug 2005 Posts: 33
|
|
|
|
Thank u . |
|
Back to top |
|
|
ajayvamsi
New User
Joined: 21 Jul 2005 Posts: 56 Location: Hyderabad
|
|
|
|
hey abu
Declare the variable for null indicator as S9(04) COMP.
Thanks..!! Bye |
|
Back to top |
|
|
Anbudan
New User
Joined: 07 Sep 2005 Posts: 26 Location: Germany
|
|
|
|
Hi AnuB
To find out, whether the field is NULL or NOT NULL,
i)Check the Table info on DB2 OR
ii)While Create DCLGEN, u will find.
Don't hesitate to ask
Anbudan |
|
Back to top |
|
|
AnuB Currently Banned New User
Joined: 29 Aug 2005 Posts: 33
|
|
|
|
Thank u all. |
|
Back to top |
|
|
|