Help with trigger - for God's sake

DBA Geral (instalação, configuração do banco, scripts do Sql*Plus, shell scripts, batch scripts, etc...)
Post Reply
Doug
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 49
Joined: Wed, 07 Feb 2007 1:08 pm
Location: São Paulo

Help me please ...

I need to do a trigger, which when the user logs on the bank, the same must make an insert in a particular field of a table.

I created a table with only one field and I decided to do the insert in the same for tests, but the trigger does not shoot at all ..

follows the code

Select all

 
create or replace trigger marca_logon 
after logon on database 
begin 
insert into vigia  
values 
(User || ' entrou no systema' || 
    to_char(sysdate, 'DD-MM-YYYY HH24:MI:SS')); 
    COMMIT; 
    END; 
Att
Trevisolli
Moderador
Moderador
Posts: 2016
Joined: Wed, 12 Jan 2005 3:25 pm
Location: Araraquara - SP
Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Brother,

The first thing to do, in my point of view, it would be to put an exception on your trigger, to see if it does not shoot or, shoot and generate an error:

Select all

 
create or replace trigger marca_logon  
after logon on database  
begin  
insert into vigia  
values  
(User || ' entrou no systema' ||  
    to_char(sysdate, 'DD-MM-YYYY HH24:MI:SS'));  
    COMMIT;  
EXCEPTION 
  WHEN OTHERS THEN  
    RAISE_APPLICATION_ERROR(-20001,'Erro ao logar:'||sqlerrm); 
END;  
Try this, and send us the return here.
Dulima-SP
Rank: DBA Júnior
Rank: DBA Júnior
Posts: 193
Joined: Thu, 24 Jan 2008 1:56 pm
Location: SP

Friend you already thought about conducting an audit ??

and only activate a parameter in the bunch and it's already necessary to have DBA previlegio to activate it and see the results ....
Doug
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 49
Joined: Wed, 07 Feb 2007 1:08 pm
Location: São Paulo

Friends, with respect to Grant de DBA, this is not the problem. The User is already with the same.

I already put Exception on the trigger. What should I send to you?
Trevisolli
Moderador
Moderador
Posts: 2016
Joined: Wed, 12 Jan 2005 3:25 pm
Location: Araraquara - SP
Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Did he accuse an error?
inserted something on your table?
If you accused error, send us the mistake please.
Doug
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 49
Joined: Wed, 07 Feb 2007 1:08 pm
Location: São Paulo

Friend, he did not accuse any mistake.

The trigger compiles normally.Dai I go and close my session and myself again, but it does not include anything in the table.

Thanks.
Trevisolli
Moderador
Moderador
Posts: 2016
Joined: Wed, 12 Jan 2005 3:25 pm
Location: Araraquara - SP
Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Brother, I found a surveyed and, I verified that the staff creates in the schema of sys .
maybe only work on it .

Try to create in it, and anything returns here, that I move this topic to the DBA's team here from the forum.

Below is the example I searched:

Select all

 
CREATE OR REPLACE TRIGGER sys.security_check 
  AFTER LOGON ON DATABASE 
DECLARE 
  v_sid      NUMBER; 
  v_isdba    VARCHAR2(10); 
  v_program  VARCHAR2(30); 
  v_osuser   VARCHAR2(30); 
  v_username VARCHAR2(30); 
BEGIN 
  select distinct sid  
  INTO   v_sid 
  from   sys.v_$mystat; 
  select program, osuser, username  
  INTO   v_program, v_osuser, v_username  
  from   sys.v_$session  
  where  sid = v_sid; 
  SELECT sys_context ('userenv','ISDBA')  
  INTO   v_isdba  
  FROM   DUAL; 
  IF (UPPER(v_osuser) != UPPER(v_username)) 
  THEN 
    RAISE_APPLICATION_ERROR 
      (-20001,'You cant access the database!',TRUE); 
  END IF; 
END; 
/ 
Doug
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 49
Joined: Wed, 07 Feb 2007 1:08 pm
Location: São Paulo

Dear Trevisolli,

I created the same trigger, with the user sys and even so nothing was inserted in the table ...
He compiled normally, but when I saw the trigger the same was With an error, I had recompile and the error was from the watch table, which did not exist.
I created the same and the trigger compiled normally. I closed the session and I regained myself with the user sys and again nothing was add in the table.

Select all

 
create or replace trigger sys.marca_logon 
after logon on database 
begin 
insert into vigia 
values 
(User || ' entrou no sistema ' || to_char(sysdate, 'DD-MM-YYYY HH24:MI:SS')); 
    COMMIT; 
