Motaz
asked on
Intebase Auto Increment field
I'm using Interbase 5.
My problem is that I want to apply the Auto-Increment field in dbGrid that linked with Interbase in Delphi.
I'm using generator, and I'm tring to use trigger:
create trigger for Test after insert as
begin
Ā Test.ID = Gen_ID(TestGen, 1);
end
it compiles successfully but it do nothing, also what must I do for NOT NULL in primary key (Auto Inc)
I tried also to make it the default value in fields definition:
create Table Test (ID Integer not null primary key default Gen_ID(TestGen, 1), Name VarChar(30));
Also I'm getting an error on that (unknown function -Gen_ID )
Motaz Abdel Azeem
My problem is that I want to apply the Auto-Increment field in dbGrid that linked with Interbase in Delphi.
I'm using generator, and I'm tring to use trigger:
create trigger for Test after insert as
begin
Ā Test.ID = Gen_ID(TestGen, 1);
end
it compiles successfully but it do nothing, also what must I do for NOT NULL in primary key (Auto Inc)
I tried also to make it the default value in fields definition:
create Table Test (ID Integer not null primary key default Gen_ID(TestGen, 1), Name VarChar(30));
Also I'm getting an error on that (unknown function -Gen_ID )
Motaz Abdel Azeem
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, I'll try it
Also if you have the trigger you don't need the default.
The method meikle describes is a better approach (although a bit more work when you have a lot of generator keyed tables. It is hard (if not impossible) for delphi to retrieve the record if it doesn't know the primary key at the time of posting the record.
Regards Jacco.