SQL & PL/SQL :: Avoid Mutating Table Error?

May 16, 2011

Best solution to avoid mutating table error?

View 11 Replies


ADVERTISEMENT

PL/SQL :: Oracle 10g Express - Mutating Table Error

Apr 11, 2013

Oracle version: 10g express.

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:

drop table student;
drop table class;
create table class(
clsid varchar2(9) primary key,
reward_stuid varchar2(9));
create table student(
stuid varchar2(9) primary key,
clsid varchar2(9)

not null references class(cid) on delete cascade);But the question is these two tables has foreign key from each other, is it a good design?.

View 7 Replies View Related

SQL & PL/SQL :: Mutating Trigger Error Using Global Temporary Table?

Jun 21, 2010

How can we overcome mutating trigger error using global temporary table.

Suppose if we use the following trigger we will get mutating trigger error.

CREATE OR REPLACE TRIGGER t1
AFTER INSERT ON emp
FOR EACH ROW
DECLARE
BEGIN
UPDATE emp SET sal=sal+100;
END;
/

View 27 Replies View Related

SQL & PL/SQL :: AFTER INSERT Or UPDATE Trigger Failed - Mutating Table Error

Jul 4, 2013

Table A basically has 4 rows of interest, an outside event changes/inserts let's say row 1.

Row 2 and 3 have to be changed in a trigger depending on the new value of 1.(or not if the value stays the same)

Row 4 is the reference for the update and will not be changed.

My first simple AFTER INSERT or UPDATE trigger obviously failed because of the mutating table error.

View 19 Replies View Related

SQL & PL/SQL :: What Is Mutating Error

Sep 2, 2005

What is Mutating error,have u faced it, I have faced this question so many time in interviews but i have not facing this problem till now.

View 15 Replies View Related

SQL & PL/SQL :: Mutating Error?

Oct 20, 2013

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).

View 8 Replies View Related

SQL & PL/SQL :: Mutating Trigger Error

Jun 13, 2012

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]...

View 5 Replies View Related

SQL & PL/SQL :: Mutating Trigger While Updating Original Table

Feb 18, 2013

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).

View 7 Replies View Related

PL/SQL :: How To Avoid Error ORA-01843

Aug 10, 2012

i am facing problem with date column.when i am trying to do execute a query this works fine

select null as link,'S'||to_char(DATE_OF_JOIN,'YY'),COUNT(STUDENT) "Blue Acres" from STUDENT_RECORD where PROCESSOR=1 and DATE_OF_JOIN >= to_date('0620' || to_char(sysdate, 'YYYY'), 'MMDDYYYY') and DATE_OF_JOIN < to_date('0920' || to_char(sysdate, 'YYYY'), 'MMDDYYYY') group by to_char(DATE_OF_JOIN,'YY')

and when i am trying the below query its showing the only this year dates its not referring the previous years

select null as link,'S'||to_char(DATE_OF_JOIN,'MMDDYY'),COUNT(STUDENT) "Blue Acres" from STUDENT_RECORD where PROCESSOR=1 and DATE_OF_JOIN >= to_date('1220' || to_char(sysdate, 'YYYY')-1, 'MMDDYYYY') and DATE_OF_JOIN < to_date('0320' || to_char(sysdate, 'YYYY'), 'MMDDYYYY') group by to_char(DATE_OF_JOIN,'MMDDYY')

when i am trying below query its showng the error ORA-01843: not a valid month

select null as link,'Fall'||to_char(to_char(DATE_OF_JOIN,'YY')-1),COUNT(STUDENT) "Blue Acres" from STUDENT_RECORD where PROCESSOR=1 and DATE_OF_JOIN >= to_date('0620' || to_char(sysdate, 'YYYY')-1, 'MMDDYYYY') and DATE_OF_JOIN < to_date('0920' || to_char(sysdate, 'YYYY')-1, 'MMDDYYYY') group by to_char(to_char(DATE_OF_JOIN,'YY')-1)

View 11 Replies View Related

SQL & PL/SQL :: How To Avoid Duplicate Rows From Being Inserted In The Table

Dec 21, 2009

I have one table in which I want to restrict some records from being inserted. I don't want to put any checked constraints. e.g. consider following table

transaction(
id number primary key,
txn_date timestamp(7),
payee varchar2(40),
amount number,
memo varchar2(40),
ref_num number
)

I want to write SQL which should not inset duplicate record.

e.g.

I have written one as bellow:

insert into transaction
select 1, to_date('2009-12-12','YYYY-MM-DD'), 'Payee1', 12, 'Test', 212 from dual where
(select count(*) from transaction where txn_date=to_date('2009-12-12','YYYY-MM-DD') and
payee='Payee1' and amount=12)=0;

Can I use exists/not exists, which query will be more appropriate. (Please consider that fields which I am using to filter out the duplicate transactions does not contain primary key.)

Can I write such SQL. Or do i check for duplicate rows one by one and then filter the duplicate records.

View 21 Replies View Related

How To Avoid Table Data To Physical Standby Database

Jun 28, 2013

Our client requirement is to avoid table data to physical standby database.

View 3 Replies View Related

SQL & PL/SQL :: Refer A Table In Different Schema - Avoid Database Links

Jul 23, 2013

is there any way to refer a table which is in different schema other than using DB links.

View 5 Replies View Related

Forms :: How To Avoid (no List Elements Defined For List Item) Error

Sep 27, 2011

I am creating the Dynamic list but when i am compiling the form it gives the compilation error "No list elements defined for the list item".

I can eliminate it by entering the dummy list element but this dummy value will be displayed at form run time.

View 1 Replies View Related

SQL & PL/SQL :: Mutating Tables And Row Level Triggers?

Feb 24, 2010

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.

View 1 Replies View Related

How To Avoid Ora-03134

Apr 19, 2011

We have Oracle 8i, 9i, 10g and 11g. I installed oracle client 11gR2 and when I tried connecting to the database, its erroring out saying "ORA-03134 connections to this server version are no longer supported". What client version should I install in order to avoid this error?

View 2 Replies View Related

SQL & PL/SQL :: How To Avoid Max Function

Feb 22, 2010

I have two tables where I have to find the record for Max value of the column sap_pkid for every sap_id as in given table create script. This script is giving correct value but looking for a better way so that when data increses it doesn't hit the performance.

way where max can be avoided or a more tuned query .

