CodeListing 1: BEFORE CREATE trigger to count objects

SQL> create or replace trigger no_more_than_10
  2  before create on database
  3  declare
  4    l_cnt   number;
  5  begin
  6    if ( user in ( 'A', 'B', 'C' ) )
  7    then
  8        select count(*) into l_cnt
  9          from dba_objects
 10         where owner = USER
 11           and object_type = 'TABLE';
 12
 13        if ( l_cnt >= 10 )
 14        then
 15            raise_application_error ( -20001, 'You can only do 10 things!' );
 16        end if;
 17    end if;
 18  end;
 19  /
 Trigger created.