hi buddy,
I was install Zeos 6.6.1 beta to replace 6.1.5 version in my application. How ever, i get an error above when inserting new record.
FYI, i'm using firebird database with generator and trigger. It seem trigger does'nt work in version 6.6.1.
EDatabaseError with message Field 'xxxxxx' must have a value
Moderators: gto, cipto_kh, EgonHugeist
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Hi,
You will have to set the 'required' poperty on the field to 'false'. I suppose the field is required in the database (primary key, probably?), so ZEOS defaults it to required as it isn't aware of what your triggers do before inserting. As I understood from other posts on this forum you can override that, however.
Mark
You will have to set the 'required' poperty on the field to 'false'. I suppose the field is required in the database (primary key, probably?), so ZEOS defaults it to required as it isn't aware of what your triggers do before inserting. As I understood from other posts on this forum you can override that, however.
Mark
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Napi,
Can you identify this kind of 'autoincrement' fields in Firebird. Is it easy to see that a generator is used for a certain field? I think current implementation always sets the FAutoincrement swith to false for all fields.
For mysql we can easyly find out a field is an autoincrement field and in this case it is allowed to be null, even when the field is defined as 'Not Null'.
When I remove this workaround for mysql and test then the program requires a value indeed.
Thus, after the 'open' in my testcase I added 'ZQuery1.FieldByName('c_id').Required := false;' That made it all work again. So you can work around it if you know there is a generator on your primary key.
Mark
Can you identify this kind of 'autoincrement' fields in Firebird. Is it easy to see that a generator is used for a certain field? I think current implementation always sets the FAutoincrement swith to false for all fields.
For mysql we can easyly find out a field is an autoincrement field and in this case it is allowed to be null, even when the field is defined as 'Not Null'.
When I remove this workaround for mysql and test then the program requires a value indeed.
Thus, after the 'open' in my testcase I added 'ZQuery1.FieldByName('c_id').Required := false;' That made it all work again. So you can work around it if you know there is a generator on your primary key.
Mark
hi mdaems
below is my table structure
In firebird, i cannot set primary key to NULL
below is my table structure
Code: Select all
/* table structure */
CREATE TABLE "SIMPAN"
(
"ID_SIMPAN" INTEGER NOT NULL,
"ID_MS" VARCHAR(10) CHARACTER SET WIN1251,
"NAMA" VARCHAR(100),
PRIMARY KEY ("ID_SIMPAN")
);
/* Triggers */
CREATE TRIGGER "BI_SIMPAN_ID_SIMPAN" FOR "SIMPAN"
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.ID_SIMPAN IS NULL) THEN
NEW.ID_SIMPAN = GEN_ID(SIMPAN_ID_SIMPAN_GEN, 1);
END
^
/*generator */
CREATE GENERATOR SIMPAN_ID_SIMPAN_GEN;
-
- Senior Boarder
- Posts: 50
- Joined: 31.08.2006, 10:41
- Contact:
Hi napi
What mdeam says is corret, you don't have to make any modification in your DDL (Data Definition Language) like removing the primary key. Do not do anything over the DDL. Also you dont have to remove anything on your Dataset. You Just have change the "Required" property to False on the Field handled by GENERATOR.
FYI:
Primary key can not be set to NULL, that is the rule of overall database system.
What mdeam says is corret, you don't have to make any modification in your DDL (Data Definition Language) like removing the primary key. Do not do anything over the DDL. Also you dont have to remove anything on your Dataset. You Just have change the "Required" property to False on the Field handled by GENERATOR.
FYI:
Primary key can not be set to NULL, that is the rule of overall database system.
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Hi Bangfauzan, Napi,
Is a generator linked to a specific field and can this be retrieved from the information tables provided by Firebird? That way we can try to implement the autoincrement exeption we also used for mysql. Any idea?
@napi, I hope you now understand what I meant and your problem is solved now?
Mark
Is a generator linked to a specific field and can this be retrieved from the information tables provided by Firebird? That way we can try to implement the autoincrement exeption we also used for mysql. Any idea?
@napi, I hope you now understand what I meant and your problem is solved now?
Mark
hi bangfauzan, mdaems
Yes, i understand now. I follow your example and it's work. Just set required to False.
exp
there are other solution that i was tested using sequence;
Thanks Buddy.
Yes, i understand now. I follow your example and it's work. Just set required to False.
exp
Code: Select all
tblQuestion.FieldByName('ID_SIMPAN').Required := false;
tblQuestion.append;
tblQuestion.FieldByName('ID_MS').asInteger := 1;
tblQuestion.FieldByName('NAMA').asString :='Test';
tblQuestion.post;
Code: Select all
ZSequence1.SequenceName := 'SIMPAN_ID_SIMPAN_GEN';
tblQuestion.append;
tblQuestion.FieldByName('ID_SOALAN').AsInteger := ZSequence1.GetNextValue;
tblQuestion.FieldByName('ID_MS').asInteger := 1;
tblQuestion.FieldByName('NAMA').asString :='Test';
tblQuestion.post;