1.I have created table emp_log using structure of emp table
create table emp_log
as select * from emp
where 1=2;
2.Now I have added some new fields i.e
new_sal(updated salary) ,
upd_by (who updated),
upd_date (Salary update date)
alter table emp_log
add (new_sal number, upd_by varchar2(20),upd_date date);
3. I have made following trigger to insert old and new values (for salary,user and date) in emp_log table whenever I update sal for particular employee in emp table and at the same time i am selecting the updated value of sal into lv_sal variable which will cause mutating error.
create or replace trigger emp_trg
after update of sal on emp
for each row
declare
[code]...
4. Suppose sal of emp is 1000:-
update emp
set sal=sal+100
where empno=7369;
>select * from emp_log;
output:- sal= 1000 new_sal=1100
[code]...
Now the question starts if i commment pragma autonomous_tansaction and commit statement then it gives mutating error because at the same time i am updating and selecting value of sal from emp table.
create or replace trigger emp_trg
after update of sal on emp
for each row
declare
[code]...
Questions:-
1.Is pragma autonomous_transaction handling the mutating error and if yes then how?
2.How many ways are there to handle mutating error.
3.What is the exact definition of Mutating Error.
4.An example or query to use lv_sal variable for printing new updated sal.
5.What is Mutating Table , Is it similar to mutating error (Found this topic while searching for mutating error).
I have created a trigger which gets executed whenever there is DML operation happens on it. I am getting the below error. ORA-04091: table RTS_SCHEMA.TBL1 is mutating, trigger/function may not see it...the tigger is on table tbl1 and the structure of the table is
CREATE TABLE TBL1 ( SLNO NUMBER NULL, DES VARCHAR2(20 BYTE) NULL ) LOGGING NOCOMPRESS NOCACHE NOPARALLEL MONITORING; [code]...
case study: one class has many students, only one student has reward.
original design: drop table student; drop table class;
[Code]...
questions:
1. If I want insert into student values('stu2','cls1','yes'); I can put a trigger on student to check whether it has only one student in class has reward. This trigger should tell me error: I can not let 'stu2' has 'yes' on reward column. But it will lead Oracle error: ora-04091: mutating table. It seems use "after" or "instead of" trigger can solve this problem, so how to do it?
2. Another way to make sure only one student in a class has reward is change design as:
I am unable to understand why row level triggers cant be used in mutating tables.
If you need to update a mutating table, you could bypass these restrictions by using a temporary table, a PL/SQL table, or a package variable. For example, in place of a single AFTER row trigger that updates the original table, resulting in a mutating table error, you might use two triggers--an AFTER row trigger that updates a temporary table, and an AFTER statement trigger that updates the original table with the values from the temporary table.
I have a table EMPLOYEE with columns employee_id and status. I have a requirement that when an employee status is getting changed, then even its linked employee's status also should be changed to the same status value. For this, I need to handle the updating of linked employee's status using a trigger.
Since we get mutating trigger issue when try to update the originating table, I am trying to go with the approach of "in place of a single AFTER row trigger that updates the original table, resulting in a mutating table error, you may be able to use two triggers. The first is an AFTER row trigger that updates a temporary table, and the second an AFTER statement trigger that updates the original table with the values from the temporary table".
But however I am still facing the same issue.
Test case:
CREATE TABLE EMPLOYEE ( EMPLOYEE_ID VARCHAR2(1), STATUS NUMBER(9) );
INSERT INTO EMPLOYEE VALUES ('A',1); INSERT INTO EMPLOYEE VALUES ('B',1); commit; [code]....
Also, any alternate options (rather than using 2 triggers with temp table).
In my alert log I am getting the following error quite repeatedly; My application hangs, and have to restart the instance.
CODEORA-00604: error occurred at recursive SQL level 1 ORA-06521: PL/SQL: Error mapping function ORA-06512: at "SYS.OLAPIHISTORYRETENTION", line 1 ORA-06512: at line 6
im new to Database i have to count no of messages based on the minuties like 1-5, 6-15,16-30,>30 min how to write query
select count(*) from table1 where ( select ( (extract(day from column2)-extract(day from column1))*24*60 + (extract(hour from column2)-extract(hour from column1))*60 + extract(minute from column2)-extract(minute from column1)) as Processed_time from table1 ) IN (1,5)
In oracle 11.2.0.3 I am getting, PL/SQL:ORA-00904 TR_STATE_NAME invalid identifier
but the same code compiled without any compilation error (though column name specified was wrong).I corrected the column name and its working fine in 11.2.0.3 now. Is there any enhancement in Oracle Version 11.2.0.3 in terms of compilation error?
My task has more lines of code,so i tried to present here only few lines of code where i am getting the error.The following cursor needs to select data from two tables with some conditions that are included in cursor and place those in other table.I used BULK collect.
CURSOR c_arch_trk (p_run_date DATE, p_nbr_days_arch1 NUMBER, p_nbr_days_arch2 NUMBER ) IS SELECT a.SIS_PGM_START_DATE,a.SIS_PGM_END_DATE,a.PGM_MSTR_NBR,a.PGM_TRK_NBR,a.CNTL_LOCN,a.CMPNY_VNDR_NBR,a.AGRMNT_MSTR_NBR, a.SLS_CONT_NBR,b.PGM_NAME,b.PGM_BASIS,b.AGRMNT_CNTL_LOCN [code]....
Create table students ( Sid number(3), Sname varchar(20) not null, Email varchar(20) not null, Doj Timestamp default sysdate not null, Dob date not null,
[code]....
when i run the above code i m getting error like this...I dont understand wat error it is...Because i didnt reference any column in the check constraint...Thn why it says that i m referencing some column..
Error: SQL> SQL> Create table students 2 ( 3 Sid number(3), 4 Sname varchar(20) not null,
I just create a trigger to fire whenever the quantity on hand for a books table has been updated.when the quantity on hand become zero ,it should call 'insert_reorder' procedure and pass the ISBN for the books. This is my code
CREATE OR REPLACE TRIGGER books_qty_on_hand_trg AFTER UPDATE OF on_hand_quantity ON books FOR EACH ROW BEGIN IF :NEW.on_hand_quantity = 0 THEN insert_reorde_pp (:NEW.isbn) END IF; END;
But i m getting this error
LINE/COL ERROR 4/3 PLS-00103: Encountered the symbol "END" when expecting one of the following: := . ( % ; The symbol ";" was substituted for "EN D" to continue.
I am begginer programing oracle and I have a issue to resolve but I can't resolve it.I have a procedure that upload a image from a directory. But when I pass the path, the function bfilename put a slash "/" in the path. I don't know why.Here my code.
CREATE OR REPLACE PROCEDURE p_grava_assinatura_gestor AS --------------------------------------------------------- -- Crio o Cursor dos Nomes dos Arquivos JPG. -- --------------------------------------------------------- CURSOR cursor_nome_arquivo IS SELECT p.id, (p.empresa || '_' || p.chapa || '.JPG') AS noarq
When i am trying to execute the below in sql. i am getting the error.
create or replace type sum_n as object ( nodes node_d, constructor function sum_n return self as result, member procedure do_s (m date,exd varchar) ); /
LINE/COL ERROR -------- ----------------------------------------------------------------- 0/0 PL/SQL: Compilation unit analysis terminated 2/9 PLS-00201: identifier 'NODE_d' must be declared
Successfull installation of my Oracle Client was done.When i opened Enterprise Manage Console and i try to login to a database, the following error occurs
" The procedure entry point kpufhndl() could not be located in the dynamic link library OCI.dll "
In first run, 16,36,897 were inserted successfully in around 38 seconds.But in second run, 54,62,952 records had to be inserted, but process failed after 708 seconds with following error :
Error report: ORA-04030: out of process memory when trying to allocate 980248 bytes (PLS non-lib hp,DARWIN) ORA-06512: at line 21 04030. 00000 - "out of process memory when trying to allocate %s bytes (%s,%s)" *Cause: Operating system process private memory has been exhausted *Action:
Here is my code snippet : ....... FORALL i in products_tab.first .. products_tab.last INSERT INTO tab1 VALUES products_tab(i); COMMIT; .........
I think that there should not have been any problem in getting it completed successfully.
I have a trigger that is called from an update on the table, this trigger performs the procedure and this procedure update the Same record in the table That shot the trigger. this situation returns error ORA-0060 - DEADLOCK DETECTED WHILE WAITING FOR RESOURCE. Is there any way that this works?