View previous topic :: View next topic
|
Author |
Message |
Debasis Misra Warnings : 1 New User
Joined: 16 Sep 2008 Posts: 72 Location: Bangalore
|
|
|
|
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 |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
Quote: |
we will active the Null Indicator |
Can you elaborate? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Debasis Misra Warnings : 1 New User
Joined: 16 Sep 2008 Posts: 72 Location: Bangalore
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Debasis Misra Warnings : 1 New User
Joined: 16 Sep 2008 Posts: 72 Location: Bangalore
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
If A_1 is defined as NOT NULL, i believe you will get an sql error.
Should be a painless test |
|
Back to top |
|
|
Debasis Misra Warnings : 1 New User
Joined: 16 Sep 2008 Posts: 72 Location: Bangalore
|
|
|
|
A_1 is defined as NOT NULL.
Thanks alot.
It will be very helpful for me if you mantion the sqlcode. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Which is why i mentioned:
Quote: |
Should be a painless test |
|
|
Back to top |
|
|
Debasis Misra Warnings : 1 New User
Joined: 16 Sep 2008 Posts: 72 Location: Bangalore
|
|
|
|
I got.
sqlcode -407. |
|
Back to top |
|
|
muthuvel
Active User
Joined: 29 Nov 2005 Posts: 217 Location: Canada
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|