Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Allow only particular users based on list of users in a table

rcc50886Jun 3 2013 — edited Jun 3 2013
We have a situation where we need to allow particular users which are stored in a table.
create table ALLOW_USERS (username varchar2(30) );

CREATE OR REPLACE TRIGGER USERS_TRIGGER
   AFTER LOGON
   ON DATABASE
DECLARE
BEGIN
  IF DBMS_STANDARD.LOGIN_USER NOT IN (SELECT USERNAME FROM ALLOW_USERS)

	    THEN
		     RAISE_APPLICATION_ERROR (-20001, 'Unauthorized login');
	  END IF;
END;
/

Warning: Trigger created with compilation errors.

SQL> show error
Errors for TRIGGER USERS_TRIGGER:

LINE/COL ERROR
-------- -----------------------------------------------------------------
3/3      PL/SQL: Statement ignored
3/38     PLS-00405: subquery not allowed in this context
How to use subquery on the above trigger ? or is there any better way to achive required results .

-Thanks
This post has been answered by Solomon Yakobson on Jun 3 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 1 2013
Added on Jun 3 2013
10 comments
489 views