IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Null Indicator handling


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Debasis Misra
Warnings : 1

New User


Joined: 16 Sep 2008
Posts: 72
Location: Bangalore

PostPosted: Mon Feb 16, 2009 10:42 pm
Reply with quote

If a DB2 table variable is defined as a NOT NULL. And from the cobol program during the executing of a INSERT or UPDATE query for that field, we will active the Null Indicator, will it abend?

If it is defined as NOT NULL WITH DEFAULT still will it abend?

OR, what data will be populate in that field?
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Mon Feb 16, 2009 11:58 pm
Reply with quote

Quote:
we will active the Null Indicator


Can you elaborate?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Feb 17, 2009 2:31 am
Reply with quote

Hello,

As asked - please elaborate. . .

fwiw - if the column is defined as NOT NULL, there will be no null indicator in the host variables. . .
Back to top
View user's profile Send private message
Debasis Misra
Warnings : 1

New User


Joined: 16 Sep 2008
Posts: 72
Location: Bangalore

PostPosted: Tue Feb 17, 2009 10:20 am
Reply with quote

Just I am asking if Null Indicator has been used for NOT NULL coloumns during INSERT & UPDATE, what will happen? It will abend or it will execute successfully but DB2 table will be unchanged.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Feb 17, 2009 10:38 am
Reply with quote

Hello,

Please post the dclgen for one of these tables (only a small number of columns and at least one that is not nullable) and the insert sql for the same table.

I believe i am misunderstanding something as there should be no "null indicator" variables for columns that do not support a null value.
Back to top
View user's profile Send private message
Debasis Misra
Warnings : 1

New User


Joined: 16 Sep 2008
Posts: 72
Location: Bangalore

PostPosted: Tue Feb 17, 2009 11:23 am
Reply with quote

Dclgen:
-----------
10 A-1 PIC X(2).



Code:
----------
Move -1 to WS-NULL-IND1.

Insert Into TableA
(A_1
)
Vaues
(:A-1 ::WS-NULL-IND1
)
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Feb 17, 2009 11:27 am
Reply with quote

Hello,

If A_1 is defined as NOT NULL, i believe you will get an sql error.

Should be a painless test icon_wink.gif
Back to top
View user's profile Send private message
Debasis Misra
Warnings : 1

New User


Joined: 16 Sep 2008
Posts: 72
Location: Bangalore

PostPosted: Tue Feb 17, 2009 11:29 am
Reply with quote

A_1 is defined as NOT NULL.
Thanks alot.
It will be very helpful for me if you mantion the sqlcode.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Feb 17, 2009 11:30 am
Reply with quote

Hello,

Which is why i mentioned:
Quote:
Should be a painless test icon_wink.gif
Back to top
View user's profile Send private message
Debasis Misra
Warnings : 1

New User


Joined: 16 Sep 2008
Posts: 72
Location: Bangalore

PostPosted: Tue Feb 17, 2009 11:33 am
Reply with quote

I got.
sqlcode -407.
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Tue Feb 17, 2009 11:59 am
Reply with quote

Yes,
Quote:
407 is AN UPDATE, INSERT, OR SET VALUE IS NULL, BUT THE OBJECT COLUMN CANNOT CONTAIN NULL VALUES


They may have defined it as not null because it could have been for some business specific requirements.Analyse the reason with ur DA/DBA on this and then if it is of no impact on removing the NOT NULL ,then have it removed.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Feb 17, 2009 8:38 pm
Reply with quote

Hello,

Suggest you NOT remove the not null. Suggest you remove the null indicator(s) from the code where they should not be.

Many places i support require a specific exception to define a column as nullable. A common/growing feeling is that nulls are more trouble than they are worth. Especially considering the growing number of people who work with databases (even dbas) that are not "database people" . . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Adding 'ODD' and 'EVEN' indicator at ... DFSORT/ICETOOL 6
No new posts Cobol prog to put an indicator on the... JCL & VSAM 1
No new posts the system or user abend SF0F R=NULL COBOL Programming 0
No new posts File Handling COBOL Programming 9
Search our Forums:

Back to Top