Home > database >  Oracle set up the trigger, trigger prompt ORA - 04098 how to solve
Oracle set up the trigger, trigger prompt ORA - 04098 how to solve

Time:10-08

Do experiment about oracle triggers
1, create a table
SQL> The
create table Scott2 (id integer,
3 the name varchar2 (50));

The table is created,

SQL> The create table Scott. Logtable
2 (log_data date,
3 the action varchar2 (50));

The table is created,


2, build the trigger
SQL> The CREATE OR REPLACE the TRIGGER Scott. LogUpdateTrigger
2 AFTER the INSERT OR UPDATE OR DELETE
The
3 ON Scott4 DECLARE log_action VARCHAR2 (50);
5 the BEGIN
6 IF INSERTING THEN log_action:='Insert';
7 ELSIF UPDATING THEN log_action:='Update'.
8 ELSIF DELETING THEN log_action:='Delete'.
9 the ELSE DBMS_OUTPUT. PUT_LINE ('.. ');
10 END IF;
11 INSERT INTO Scott. Logtable (log_data, action)
12 VALUES (SYSDATE log_action);
13 the END;
14/

The trigger is created

3. Verify the trigger
SQL> INSERT INTO Scott. The Test VALUES (1, "INSERT");
INSERT INTO Scott. The Test VALUES (1, 'INSERT')
*
Line 1 error:
ORA - 04098: the trigger 'SYS. LOGUPDATETRIGGER' is invalid and not through the revalidation


SQL> The UPDATE Scott. The Test SET name='UPDATE'.
The UPDATE Scott. The Test SET name='UPDATE'
*
Line 1 error:
ORA - 04098: the trigger 'SYS. LOGUPDATETRIGGER' is invalid and not through the revalidation


SQL> The DELETE FROM Scott. Test the WHERE id=1;
The DELETE FROM Scott. Test the WHERE id=1
*
Line 1 error:
ORA - 04098: the trigger 'SYS. LOGUPDATETRIGGER' is invalid and not through the revalidation

[prompt triggers and I set up the trigger, just learning Oracle soon, don't know a lot of knowledge, so I came to for help, build the trigger under Scott mode and sys, I always get a zero, but are like 3 validation trigger, strives for the bosses help]

CodePudding user response:

These statements, there is no problem in grammar, remove the user's former hoses, Scott in this mode, try to run it,

CodePudding user response:

Connect to the Scott user by operation, then don't have to add Scott.

CodePudding user response:

Thank you, you reply, I have already solved the problem, indeed because of in different mode,
If is in Scott mode, Scott will remove,
If is in Scott mode can trigger set, to execute the statement in sys mode, so also will be a success,
As for the reason, I don't know, at the same time problem because I get it right, so the solution might not be for some
  • Related