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!

trying to handle the error messge with a forced disconnect

KersApr 3 2008 — edited Apr 3 2008

I have an after logon trigger with the following code, this is trying to disconnect a user if they have logged onto discoverer 4i too many times (value held in a table).

the trigger is working ok and does not allow then to connect, however it exits with these errors
"Authentication Failed.
(Failed to connect to database - ORA-00604: error occurred at recursive SQL level 1 ORA-20998: Too many discoverer sessions, please try later. ORA-06512: at line 38 ) "

I would like to just show the raised ORA-20998: Too many discoverer sessions, please try later. error, is this possible?
I am trying this on 8.1.7.4, but do have access to 9.2.0.8 if that helps.

create or replace trigger COM_DISCOVERER_SESSIONS
after logon on database 
DECLARE
V_USER VARCHAR(10);
V_SESSIONS NUMBER(3);
V_CONTROL NUMBER(3);
V_Q_SESS NUMBER(3);
V_OTH_SESS NUMBER(3);

BEGIN

      SELECT upper(SYS_CONTEXT('USERENV', 'SESSION_USER'))
      INTO V_USER
      FROM DUAL;  
        
                SELECT COUNT(*)
                  INTO V_SESSIONS
                  from COM_DISC_LOGINS
                  where UPPER(USERNAME) = V_USER;
        
                  IF V_SESSIONS = 0 THEN
                  
                    NULL;
                    
                  ELSE
                 
                      SELECT SCH_USER_CONTROL, SCH_DISC_Q_SESSIONS, SCH_DISC_OTH_SESSIONS
                      INTO V_CONTROL, V_Q_SESS, V_OTH_SESS
                      FROM COM_SCHEMES;
                      
                      
                      IF (V_CONTROL = 1  
                            AND SUBSTR(V_USER,1,2) IN ('WO','PR','ED','SW','WQ','PQ'))
                       OR (V_CONTROL IN (2,3)   
                            AND (SUBSTR(V_USER,1,2) IN ('WO','PR','ED','SW') 
                                AND V_SESSIONS >= V_OTH_SESS )
                            OR (SUBSTR(V_USER,1,2) IN ('WQ','PQ')  
                                 AND V_SESSIONS >= V_Q_SESS)) THEN
                         
                               Raise_application_error(-20998, 'Too many discoverer sessions, please try later.');      
                              EXECUTE IMMEDIATE 'DISCONNECT';
             
                      END IF;
                      
                      
                  END IF;
     
END;

Message was edited by:
Kers

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 1 2008
Added on Apr 3 2008
0 comments
374 views