I can not execute a procedure in Firebird

2

Good afternoon, guys. I need to insert a record in the database but no duplication. I tried this:

create procedure My_Proc
as begin

if(not exists(select * from alunos where nome = 'Mateus')) then

insert into Alunos (Matricula, Nome, Idade, OBS) 
values (6, 'Mateus', 5, 'É terrível');

end

Does not recognize the ';' at the end of the insert command. If I get the ';', it does not recognize the END. Does anyone know what's missing?

I'm using Flaming Robin.

NOTE: If I use execute block, the same errors happen.

    
asked by anonymous 02.01.2019 / 16:16

1 answer

1

Maybe using SET TERM ( Instructions set term) solves your problem.

create procedure My_Proc
 as begin


 SET TERM  ^;

 if(not exists(select * from alunos where nome = 'Mateus')) then

 insert into Alunos (Matricula, Nome, Idade, OBS) 
 values (6, 'Mateus', 5, 'É terrível');

 end ^
    
02.01.2019 / 16:29