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


ADVERTISEMENT

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 :: 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 :: Global Temporary Table

Feb 20, 2010

What is the best option for GLOBAL TEMPORARY TABLE

1) option create GLOBAL TEMPORARY TABLE with ON COMMIT DELETE ROWS. and wheverever this is used for calculation commit at the end of porcedure.

CREATE GLOBAL TEMPORARY TABLE gtt_test
(
A NUMBER
)ON COMMIT DELETE ROWS;

CREATE OR REPLACE PROCEDURE my_proc ( p_in in number)
as
begin

[Code]....

2) create GLOBAL TEMPORARY TABLE without ON COMMIT DELETE ROWS and wheverever this is used use delete from Temp table /Truncate table and then user it.

CREATE GLOBAL TEMPORARY TABLE gtt_test
(
A NUMBER
);

CREATE OR REPLACE PROCEDURE my_proc ( p_in in number)

[Code]....

View 26 Replies View Related

Alternatives For Global Temporary Table

Mar 12, 2013

I have created global temporary tables to be used in my stored procedure, in order to view reports which i created in JASPER. Since global temporary tables are session based, when multiple users are trying to generate the report, every user is getting inconsistent data.

To make it clear, what i meant is if a user A tries to view a report with some filter criteria and simultaneously user B is trying to generate the same report with another filter criteria, User A is getting User B's report data and User B is getting User A's report data. How can we avoid this problem?

View 1 Replies View Related

SQL & PL/SQL :: Drop Global Temporary Table?

Dec 6, 2011

how to drop global temporary table?

while droping global temporary table we are getting below error

"ORA-14452: attempt to create, alter or drop an index on temporary table already in use"

View 1 Replies View Related

SQL & PL/SQL :: Global Temporary Table DDL In Schema

Dec 21, 2011

How to allow only "CREATE GLOBAL TEMPORARY TABLE" DDL in a schema. I have to restrict all DDLs performing by a particular schema except GT Table.

View 8 Replies View Related

SQL & PL/SQL :: Global Temporary Table And JAVA?

Dec 3, 2011

I am using a global temporary table in which place data from a few different queries.

It then select it out into a cursor.

This procedure works fine in PL.SQL Developer and Toad. It doesn't have to be adjusted.

Java has a problem though, as the data is gone when the Java call attempts to acquire it. This is due to session pooling I suppose.

So, my question is somewhat composite.

Is there a setting in Java (JDeveloper) that I could overcome this with? Perhaps a momentary "Hold" on a session?

View 6 Replies View Related

PL/SQL :: Not Able To Update Global Temporary Table

Oct 17, 2012

create or replace procedure p_populate_gtt
as
begin
insert into gtt
select last_name,first_name,null from funcdemo where rownum <51;
update gtt set vote=100
where ln ='Tim';
end;
/

gtt is my global temp table. i am updating vote column which is null to 100.But i am not able to update it

View 21 Replies View Related

SQL & PL/SQL :: Can Lock Data In Global Temporary Table

Nov 15, 2011

Can we lock data in global temporary table?

View 4 Replies View Related

SQL & PL/SQL :: Global Temporary Table And Autonomous Transaction?

Jul 15, 2013

The actual flow, works on this way:

The Procedure A extracts and filter some data from the DW, this data is stored on the Global Temporary Table. Another Procedure, named B, use the data from the Global Temporary Table and store it on a normal table using another procedure Named X that Merge the data from Global Temporary against the Normal Table (inserting if not exist and updating some fields if exist).

(X isn´t important on the new flow)

Now, i need to add some steps on the normal flow:

The Procedure A extracts and filter some data from the DW, this data is stored on the Global Temporary Table. Another Procedure, named B, use the data from the Global Temporary Table and store it on a normal table. Using the Data from Global Temporary Teble i must to Store some fields on another normal table, for this i use another Procedure named C that merge the data from Global Temporary Table against the data from normal table, and i must to commit at this point. X Merge the data from Global Temporary Table and the data from the Normal table con the procedure "C" against another Normal Table (inserting if not exist and updating if exist).

The issue that i´m expecting is that i can´t use "C" for merge and commit, because this truncate the data on the global temporary table. I can´t change the on commit delete rows option, because another procedures are using this Global Temporary Table on production.

Before you ask, i try using AUTONOMOUS_TRANSACTION on "C" and didn´t works because "C" can´t found data on the Global Temporary table ( i use a select count on "C" from Global Temporary), this is because The Autonomous_Transaction (i think). So, what i can do? I tried to trace the session Number on C and A and with the AT is the same ( so isn´t session change problem).

I need:Commit on the Procedure "C" without Truncating Global Temporary Table because i need this data for X.

