Subject | Primary Key is allways null |
---|---|
Author | mcrosman1957 |
Post date | 2002-10-01T20:47:09Z |
Hi.
I am using Delphi 6 + Interbase 6.5
My application uses:
ClientDataset + DataSource +
DataSetProvider +
IBQuery +
IBTransaction +
IBDatabase.
I have created:
1)A generator to increment the NumReg primary key of my table PCOrc:
CREATE GENERATOR PCOrc_GEN;
2) A Trigger Set_NumReg_PCOrc:
SET TERM #
CREATE TRIGGER SET_NumReg_PCOrc FOR PLANCONORC
Active Before INSERT Position 0 AS
begin
IF (new.NumReg IS NULL) THEN
new.NumReg = gen_id(PCOrc_GEN,1);
end #
SET TERM ;#
3) I insert a new record executing:
ClientDataset.Insert
After I have filled all the fields on the new insertion I execute
ClientDataset.Post.
Then on the AfterPost event of ClientDataset I execute:
if (ClientDataset.ChangeCount > 0) then
ClientDataset.ApplyUpdates(-1);
After the execution of ClientDatset.Post an EDBClient exception is
raised informing that the "Field NumReg requires a value"
The value of NumReg field is allways null.
How can I solve this problem?
Thanks for any help.
Marcelo.
I am using Delphi 6 + Interbase 6.5
My application uses:
ClientDataset + DataSource +
DataSetProvider +
IBQuery +
IBTransaction +
IBDatabase.
I have created:
1)A generator to increment the NumReg primary key of my table PCOrc:
CREATE GENERATOR PCOrc_GEN;
2) A Trigger Set_NumReg_PCOrc:
SET TERM #
CREATE TRIGGER SET_NumReg_PCOrc FOR PLANCONORC
Active Before INSERT Position 0 AS
begin
IF (new.NumReg IS NULL) THEN
new.NumReg = gen_id(PCOrc_GEN,1);
end #
SET TERM ;#
3) I insert a new record executing:
ClientDataset.Insert
After I have filled all the fields on the new insertion I execute
ClientDataset.Post.
Then on the AfterPost event of ClientDataset I execute:
if (ClientDataset.ChangeCount > 0) then
ClientDataset.ApplyUpdates(-1);
After the execution of ClientDatset.Post an EDBClient exception is
raised informing that the "Field NumReg requires a value"
The value of NumReg field is allways null.
How can I solve this problem?
Thanks for any help.
Marcelo.