Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Null handling 1

Status
Not open for further replies.

widowweeds

Programmer
Oct 29, 2002
14
IE
Dear Members,

Can anybody tell what is normally done when a null is retrieved by a fetch into a host variable given that a null indicator has been coded for that host variable and both the variable itself and indicator have been initialized prior to the fetch? Would you normally be content that the variable contains either spaces or zeros and continue on your way or would it be more advisable to check the null indicator for a -1 and abort?

Many thanks for any assistance given.
 
Hi again WW,
If a field is nullable and you have coded the fetch to cater for a null indicator, you should always check the indicator in order to determine whether the field was returned or not. Just checking for 0 or spaces is not going to be good enough, as these may well be valid values. Checking for -1 or 0 is the way to go.
Marc
 
Hi Marc,

Once the null indicator has been checked and is found to contain a -1, what is the normal course of action one takes. Would it be advisable to abort via an exit-error-para or can you handle this situation in some way and continue processing. It is the course of action taken in the event of a null being retrieved that I am uncertain of.

Thanks again.
 
Hi WW,

It depends very much upon the application, but I would say that usually one wouldn't abend. If a column has been defined as nullable, then usually that means that having a null in it is an acceptable value.

Take the scenario where you have a JOB_START_DATE and a JOB-COMPLETE_DATE. The 1st column would probably be defined as NOT NULL but the 2nd would allow nulls, as this field would only be populated when the job has ended. Fetching the row and receiving a null would be a valid condition where you wouldn't want to abend.

Hope this helps.

Marc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top