View 7 Replies View Related

SQL & PL/SQL :: Executing A Procedure Containing A Global Temporary Table

Mar 3, 2010

create or replace procedure test
as
stmt varchar2(2000);
begin
EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE tt_Local(ID VarChar2(38)) ON COMMIT PRESERVE ROWS';

stmt := 'INSERT INTO tt_Local SELECT cardnumber FROM cards';
execute immediate stmt;
end;

-- when am trying to execute this

begin
test;
end;
-- showing ora-01031, insufficient privileges.

View 9 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

Forms :: How To Insert And Update From Global Temporary Table

May 15, 2013

Global temporary Table Name:

1.MT_GBL
2.DT_GBL
3.DT2_GBL

Base Table Name:

1.MT
2.DT
3.DT2

My Steps:

1.Insert all data from global table to base table.
2.Update all data (that means retrieved all data from base table to global table and update this data). Question: How to Insert and Update from Global temporary table ??

View 4 Replies View Related

SQL & PL/SQL :: Less Number Of Rows Inserted In Global Temporary Table

Sep 8, 2012

how to resolve the following issue ...

insert into GTT (select query) inserting less no. of rows than that returned by the query.

The global temporary table has ON COMMIT PRESERVE ROWS.

View 3 Replies View Related

SQL & PL/SQL :: Partial Data Inserted When Reading From Global Temporary Table?

Jun 25, 2012

I have a complex sql query that fetches 88k records. This query uses a global temporary table which is the replica of one of our permanent tables. When I do Create table..select... using this query it inserts only fewer records. But when I make the query point to the permanent table it inserts all 88k records.

1. I tried running the select query separately using temp and perm table. Both retrieves 88k records.

2. From debugging I found that this problem occurred when we were trying to perform a left outer join on an inline view.

However this problem got resolved when I used the /*+ FIRST_ROWS */ hint.

From my limited oracle knowledge I assume that it is the problem with the query and how it is processed in the memory.

View 1 Replies View Related

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

May 16, 2011

Best solution to avoid mutating table error?

View 11 Replies View Related

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

Global Temporary Tables

Jan 17, 2011

I have two database DB1 for EBS database and DB2 for Portal database. DB2 is always up.

DB1 uses some Global Temporary tables to write and store session level information.

I have Secondary database also for DB1. Whenever DB1 is down and its secondary database base is up, my requirement is to enable write operation to these Global Temporary Tables. Since secondary database we open Read-Only mode , I can't write to these GTTs.

DB2 is always up so I want to create the copies of these GTTs in DB2 portal database. Is there any harm on doing this.

Is there any harm storing session level information of DB1 database In DB2 database through DB-Link.

View 1 Replies View Related

Server Utilities :: How To Export Global Temporary Tables

Apr 18, 2013

There's an Application Express application which is based on a schema named TRAFOGLED. In order to let users test new features, there's a test application (Apex has export/import capabilities; no problem about that) which is based on another schema whose name is TRAFOTEST.

I'd like to export TRAFOGLED and import it into TRAFOTEST.I'm using 10gR2 EXPDP utility with a parameter file. Everything seems to be OK, except the fact that I'm unable to export global temporary tables (GTT). How can I tell? I didn't see them after import!

These are my GTTs:
SQL> show user
USER is "TRAFOGLED"
SQL>
SQL> select table_name from user_tables where temporary = 'Y';

[code]...

C:TEMP>
No tables were exported. Certainly, I don't expect any data to be exported, but I'd be happy with CREATE TABLE statements so that I don't have to create these tables separately.

View 4 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

Forms :: Pass Global Variable To DB Trigger?

Dec 6, 2011

how can i pass global variable from form to db trigger ?

i have this trigger:

Create Or Replace Drop Trigger Access_Group_Category_Priv_Trg
After Delete Or Insert Or Update
On Scott.Access_Group_Category_Priv

[Code].....

View 4 Replies View Related

SQL & PL/SQL :: Create Test Table - Trigger Throw Error Message

Mar 4, 2010

create table test123 as (unit varchar2(5),qty varchar2(25));
insert into test123('ABC','10,40,50');
insert into test123('PQR','20,30,40,10');
insert into test123('XYZ','20,10,70');

I have a table called test123 which qty field. if the sum of qty is entered more than 100 or less than 100, it should throw error.

I wrote this trigger..but it is not working.

create or replace restrict_sum
after insert or update of qty on test123
for each row
declare
v_sum number;
[code].........

View 5 Replies View Related

SQL & PL/SQL :: Temporary Table And Bulk Collect Into Type Table

Nov 15, 2011

I am using temporary table.

