Subject Re: psql question with trigger
Author Adam
It is not possible with the pseudo code you suggested, however you
can certainly achieve the same thing.

It is pretty easy to create a stored procedure to do the insert, here
is a really simple example you can adapt to your problem.

Our table looks like: Person (ID, Name)

CREATE PROCEDURE "SP_INSERT_PERSON"
(
NAME VARCHAR(100)
)
RETURNS
(
PERSONID INTEGER
)
AS
BEGIN
PERSONID = GEN_ID(GEN_PERSONID,1);
INSERT INTO PERSON (ID, NAME) VALUES (:PERSONID, :NAME);
SUSPEND;
END
^

As Ann said though, if you still want to assign a generated ID inside
a trigger, only do it on a null.

Alternatively, if you expected the record number to be passed in as
the ID, you could create a new field in your person table for the old
record number, index that field and query it later. This would
presume that the old record number was unique though. I wouldn't
bother with doing this though.

Adam



--- In firebird-support@yahoogroups.com, "Dixon Epperson"
<dixonepperson@y...> wrote:
>
> I am trying to write a PSQL that inserts all the values into a table
> except the record number.
> I have a trigger that using a generator creates an incremental
number
> for each new record.
>
> Is there a way to write the PSQL so that after it inserts the values
> it selects the new record number (the one in my table, not the one
in
> the system tables) and returns it. I guess I'm asking how to
select a
> field value based on the cursors current position. Is that
possible?
>
> E. D. Epperson Jr