title: if x not in(select y from table) in oracle
body: <p>I'm fairly new when it comes to pl/sql and oracle, and I'm having some trouble. I'm trying to make a logon trigger that will only allow hosts in something like an "approved_users" table to access a schema. Currently I'm using:</p>
  
  <pre><code> Create or Replace Trigger test_trigger
   AFTER logon on TEST.SCHEMA
   declare
   vhost VARCHAR2(25);
   begin
   select sys_context('userenv', 'host') into vhost from dual;
   if vhost not in(select hostname from approved_users) THEN
   raise_application_error(-20001, 'Access Denied');
   end if;
   end;
  </code></pre>
  
  <p>But I'm getting a message saying, "compiled but with errors" and I'm pretty sure that it's not liking the "if not in(select...." portion of the code. I'm hoping somebody here can give me some help on how to get this working/other ways to go about making this logon trigger.</p>
  
  <p>Thanks.</p>