PROCEDURE Return_Summary(WX IN dbms_sql.varchar2_table,
WX OUT SYS_REFCURSOR) IS

Begin
FOR i IN 1 .. Pi_ WX.count LOOP

/* I need to put this results in a temp table or table object Can I use temp table for this or do we have any other recommended method. The loop might execute max of 10 times and for each run it might return 100-200 records. */

select WX_NM,
WX_NUM
from TAB A, TAB B, TAB C
where A.KEY1 = B.KEY1
and B.KEY1 = C.KEY1
and C.WX = WX(i);
End Loop;
End;

View 5 Replies View Related

SQL & PL/SQL :: How To Create A Temporary Table

Aug 30, 2013

creating a temporary table.i have this query mentioned below

CREATE TABLE WEBPEN AS (SELECT PNSR_PPO_NO PPO,PNSR_FILE_NO,
DECODE(F_GET_APPLN_NO(PNSR_PK),'1',PNSR_VOL_NO,F_GET_APPLN_NO(PNSR_PK)) APPLN_NO,
PNSR_FULL_NAME NAME,
TO_CHAR(PNSR_DOB,'DD/MM/YYYY') DOB,
TO_CHAR(PNSR_DOR,'DD/MM/YYYY') DOR,
F_GET_ADBK_NAME(PNSR_TO_PENSION) TREASURY,
PNSR_SPOUSE_NAME SPOUSE,

[code]....

This creates a table webpen with around 54107 rows. What i am want is every time run "select * from webpen" it should run the above query and give the result as per the values in main table M_PENSIONER ,M_PEN_DCRG_WITHHELD.

What i want is it should truncate the existing values and insert the value by running the above mentioned query .

View 6 Replies View Related

SQL & PL/SQL :: Insert Into Temporary Table

Jun 5, 2005

I migrate procedures MS SQL Server to Oracle.In MS SQL SSERVER the use of instructions INSERT with procedure results which are in storage or dynamic instructions EXECUTE in place of VALUES clause is permissible. This construction is similar to INSERT/SELECT but we have to do with EXEC instead of SELECT. The part of EXEC should include exactly one resulted collection about the equivalent types to the types of table columns. In case of the stored procedure, we can pass on proper parameters, use the form of EXEC('string') and even call up wideranging procedures or remote control procedures from different servers. Calling up remote control procedures from different server, which place data in temporary table, and later realizing join with obtainable data, we can construct diffuse joins. For example. I want insert results stored procedures sp_configure, proc_obj in temporary table.

1)INSERT #konfig
exec sp_configure.

2)
CREATE PROCEDURE proc_test
@Object_ID int,
AS
SET XACT_ABORT ON
BEGIN TRAN
CREATE TABLE #testObjects ( Object_ID int NOT NULL )
INSERT
#testObjects
EXEC
proc_obj @Object_ID,3,1
COMMIT TRAN
RETURN(0)
go

how migrate for example code to Oracle?

View 11 Replies View Related

Reformat Data In A Temporary Table

Apr 26, 2011

Is there a neat way other than having to reformat the data in a temporary table to do the following,I've got the following content in a table:

CODECustid           Type               Nb                Amount
1                  Deposit           2             10000
1                  Withdrawal        1             4000

I'd like to show the data in this manner:

CustID Deposit  DepositAmount  Withdrawal WithdrawalAmount
1       2         10000            1          4000

View 3 Replies View Related

SQL & PL/SQL :: Temporary Disable All Constraint In Particular Table?

Jan 7, 2012

i have one table HR.employees

SQL> desc hr.employees
Name Null? Type
----------------------------------------- -------- ----------------------------

EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)

SQL>

in this table i want to temporary disable all constraint in this employees table

View 4 Replies View Related

SQL & PL/SQL :: Create A Temporary Table With Same Structure

Mar 13, 2013

create table my_rows
(
my_envvarchar2(100),
anumber(2),
bnumber(2)
)
/
insert into my_rows values ('A', 10, 20);
insert into my_rows values ('A', 10, 20);
insert into my_rows values ('A', 10, 20);
insert into my_rows values ('A', 10, 20);
insert into my_rows values ('A', 10, 20);
insert into my_rows values ('A', 10, 20);
insert into my_rows values ('A', 10, 20);
insert into my_rows values ('A', 10, 20);
[code]....

The first row means that the value 10 represents 40% in the couple (10,20). Meaning if I have 100 rows with the couple (10,20), 40 rows will be marked with the value 10 and 60 will be marked with the value 20. To do this, I used to create a temporary table with the same structure as the my_rows table with a new column "the_value" and I used to update this new column wth a PL/SQL for loop. But I think it is doable in a signle SQL.

View 9 Replies View Related







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