"localhost:/firebird/data/ILICHEVSK2.FDB". Триггеры Previous topic Chapter index Next topic

IT_SETWEIGHTNUMBER

 

Описание

(Нет описания для триггера IT_SETWEIGHTNUMBER)

 

Определение

CREATE TRIGGER IT_SETWEIGHTNUMBER FOR IT
ACTIVE BEFORE INSERT OR UPDATE POSITION 0
as
declare variable TRANSPORTTYPEID integer;
declare variable WEIGHTNUMBERGENNAME varchar(32);

begin
  if ((new.WEIGHTNUMBER is null) and (new.STORAGEID is not null)) then begin
    select TRANSPORTTYPE.TRANSPORTSUBTYPE
      from ITTRANSPORT
        left join TRANSPORTTYPE on (TRANSPORTTYPE.TRANSPORTTYPEID = ITTRANSPORT.TRANSPORTTYPEID)
      where (ITTRANSPORT.INVENTORYID = new.INVENTORYID)
    into :TRANSPORTTYPEID;

    execute procedure IT_GETGENERATOR_WEIGHTNUMBER(TRANSPORTTYPEID, New.STORAGEID, 1)
    returning_values :WEIGHTNUMBERGENNAME;
    execute statement 'select cast(gen_id('|| :WEIGHTNUMBERGENNAME ||', 1) as integer) from rdb$database'
    into TRANSPORTTYPEID;

    new.WEIGHTNUMBER = TRANSPORTTYPEID;
  end
end

 

     Previous topic Chapter index Next topic