CREATE OR ALTER trigger ttbpedido_item_b01i for tbpedido_item
active before insert position 0
as
begin
  if (new.id is null) then
  BEGIN
    new.id = gen_id(gtbpedido_item,1);
    NEW.CONTROLE = CAST('1'||FN_LPAD(NEW.PEDIDO, 6, '0')||FN_LPAD(NEW.SEQUENCIA, 3, '0') AS INTEGER);
  END


end;