Subject Re: This trigger
Author Adam
--- In firebird-support@yahoogroups.com, ShepherdHill DB Subscriptions
<db.subscriptions@...> wrote:
>
> Hi,
>
> What am I doing wrong here?
>
> ----
> SET TERM ^ ;
> CREATE TRIGGER HALL_ALL_NAMA ACTIVE
> BEFORE INSERT POSITION 0
> AS
> BEGIN
> NEW.nama = (SELECT nama FROM pool WHERE matric = NEW.matric);
> END^
> SET TERM ; ^
> ----

That is obviously not your exact code, because you haven't said what
table the trigger is even on, secondly, your subselect logic is not
going to work like that.

SET TERM ^ ;

CREATE TRIGGER HALL_ALL_NAMA
FOR HALL_ALLOCATION
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
SELECT nama
FROM pool
WHERE matric = NEW.matric
INTO NEW.nama;
END^
SET TERM ; ^

Note that if there is no record in pool with Matric = New.Matric, then
New.Nama will be left at whatever it is inserted as. It will not be
set to null unless that is what your insert statement sets it to.

Adam