How to handle the null indiactor

Ask question on - DataBase Concepts, IBM Mainframe DB2, DB2/UDB, DB2 Tools, SQL , DB2 programming with languages like COBOL, PL1.

Moderators: Kalicharan, Moderator Group

Post Reply
mithunthakre
Member
Posts: 8
Joined: Mon Feb 27, 2006 4:31 pm
Location: India

How to handle the null indiactor

Post by mithunthakre » Tue Aug 22, 2006 11:04 am

HI,

I am getting the SQLCODE as -305. how i can handle the sqlcode -305
please help me

Thanks & Regrads,
Mit's

User avatar
Krishna
Site Admin
Posts: 1052
Joined: Fri Jan 27, 2006 7:50 am

sql code -305 , Use null indiactor in db2

Post by Krishna » Mon Aug 28, 2006 11:48 am

Hi,

If you get -305 sqlcode which means you got null values into the host variables.


Solution -
Use NULL INDICATOR VARIABLES to stop getting -305.

Example
-----------

,: FIRST-NAME :WS-FIRST-NAME-NULL-IND
,: INIT-NAME :WS-MID-NAME-NULL-IND

FROM EMPLOYEE ........


Define Null Indicator variables as follows
05 WS-FIRST-NAME-NULL-IND PIC S9(04) COMP.


Use following logic When SQLCODE = 0.

IF WS-FIRST-NAME-NULL-IND >= 0
... Means Field populated with proper value
ELSE
... Means Field populated with null value
END-IF


In sum cases, I would suggest handle -305 instead of using
null indicator variables. If you are feching only one field, in that
case better go and handle -305, if query hit -305 move space/zero's
into host variable.



Thanks,
Krishna

mithunthakre
Member
Posts: 8
Joined: Mon Feb 27, 2006 4:31 pm
Location: India

Post by mithunthakre » Mon Sep 04, 2006 2:20 pm

Thanks Krishna

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others