Abhijeet Kashnia
Abhijeet Kashnia

Reputation: 12890

Db2 on AS400 and null values inserted on not nullable columns?

Is there a difference in behaviour of DB2 on AS400 machines when it comes to handling not-nullable columns?

Someone just told me that if you insert a null value into a column with not null, on DB2 as400 it will work (sounds strange I know) , but will throw an error if Db2 is running on Windows.

I am going to verify this as soon as I get hold of the environment, still want to know if someone has ever heard of such a thing.

Closing Note: It was a schema that had changed over time... so the column had changed across releases, which led to the confusion.

Upvotes: 1

Views: 4775

Answers (2)

jmarkmurphy
jmarkmurphy

Reputation: 11473

James has the right answer here about Nulls. As far as differences go, yes there are some. In fact there are three flavors of DB2, and each has it's own codebase. Those flavors are DB2 for z, DB for i, and DB2 for LUW. They try to keep the feature set as close to the same as they can, but there are some things that are in one, but not in the others. Most of the differences are due to differences in the environment. For instance, DB2 for i is tightly integrated into the OS. The OS already manages the file system and application resources, so the database lets the OS do what OS's do, and does not duplicate many of those efforts, so you will not find commands concerning tablespaces and the like. Not that the file system is not managed, but the OS does it, not the database engine. If you compare the LUW and i documentation, you will also find some differences in the way certain features work. These are the result of multiple codebases with different customer bases driving new features. They are close, but not identical,

Upvotes: 0

James Allman
James Allman

Reputation: 41168

I would say the answer is no. Here's a quick test I performed using interactive SQL (STRSQL) on V7R1:

CREATE TABLE QTEMP/TEST (F1 INT, F2 INT NOT NULL, F3 INT NOT NULL WITH DEFAULT);
INSERT INTO QTEMP/TEST (F1, F2, F3) VALUES(NULL, NULL, NULL);
Null values not allowed in column or variable F2.
INSERT INTO QTEMP/TEST (F1, F2, F3) VALUES(NULL, 0, NULL);
Null values not allowed in column or variable F3.

Upvotes: 1

Related Questions