Subject | Re: [firebird-support] Re: Differences when adding a Primary Key |
---|---|
Author | Ann Harrison |
Post date | 2015-08-23T16:34:46Z |
On Fri, Aug 21, 2015 at 4:47 PM, Walter R. Ojeda Valiente <sistemas2000profesional@...> wrote:"Cannot commit transaction:
The insert failed because a column definition includes validation constraints. validation error for column ID, value "*** null ***".It looks to me as if you have a null in that column. It may be an old value that's being maintained for an old transaction. In that case it would not be visible to you and could disapear before you retry the command.Good luck,AnnThe question is:Why without using CONSTRAINT appears that message but using CONSTRAINT all works fine?And there are not row/s with a NULL value in the column ID.At least, they are not showed with the following query:SELECT*FROMMyTableWHEREID IS NULLSo, it seems very strange to me. The logic for me is: both works or both fails, but why one fails and the other works?Greetings.Walter.On Fri, Aug 21, 2015 at 2:43 PM, Ann Harrison aharrison@... [firebird-support] <firebird-support@yahoogroups.com> wrote:On Aug 21, 2015, at 2:13 PM, 'Walter R. Ojeda Valiente' sistemas2000profesional@... [firebird-support] <firebird-support@yahoogroups.com> wrote:Without using CONSTRAINT doesn't work and in such case the name is choosed by Firebird, not for me.For add a Primary Key to a table we can write:ALTER TABLE MyTable ADD PRIMARY KEY (ID);or we can write:ALTER TABLE MyTable ADD CONSTRAINT MyPK PRIMARY KEY (ID);In the first case, the Firebird puts the name of the Primary Key, in the second case we choose that name, but...Why sometimes the first case fails and the second case always work?But (just sometimes) the first case fails.How does it fail? What's the error message? Or does it kill the connection? Crash the server? Freeze the O/S? Set the machine on fire?Cheers,Ann