Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DBGrid to InterBase with GENERATOR

12 views
Skip to first unread message

Robert Schieck

unread,
May 15, 1996, 3:00:00 AM5/15/96
to Sylvia C. Johnson

Sylvia C. Johnson wrote:
>
> I have an InterBase table whose primary key is based on a GENERATOR value which is assigned by a trigger to
> records inserted in the table (on insert event).
> When I use a grid to insert records into this table a message indicating Record/Key deleted is displayed. First,
> I haven't been able to track down where this message is coming from (I assume it was the grid, but I couldn't
> find it in the source). Second, has anyone developed a standard way to address this issue?
> I have been working at something along the lines of refreshing the grid when a record is inserted, but I haven't
> been able to prevent the error message...
>
> Thanks for the help.


You have two choices:

If you remove the calculated fields, and default values from your table, the
problem goes away.

If you want to keep the calculated fields or default values, then you will
have to create a stored procedure that will return the next value of your
generator. In your Delphi application in the beforepost method of you TDataset , make a call
to a TStoredProce to get the next value from your generator through your
stored procedure. Put this value in your table before you post.

Here is an example of the stored procedure to get the value from the generator.


SHOW PROCEDURE getgen
Procedure text:
=============================================================================

begin
rvalue = gen_id(Gen,1);
END


Here is an example of the trigger:

CREATE TRIGGER SETVENUEID FOR VENUE
ACTIVE BEFORE INSERT POSITION 1
as
Begin
if (NEW.VenueID is Null) then
begin
execute procedure GetGen returning_Values NEW.VenueID;
end
end
^

hope this helps

--

Robert Schieck
-----------------------------------------------------------------------
MER Systems Inc.

Client/Server Development and Training using Delphi, InterBase and Oracle

InterBase page http://www.mers.com/interbase.html
udflib page http://www.mers.com/product.html
TDUG page http://www.mers.com/tdug.html -Toronto Delphi Users Group

0 new messages