I am working on a CICS screen where the users can query, add, update or delete data in a table. In one of my tables, the unique key is made of 5 fields, 2 of which can be NULL. In my cursor I'm having to use an
AND (COLUMN_1 = :V??-REC.COLUMN-1 OR COLUMN-1 IS NULL)
and then I am having to run an evaluation on the results and display the closest matching result.
How I am currently finding NULL entries:
EXEC SQL
DECLARE V000001-CUR CURSOR FOR
SELECT DOCM_N,
DOCM_TYPE_T,
REJ_RESN_C
FROM V000001
WHERE DOCM_N = :V000001-REC.DOCM-N
AND DOCM_TYPE_T = :V000001-REC.DOCM-TYPE-T
AND (REJ_RESN_C = :V000001-REC.REJ-RESN-C OR
REJ_RESN_C IS NULL)
END-EXEC
I have read online that null indicators can be used to insert NULL into the table when using update or insert.
For example:
EXEC SQL
UPDATE V000001
SET DOCM_N = :V000001-REC.DOCM-N,
DOCM_TYPE_T = :V000001-REC.DOCM-TYPE-T,
REJ_RESN_C = :V000001-REC.REJ-RESN-C
:WS-REJ-RESN-C-IND
WHERE DOCM_N = :WW-DOCM-N
AND DOCM_TYPE_T = :WW-DOCM-TYPE-T
END-EXEC
My question. Can I use the null indicator in the WHERE clause?
Such as:
EXEC SQL
DECLARE V000001-CUR CURSOR FOR
SELECT DOCM_N,
DOCM_TYPE_T,
REJ_RESN_C
FROM V000001
WHERE DOCM_N = :V000001-REC.DOCM-N
AND DOCM_TYPE_T = :V000001-REC.DOCM-TYPE-T
AND REJ_RESN_C = :V000001-REC.REJ-RESN-C
:WS-REJ-RESN-C-IND
END-EXEC