0

I am trying to compare a number which I need to retrieve from the table to execute a trigger.

IF (Select *my table* from *column* where *condition*) < 1
then (something)
else (something)

but when it compile, I get the following error.

Error(2,8): PLS-00103: Encountered the symbol "SELECT" when expecting one of the following: ( - + case mod new not null others avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date pipe

Am I wrong to use select to retrieve the amount to do the check? Please advise.

  • read up on pl-sql if you want to do this on dbms side, otherwise make the logic in your application. – Vegard Nov 23 '13 at 14:51

1 Answers1

0
number cnt := 0;
Select count(*) into val from mytable where *condition*;
if val > 0 then
(something)
else 
 (something)
end if;

This is the kind of logic needed.

Ben
  • 51,770
  • 36
  • 127
  • 149
jim mcnamara
  • 16,005
  • 2
  • 34
  • 51