Subject | Problem in INSERT query |
---|---|
Author | Adriano |
Post date | 2006-05-19T07:31:59Z |
Hi,
Firebird 2 RC1 Windows, Driver ODBC, Visual Basic
I've a table FATTURE with some fields,
a field named IDFATTURA which is Primary Key (not null, unique and active)
a autoincremental trigger in Before Insert
BEGIN
IF (NEW.IDFATTURA IS NULL) THEN
NEW.IDFATTURA = GEN_ID(GEN_FATTURE_IDFATTURA, 1);
END
If i execute a simple query:
query = "INSERT
cn.execute query
I receive this error message:
Invalid insert or update value(s): object columns are
constrained - no 2 table rows can have duplicate column values.
Violation of PRIMARY or UNIQUE KEY constraint "PRIMARYKEY012" on table
"FATTURE".
I see that have no violation of primary key nor duplicate column values.
Why do you think i receive this message ?
Another question: in general is preferable to mantain separated the
Primary key with a field (numeric autoincremental field) used to
assign some unique value ? I used the number of a primary key to
create an unique folder on pc, is it correct or is it preferable to
assign for that a different field with autoincremental number for that
?
thanks
Adriano
Firebird 2 RC1 Windows, Driver ODBC, Visual Basic
I've a table FATTURE with some fields,
a field named IDFATTURA which is Primary Key (not null, unique and active)
a autoincremental trigger in Before Insert
BEGIN
IF (NEW.IDFATTURA IS NULL) THEN
NEW.IDFATTURA = GEN_ID(GEN_FATTURE_IDFATTURA, 1);
END
If i execute a simple query:
query = "INSERT
cn.execute query
I receive this error message:
Invalid insert or update value(s): object columns are
constrained - no 2 table rows can have duplicate column values.
Violation of PRIMARY or UNIQUE KEY constraint "PRIMARYKEY012" on table
"FATTURE".
I see that have no violation of primary key nor duplicate column values.
Why do you think i receive this message ?
Another question: in general is preferable to mantain separated the
Primary key with a field (numeric autoincremental field) used to
assign some unique value ? I used the number of a primary key to
create an unique folder on pc, is it correct or is it preferable to
assign for that a different field with autoincremental number for that
?
thanks
Adriano