EXCEPTION 
  WHEN OTHERS THEN 
    RAISE_APPLICATION_ERROR(-20001,'Erro ao logar:'||sqlerrm); 
END; 
PS - Thank you very much for your attention.
Trevisolli
Moderador
Moderador
Posts: 2016
Joined: Wed, 12 Jan 2005 3:25 pm
Location: Araraquara - SP
Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Brother,

I will send the post to the group of dba's here of the forum.
They can guide us better, okay?
ruevers
Rank: DBA Sênior
Rank: DBA Sênior
Posts: 324
Joined: Fri, 02 Jun 2006 1:48 pm
Location: sp
Contact:

Children ...
What is the bank version ??? This is very important can be a bug.
Another thing ...
has already tried "before logon" instead of after ...
compiled and is invalid ... would have to have given error
Gives a "show errors" after cimpile in SQLPlus ... Show something?
Trevisolli
Moderador
Moderador
Posts: 2016
Joined: Wed, 12 Jan 2005 3:25 pm
Location: Araraquara - SP
Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Well, come on, "my old man."

In case, bankruptcy, I believe it can not interfere with after-logon trigger, but ...

Another thing, can not be (I believe) of Before-Logon, because "before" to enter? How to get this information? I talked to the DBA here and said it has to be with the after.

Errors arose, he informed me that no.

Another thing I confirmed, very important:
Create with sys or, the user who is creating, has explicit permission on objects.

Another thing, did you take a look at the bank's alert to see if there is any information regarding this attempt? Talking here with the DBA, just passed me to be careful with this trigger, because you may not be able to log in.
Doug
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 49
Joined: Wed, 07 Feb 2007 1:08 pm
Location: São Paulo

Good morning

The bank version is 9.2.0.1.0.

I tried to compile the trigger with the before, but it is not possible.

Error: ORA-30508 - Customer logon triggers can not have the Before type.

Att ...
Trevisolli
Moderador
Moderador
Posts: 2016
Joined: Wed, 12 Jan 2005 3:25 pm
Location: Araraquara - SP
Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Doug, Next Brother ...

I followed the steps below, with the user sys and, it worked perfectly.

does a tests there brother, whatever, send us:

Select all

 
--1) tabela  
CREATE TABLE auditoria (usuario VARCHAR2(30), 
                        data    DATE); 
                         
 
--2) trigger 
 
CREATE OR REPLACE TRIGGER log_auditoria AFTER LOGON ON  DATABASE  
 
DECLARE 
 
BEGIN  
   INSERT INTO auditoria (usuario, 
                          data) 
                  VALUES (USER, 
                          SYSDATE); 
   COMMIT; 
EXCEPTION 
  WHEN OTHERS THEN  
     raise_application_error(-20001,'Erro logando no banco:'||sqlerrm);                            
END; 
                         
 
-- depois de logado com Sys e Scott 
SELECT * 
  FROM auditoria; 
 
 
-- resultado  
SCOTT 	27-fev-2008 10:36:40 
SYS   	27-fev-2008 10:37:03 
Doug
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 49
Joined: Wed, 07 Feb 2007 1:08 pm
Location: São Paulo

It's a friend, I think that my Oracle is zuado. I will format my pc and I will try again ...

Thanks a lot for your attention ..

God bless ...
gokden
Rank: DBA Pleno
Rank: DBA Pleno
Posts: 264
Joined: Sun, 19 Aug 2007 8:18 pm
Location: Ribeirão Preto - SP
Lucas de Souza

OCA Developer
Analista de sistemas

Before you do this, make sure this trigger is enable = D
type a

Select all

 ALTER TRIGGER nome_da_trigger ENABLE
AI to confirm even if the trigger is activated Make this select

Select all

 select trigger_name,owner, status from dba_triggers where trigger_name = 'NOME_DA_TRIGGER' 
]]

: -O
diegoleite
Rank: Analista Pleno
Rank: Analista Pleno
Posts: 115
Joined: Sat, 10 Nov 2007 2:54 pm
Location: rio de janeiro
Att,


Diego Leite
DBA ORACLE

Beware of audit triggers in. Do not forget about them

Periodically check the growth of your tables.

or if you connect the Audit Follow your space space.
Doug
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 49
Joined: Wed, 07 Feb 2007 1:08 pm
Location: São Paulo

beleza galera..consegui the expected result ..

Thank you for the help and tips of all ...
jucruzjc
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 57
Joined: Thu, 11 Jan 2007 10:26 am
Location: Santa Bárbaba d'Oeste

Commit in Trigger?
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest