You are on page 1of 1

ALTER TRIGGER TRG_FPRESCISAO_BIU

As
Declare t_fprescisao_id Type Of Column fprescisao.id;
Begin
/*Inicio da opera��o insert/update*/
If (New.id_fpprocesso Is Not Null) Then
Begin
If (((Select Count(*) total
From fpprocesso
Where fpprocesso.id = New.id_fpprocesso
And fpprocesso.id_tbemphos = New.cod_emp) = 0)) Then
Exception e_geral_id_tbemphos;
End
/*Fim da opera��o insert/update*/

/*Inicio da opera��o insert*/


If (Inserting) Then
Begin
If ((New.id Is Null)
Or (New.id = 0)) Then
Begin
t_fprescisao_id = 1;

While (t_fprescisao_id > 0) Do


Begin
New.id = Gen_Id(gen_fprescisao_id, 1);

Select Count(id)
From fprescisao
Where id = New.id
Into t_fprescisao_id;
End
End
End
/*Fim da opera��o insert*/
End;

You might also like