create table tab1 (sapid number,
denid number);
create table tab2 (sap_pkid number ,sapid number,
denid number,

[code]...

View 2 Replies View Related

SQL & PL/SQL :: Avoid Divisions By Zero?

Feb 25, 2013

I have a query that performs the sum of a field and divides by the number of occurrences, got me a problem because if there are no occurrences would cause a divide by zero error in Query.

The solution I found might not have been the best, but at the time was possible.

I put a Case, when the sum of the number of occurrence is zero then return zero, otherwise performs the division of the sum of the values by the number of occurrences.

SELECT CLIENT_ID,
TO_NUMBER(TO_CHAR(DTPROC, ''YYYYMM'')),
DTPROC, EXCHANG_VAL,

[Code]....

Now this query is very slow, because have CASE,SUM and GROUP BY, so I need to optimize it.

do this validation (if the divisor is zero) more performance?

View 5 Replies View Related

PL/SQL :: Way To Avoid (group By)

May 14, 2013

select T2.name,sum(T1.area)
from (select * from country) T1,T2i wrote very simple just to show you the problem, bu i think here we should add "group by".
but is there any way to avoid group by?because i don't want to group any thing!

oracle11g

View 4 Replies View Related

SQL & PL/SQL :: Avoid Duplicity In String

Mar 5, 2013

I have created a procedure which sends mail to the users by using the smtp operation. I am collecting the email id of the users and then concatenating the same using the loop.

Everything is working fine, but if some person is coming multiple times in the loop, then his/her name is shown multiple times in the CC/BCC part (Although mail is sent once), it should be restricted to one time.

what i am doing is:

I have declared id_collector and it is concetenating the email as per the condition loop

........ some code here....
id_collector:=id_collector||email_id||';';
end loop;

Now, I want to check before concatenating that email already exists or not.

Example:

suppose value of id_collector= 'abc@gmail.com;pqr@gmail.com;rst@gmail.com;xyz@gmail.com;'
and again if email id comes - 'abc@gmail.com', then it should get rejected.

I think it can be done using reg_exp but I have messed up with that.

View 2 Replies View Related

Forms :: Avoid Duplication In Three Tables

Jan 31, 2013

I'm creating oracle form to allow the user to register a new record in a table, I want to check the duplication in Four tables! which means, the user is able to save the record if it's NOT already registered in the other four tables.By checking P_ID (user parameter). this is my

Declare
v_count number;
begin
select count(*) into v_count ---Checking the 1st table
from 1_table
where p1_id=:p_id;
if (v_count>0) then
message ('Duplicate');
[code]....

View 4 Replies View Related

SQL & PL/SQL :: How To Avoid Multiple Function Calls

Jul 23, 2013

I have a function that is being called three time using UNION and wanted to know if this can be improved to just one call while incorporating all the table joins.

select field1,fdate,fname,username,stepnum from (
SELECT M.FIELD1,
TO_CHAR (M.FIELD_DATE, 'MM/DD/YYYY HH24MISS') AS FDATE,
M.FIELDNAME AS FNAME,
M.USERNAME,

View 10 Replies View Related

Forms :: How To Avoid FRM-40401 Message

Oct 16, 2008

While I am inserting and updating the values in the oracle database its showing a message 'FRM-40401 - No changes to save.' I don't want this message to be shown. How can I do that?

View 5 Replies View Related

Forms :: Avoid The User To Select Twice The Same Value From LOV?

Aug 21, 2010

i have created form. one field is there "Payment_terms" at line level. for that i created LOV containing 3 fixed Payment terms. my requirement is that Avoid the user to select twice the same value from LOV.

View 8 Replies View Related

How To Avoid Parallel Execution In Database

Dec 5, 2012

In my database is present undesirable parallelization of the query. All involved tables has degree=1,

if I right understood there is no method to avoid this except reducing of degree of indexes ? I'm using 11.2.0.3

View 3 Replies View Related

PL/SQL :: Avoid Cartesian Join In Query?

Oct 24, 2012

must generate a Cartesian join, but I do not know why it happens. dt.debtorkey, cl.clientkey, inv.invoicekey, ag.agingkey are primary keys of each table. The problem is: I got same tuple for 8 times.

select dt.debtorkey, cl.clientkey,  inv.invoicekey, ag.agingkey, dt.DebtorNo, dt.Name as "debtor Name", dt.State,  cl.ClientNo, cl.Name as "Client Name",  inv.InvNo, inv.PurchOrd, inv.Amt,
to_char(inv.InvDate, 'MM-DD-YY') invoice_date,  to_char(ag.DateLastBuy, 'MM-DD-YY') aging_lastbuy, to_char(ag.DateLastPmt, 'MM-DD-YY') aging_lastpmt

[code]...

View 14 Replies View Related

Forms :: Avoid Duplicate At Entry Level

May 17, 2011

How can i avoid duplicate entry at entry level in form rather than when i pressed save button

View 2 Replies View Related

Performance Tuning :: Unable To Avoid Indexes

May 20, 2011

Below query is getting delayed becasue of BitMap Indexes on the table. I am trying to avoid indexes by using Hints in the query but unable to do so, Details are as follows.

explain plan for
SELECT cbu_cid, cbu_cid_customer_en_nm,
COUNT (billg_acct_no) AS billg_acct_no,
SUM (subscriber_cnt) AS subscriber_cnt
FROM daily_view
WHERE (billg_system_id = 'TM' AND mktg_sub_segment_a_nm = 'TM')
AND (cbu_cid NOT IN ('0001988048', '0001379962', '0001350469'))
GROUP BY cbu_cid, cbu_cid_customer_en_nm
HAVING SUM (subscriber_cnt) > 10
ORDER BY subscriber_cnt DESC;
[code]....

I have tried with ALL_ROWS & PARALLEL.how to avoid above two indexes in a query.

View 28 Replies View Related

SQL & PL/SQL :: Avoid NVL Condition Suppressing Index Usage?

Feb 1, 2012

I have index on column column1 and because of the nvl, the optimizer is not picking up the index

How can I restructure the query to avoid nvl giving same result using index on column1?

now column1 and column2 are varchar2 fields here

where nvl(column1,'*')=(nvl(:param1,nvl(column2,'*'))

can I use case statement like

case when column>'' then .. stuckup here

View 7 Replies View Related

Server Administration :: How To Avoid Blocking Locks

Nov 8, 2011

how to avoid blocking locks.

View 27 Replies View Related

PL/SQL :: Avoid Record Creation With Similar Names

Oct 17, 2013

am trying to add a validation in Oracle forms using Oracle DB.in a Oracle table consider there is a record named 'Netbook' then if I try to create another record with name 'Netbooks', then a Oracle warning message should be displayed stating similar name 'Netbook' is already available. same way, if NETBOOKS is already available in table and if user try to create another record NETBOOK then same warning message netbooks is already available should be shown. 

View 17 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved