-5

Compilation failed, line 10 (14:27:16)
The line numbers associated with compilation errors are relative to the first BEGIN statement. This only affects the compilation of database triggers.

PLS-00103: Encountered the symbol ";" when expecting one of the following: . ( ) * @ % & - + / at mod remainder rem with and or group having intersect minus start union where connect || multiset The symbol ";" was ignored.**

create or replace trigger "PROMOS_T2"
  BEFORE insert or update on "PROMOS"    
  for each row    
DECLARE    
  ma_exp1 EXCEPTION;    
  ma_exp2 EXCEPTION;    
  ma_exp3 EXCEPTION;
  cap LOGTS.CAPACITE%TYPE;    
  nbr INTEGER;    
begin
  SELECT COUNT (*) INTO nbr FROM LOGTS  WHERE :NEW."IDLOG"=IDLOG;
  SELECT CAPACITE INTO cap FROM LOGTS WHERE :NEW."IDLOG"=IDLOG;
  if (exists(SELECT * FROM PROMOS WHERE :NEW."IDPROMO"=IDPROMO;) )THEN
    RAISE ma_exp1;
  elsif nbr=1 AND cap < :NEW."NBPLACES" THEN
    RAISE ma_exp2;
  else
    RAISE ma_exp3;
  end if;
EXCEPTION
  WHEN ma_exp1 THEN
    RAISE_APPLICATION_ERROR(-20004,'la promos dèja existe');
  WHEN ma_exp2 THEN
    RAISE_APPLICATION_ERROR(-20005,'PAS DE PLACE');
  WHEN ma_exp3 THEN
    RAISE_APPLICATION_ERROR(-20006,'IDLOG nexiste pas');
end;
Luke Woodward
  • 63,336
  • 16
  • 89
  • 104

1 Answers1

3

Take a look at the error message, in particular, the parts

Compilation failed, line 10

and

Encountered the symbol ";"

This is line 10:

if (exists(SELECT * FROM PROMOS WHERE :NEW."IDPROMO"=IDPROMO;) )THEN

See the problem?

Your compilation error is being caused by the semicolon in that line. Removing it will help, but your code will still fail to compile, because you can't call EXISTS in PL/SQL outside of SQL. To fix that, see the answers to this question.

Community
  • 1
  • 1
Luke Woodward
  • 63,336
  • 16
  • 89
  • 104