Home » SQL & PL/SQL » SQL & PL/SQL » Logon Trigger
Logon Trigger [message #40828] Thu, 07 November 2002 09:02 Go to next message
Lydia Counter
Messages: 1
Registered: November 2002
Junior Member
I need to create a logon trigger to either allow or disallow access to the database. The conditions to disallow access are that :

SELECT ContinueIndicator FROM ApplicationMessage_vw WHERE MessageId = 1
(If ContinueIndicator = 2, you should not access Application)

SELECT RECORDCOUNT FROM SystemLockout_vw
(If RECORDCOUNT > 0, you should not access Application)

I have never written a trigger like this, so please help!

Thanks in advance.
Re: Logon Trigger [message #40830 is a reply to message #40828] Thu, 07 November 2002 09:14 Go to previous message
F. Tollenaar
Messages: 64
Registered: November 2002
Member
8.1.7:

create table ApplicationMessage_vw (continueindicator number, messageid number);
create table SystemLockout_vw (recordcount number);

create or replace trigger NO_ACCESS
after logon
on database
declare
  l_count number;
begin
  select continueindicator
  into   l_count
  from   applicationmessage_vw
  where  messageid = 1;
  --
  if l_count = 2
  then
    raise_application_error(-20001, 'System is not available');
  end if;
  --
  select recordcount
  into   l_count
  from   systemlockout_vw;
  --
  if l_count > 0
  then
    raise_application_error(-20001, 'Lockout already there');
  end if;
end;
/

SQL> insert into SystemLockout_vw values(1);

1 row created.

SQL> commit;

Commit complete.

SQL> conn scott/tiger
ERROR:
ORA-04088: error during execution of trigger 'SYS.NO_ACCESS'
ORA-01403: no data found
ORA-06512: at line 4

Warning: You are no longer connected to ORACLE.

SQL> conn sys
Enter password: ***
Connected.
SQL> 



if you mean you want the number of records instead of the column-value recordcount, then select count(*) from sl-view

hth,
Frank
Previous Topic: schedule a job
Next Topic: how to run packages procedure and function
Goto Forum:
  


Current Time: Mon Apr 29 06:48:28 CDT 2024