Following Trigger created in a user anu
create or replace trigger audit_creation1
before create
on schema
begin
insert into audit_creation
values(audit_creation_s1.nextval,
ora_dict_obj_owner,
ora_dict_obj_name,
sysdate);
end;
create table cc(cid number);
ORA-00604: error occurred at recursive SQL level 1
ORA-30511: invalid DDL operation in system triggers
This worked before many times. It was working successfully.
But now it's throwing error.
Throw a command
purge recyclebin;
as your trigger owner (anu in your case).
Related
I want to create a procedure to create user so i Write:
But appear the following error:
01002. 00000 - "fetch out of sequence"
*Cause: This error means that a fetch has been attempted from a cursor
which is no longer valid. Note that a PL/SQL cursor loop
implicitly does fetches, and thus may also cause this error.
There are a number of possible causes for this error, including:
1) Fetching from a cursor after the last row has been retrieved
and the ORA-1403 error returned.
2) If the cursor has been opened with the FOR UPDATE clause,
fetching after a COMMIT has been issued will return the error.
3) Rebinding any placeholders in the SQL statement, then issuing
a fetch before reexecuting the statement.
*Action:
1) Do not issue a fetch statement after the last row has been
retrieved - there are no more rows to fetch.
2) Do not issue a COMMIT inside a fetch loop for a cursor
that has been opened FOR UPDATE.
3) Reexecute the statement after rebinding, then attempt to
fetch again.
CREATE OR REPLACE PROCEDURE CREA_USUARIOS_PR IS
CURSOR EMPLEADOS_LISTA IS SELECT ID,NOMBRE,DNI FROM EMPLEADO FOR UPDATE;
SENTENCIA VARCHAR2(1000);
BEGIN
FOR EMPLEADO_PUNTERO IN EMPLEADOS_LISTA LOOP
SENTENCIA:= 'CREATE USER '||CONCAT(REPLACE(EMPLEADO_PUNTERO.NOMBRE,' ',''),CONCAT(to_char(EMPLEADO_PUNTERO.ID),'MERC'))||' IDENTIFIED BY '||to_char(EMPLEADO_PUNTERO.DNI)||' DEFAULT TABLESPACE TS_MERC QUOTA 10M ON TS_MERC';
EXECUTE IMMEDIATE SENTENCIA;
UPDATE EMPLEADO SET USUARIO = CONCAT(REPLACE(EMPLEADO_PUNTERO.NOMBRE,' ',''),CONCAT(EMPLEADO_PUNTERO.ID,'MERC')) WHERE CURRENT OF EMPLEADOS_LISTA;
END LOOP;
END;
/
Following is the procedure code snippet:
PRC_UPDATE
BEGIN
UPDATE EMP E SET E.NAME = 'X' WHERE E.E_ID = 'Y';
COMMIT;
EXCEPTION WHEN OTHERS
ROLLBACK;
PRC_ERROR_LOG(E.E_ID,sqlcode,sqlerrm);
RAISE;
END PRC_UPDATE;
I have a procedure which updates the values in a table.I have defined an error logging procedure (PRC_ERROR_LOG)to insert the errors in an Error Logging Table.But while calling PRC_ERROR_LOG it throws an error as "identifier 'E_ID' must be declared". Will it not recognize the Row value in which the error is thrown out.
Basically my requirement is to insert the error and the row where the particular error is caught into the error table .How can I send the particular Row value in the Error Logging Procedure?
Thanks in advance
You should look into using a cursor, the reason that you are experiencing this error is that you have already executed the update statement and the e.e_id is now out of scope. You could also use try-catch to accomplish this.
I'm using sqlte3.8.8, trying to create a trigger to clean old data. Here is the SQL that I put in:
CREATE TRIGGER "main"."NewTrigger" AFTER INSERT ON "historydata"
BEGIN
delete from historydata where id in (select id from historydata order by id limit 100000);
vacuum;
END;
But I got Syntax error on "vacuum;".However, it works fine in sqlite command line.
Is it the case that "vacuum" cannot be used in a trigger?
The documentation shows that only UPDATE/INSERT/DELETE/SELECT statements are allowed in a trigger body.
when i executed the following statements i got some error.
CREATE TABLE TEST_TRG1(NAME VARCHAR2(50),DOB DATE);--table created successfully
CREATE TABLE TEST_TRG2(NAME VARCHAR2(50),DOB DATE);--table created successfully
CREATE OR REPLACE TRIGGER TR_TEST_TRG1
AFTER INSERT
ON
TEST_TRG1
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
BEGIN
INSERT INTO TEST_TRG2 (NAME,DOB) VALUES (:NEW.NAME,:NEW.DOB);
END TR_TEST_TRG1;
/--trigger created successfully
ALTER TRIGGER TR_TEST_TRG1 ENABLE;--trigger enabled successfully
INSERT INTO TEST_TRG1(NAME,DOB) VALUES('1',SYSDATE-4);--got error at this statement
INSERT INTO TEST_TRG1(NAME,DOB) VALUES('2',SYSDATE-3);
INSERT INTO TEST_TRG1(NAME,DOB) VALUES('3',SYSDATE-2);
/
error was
thanks in advance
edit:
table confirmation
executed show errors trigger
I do not know what the error is (I ran your script and got no errors) but to find out, in SQL Plus type this:
show error trigger TEST_TRG1
I am creating this oracle 11g statement inside a java String and then executing it in sql developer. I tried running it on the database and got a warning when the trigger
is created. But, when run from the code, I get the error mentioned in my title.
Please tell me where is the mistake and how i can fix it ?
CREATE OR REPLACE TRIGGER myschema.my_sequence_id BEFORE INSERT ON myschema.mytable
FOR EACH ROW BEGIN SELECT my_sequence_id.nextval INTO :new.mycolumn FROM DUAL; end; /
Thanks in advance !
You can't have a trigger named my_sequence_id if you already have a sequence my_sequence_id. They share the same namespace. Your trigger would need to be named something other than the name of the sequence (or any other object in the schema).