Can anyone kindly explain what mutative triggers are in Oracle?
hi
Can anyone kindly explain what mutative triggers are in Oracle with example?
what is frag in oracle?
Oracle raises the mutating table error to protect you from building in-deterministic software.
Let’s explain that with a very simple example. Here’s a simple EMP-table:
ENAME SAL
====== ====
SMITH 6000
JONES 4000Let’s suppose you have a business rule that dictates that the average salary is not allowed to exceed 5000. Which is true for above EMP-table (avg. SAL is exactly 5000).
And you have (erroneously) built after-row triggers (insert and update) to verify this business rule. In your row trigger you compute the average salary, check it’s value and if it’s more than 5000 you raise an application error.
Now you issue following DML-statement, to increase the salary of employees earning less than the average salary, and to decrease the salary of employees earning more than the average salary.
Update EMP
Set SAL = SAL + ((select avg(SAL) from EMP) – SAL)/2;The end result of this update is:
ENAME SAL
====== ====
SMITH 5500
JONES 4500Note that the business rule is still OK: the average salary still doesn’t exceed 5000. But what happens inside your row-trigger, that has a query on the EMP-table?
Let’s assume the rows are changed in the order I displayed them above. The first time your row trigger fires it sees this table:
ENAME SAL
====== ====
SMITH 5500
JONES 4000The row trigger computes the average and sees that it is not more than 5000, so it does not raise the application error. The second time your row trigger fires it sees the end result.
ENAME SAL
====== ====
SMITH 5500
JONES 4500For which we already concluded that the row-trigger will not raise the application error.
But what happens if Oracle in it’s infinite wisdom decides to process the rows in the other order? The first time your row trigger executes it sees this table:
ENAME SAL
====== ====
SMITH 6000
JONES 4500And now the row-trigger concludes that the average salary exceeds 5000 and your code raises the application error.
Presto. You have just implemented indeterministic software. Sometimes it will work, and sometimes it will not work.
Why? Because you are seeing an intermediate snapshot of the EMP-table, that you really should not be seeing (that is: querying).
This is why Oracle prevents you from querying the table that is currently being mutated inside row-triggers (i.e. DML is executed against it).
It’s just to protect you against yourself.
(PS1. Note that this issue doesn't happen inside statement-triggers)
(PS2. This also shows that mutating table error is really only relevant when DML-statements affect more that one row.)
Edited by: Toon Koppelaars on Apr 26, 2010 11:29 AM
Similar Messages
-
Can anyone pls explain what this procedure does?
i could only figure out that it will be performing a transpose.
create or replace
PROCEDURE TEST_TRANSPOSE(o_test OUT SYS_REFCURSOR) AS
report_exists number(3);
report_name varchar(30) := 'REPORT_TBL' ;
query_main varchar(16000) := 'create table ' || report_name || ' as select MAGAZINE ' ;
query_part varchar(1024) ;
my_var varchar2(5);
cursor cur_region is select distinct REGION from MAIN_TBL order by region;
begin
select count(*) into report_exists
from tab
where tname = report_name;
if ( report_exists = 1 ) then
execute immediate 'drop table ' || report_name ;
end if;
open cur_region ;
loop
fetch cur_region into my_var ;
exit when cur_region%NOTFOUND;
query_part := 'select nvl(sum(quantity),0) from MAIN_TBL x where x.magazine = main.magazine and x.region='''||my_var||'''' ;
query_main := query_main || chr(10) || ',(' || query_part || ')"' || my_var || '"';
end loop;
close cur_region ;
query_main := query_main || ' from (select distinct MAGAZINE from MAIN_TBL ) main' ;
DBMS_OUTPUT.PUT_LINE(query_main);
--execute immediate query_main ;
open o_test for query_main;
end;
{code}
i need to transpose a table which has dynamic number of rows.This was what i tried.Could you pls bhelp me out to correct this i get "P_TRAN_YEAR" invalid identifier
[code]
create or replace
PROCEDURE PRM_R_MAT_RPT (p_EmpID IN Integer,
P_TRAN_YEAR IN NUMBER,
P_TRAN_MONTH IN NUMBER,O_rc OUT sys_refcursor) IS
v_cnt NUMBER;
v_sql VARCHAR2(32767);
v_basic Number(16, 4);
BEGIN
select PPH_ORG_AMOUNT into v_basic from prm_p_hop
where pph_emp_id=p_empid
and pph_tran_year=p_tran_year
and pph_tran_month=P_TRAN_MONTH
and pph_hop_code=5
and PPH_SALARY_THRU='R';
-- SELECT distinct count(*)
-- INTO v_cnt
-- FROM PRM_T_VAR_HOP
-- where PTVH_EMP_ID=p_EMPID
-- and PTVH_TRAN_YEAR=p_TRAN_YEAR
-- and PTVH_TRAN_MONTH=P_TRAN_MONTH;
v_sql := 'select distinct PCH_SHORT_DESCRIPTION,v_basic,PTVH_AMOUNT Amount ';
-- FOR i IN 1..v_cnt
-- LOOP
v_sql := v_sql || ',max(decode(rn, PCH_SHORT_DESCRIPTION)) as description ';
--v_sql := v_sql || ',max(decode(rn, '||to_char(i)||', PDSL_INTEREST)) as interest'||to_char(i);
-- v_sql := v_sql || ',max(decode(rn, '||to_char(i)||', PDSL_PRINCIPAL_SALARY)) as principle'||to_char(i);
-- v_sql := v_sql || ',max(decode(rn, '||to_char(i)||', PDSL_SOCIETY_CODE)) as SOC_CODE'||to_char(i);
-- END LOOP;
v_sql := v_sql || ' from (select PRM_T_VAR_HOP.*, PRM_C_HOP.*, row_number() over (partition by PTVH_EMP_ID order by PTVH_EMP_ID) as rn
from
PRM_T_VAR_HOP,
PRM_C_HOP
WHERE PTVH_EMP_ID =P_empid
And PTVH_TRAN_YEAR =P_TRAN_YEAR
And PTVH_TRAN_MONTH =P_TRAN_MONTH
And PTVH_HOP_CODE =PCH_HOP_CODE
AND PCH_CALCULATION_BASIS=''V''
AND PCH_TAG =''C''
AND PTVH_SALARY_THRU =''R'')';
OPEN O_rc FOR v_sql;
END;
[/code]Your first piece of code does not work, because a create table statement cannot be issued using a ref cursor like that. When executed with the "execute immediate" command, it works. Then, the refcursor is only a "select * from report_tbl".
What it does, is dynamically dropping and creating a table report_tbl and filling it with the results of a horribly inefficient pivot query. If the report_tbl has no other purpose after running this procedure, then I'd suggest to not drop and create tables dynamically like that. In the second variant of test_transpose, you can see how you can do that.
SQL> create table main_tbl (magazine,region,quantity)
2 as
3 select 'MAGAZINE1','REGION1',1 from dual union all
4 select 'MAGAZINE1','REGION2',2 from dual union all
5 select 'MAGAZINE1','REGION3',3 from dual union all
6 select 'MAGAZINE2','REGION1',4 from dual union all
7 select 'MAGAZINE2','REGION2',5 from dual union all
8 select 'MAGAZINE2','REGION3',6 from dual
9 /
Tabel is aangemaakt.
SQL> create or replace PROCEDURE TEST_TRANSPOSE(o_test OUT SYS_REFCURSOR)
2 AS
3 report_exists number(3);
4 report_name varchar(30) := 'REPORT_TBL' ;
5 query_main varchar(16000) := 'create table ' || report_name || ' as select MAGAZINE ' ;
6 query_part varchar(1024) ;
7 my_var varchar2(7);
8
9 cursor cur_region is select distinct REGION from MAIN_TBL order by region;
10 begin
11 select count(*) into report_exists
12 from tab
13 where tname = report_name;
14 if ( report_exists = 1 ) then
15 execute immediate 'drop table ' || report_name ;
16 end if;
17
18 open cur_region ;
19 loop
20 fetch cur_region into my_var ;
21 exit when cur_region%NOTFOUND;
22 query_part := 'select nvl(sum(quantity),0) from MAIN_TBL x where x.magazine = main.magazine and x.region='''||my_var||'''' ;
23 query_main := query_main || chr(10) || ',(' || query_part || ')"' || my_var || '"';
24 end loop;
25 close cur_region ;
26
27 query_main := query_main || ' from (select distinct MAGAZINE from MAIN_TBL ) main' ;
28 execute immediate query_main;
29 open o_test for 'select * from ' || report_name;
30 end;
31 /
Procedure is aangemaakt.
SQL> var rc refcursor
SQL> exec test_transpose(:rc)
PL/SQL-procedure is geslaagd.
SQL> print rc
MAGAZINE REGION1 REGION2 REGION3
MAGAZINE1 1 2 3
MAGAZINE2 4 5 6
2 rijen zijn geselecteerd.
SQL> create or replace procedure test_transpose (o_test out sys_refcursor)
2 as
3 l_query varchar2(1000) := 'select magazine';
4 begin
5 for r in (select distinct region from main_tbl)
6 loop
7 l_query := l_query || ', sum(decode(region,''' || r.region || ''',quantity)) ' || r.region;
8 end loop;
9 l_query := l_query || ' from main_tbl group by magazine';
10 open o_test for l_query;
11 end;
12 /
Procedure is aangemaakt.
SQL> exec test_transpose(:rc)
PL/SQL-procedure is geslaagd.
SQL> print rc
MAGAZINE REGION1 REGION2 REGION3
MAGAZINE1 1 2 3
MAGAZINE2 4 5 6
2 rijen zijn geselecteerd.Regards,
Rob. -
Can anyone help explain what 'goflag' means
to all you lingo gurus out there..................lol! i have
just been reading a piece of code and really need to know what the
term 'goflag means? here is the full code:
on exitFrame me
global goflag
if goflag = 1 then
update
end if
if the frame = 28 then go frame "begin"
end
thank you help would be much appreciated!
happy may day!
rainbowii7'flag' normally means a variable that can have one of two
values: TRUE or FALSE. In Lingo 1 is equivalent to TRUE and 0 is
equivalent to FALSE.
'g' is normally used as a prefix for global variables.
You will need to look for places in the code where goFlag is
set to TRUE or FALSE, in order to understand its purpose.
You can find a script named "Find Globals" at
http://nonlinear.openspark.com/tips/scripts/authortime/.
This can help you understand how another developer has used global
variables. -
Can anyone pls explain about SSR in WebdynPro application?
Hi,
Am having the webdynpro code.I that code they are having one onclik event.When they are clicking on that button link they are returning SSR.handle(parameters).But i cud not found the definition of SSR.handle(parameters) function.Can anyone pls explain what exactly SSR and where they have the definition of that function?
Rgds,
MurugagHi,
SSR or server side rendering is a location-independent rendering method of the Webdynpro framework.Because of the strict separation of layout and content, the framework supports location-independent rendering (client-side versus server-side rendering). In other words, depending on the capabilities of the client device, an HTML page can be rendered either on the server or the client.
A simple browser (simple client) may not support client-side scripting or processing of XML transformations so this client may require that the server generate the HTML page before sending it to the browser. More powerful browsers (advanced clients) can inject the content into the page on the client using XML and JavaScript. This location independence is purely configuration driven and does not require modification to either the application code or the presentation code.
Just verify if your browser is javascript enabled or not.
Regards,
Satyajit.
Message was edited by: Satyajit Chakraborty -
Most entries have codes after them, eg:
abalone/MS
abase/LDSG
abaser/M
abash/LGDhS
abbreviate/nDGNS
aberrantes
aberration/SM
Abilene/M
abjure/yDNSnRG
I can't establish a pattern for them...can anyone tell me what they are for, and if they can be deleted?That are flags to specify what kind of data that entry is and how it can be expanded with a prefix and suffix. The accompanying file *.aff define what those flags mean.
-
We got a new Apple TV for Christmas and it works wonderful. However, my question is this. We are on a satelitte internet system and our bandwidth is limited. Can anyone tell me what effect it will have on using up my 10 megs of bandwidth? If I run over the 10 mgs, the service either slows way down until it is reset on the first of the next month or I have to purchase additional bandwidth and it can get expensive.
Any information would be greatly appreciated.If you only have a 10MB limit on the Internet connection you might as well not have Internet access and certainly should not attempt to stream anything.
If the limit is 10GB, then you will need to be careful with streaming as most video is 1-3GB for a one hour show. -
Hi. I'm using iMovie for the first time. I put in only pictures. No videos. When I hit play, my pictures are playing out of order and some repeat. Can anyone tell me what I'm doing wrong or what I need to change so they play in order? Thanks!
Settings > General > Reset > Reset Network Settings
-
Within music Library can anyone please explain why after I select the option to sort 'Album by Artist' a number of tracks are being treated as separate albums? How can I fix this? I have tried to manually correct by 'drag and drop' individual tracks but that doesn't work. My music library includes a number of repeat album artwork images simply because not all tracks are being listed under the one album making my library more difficult to use than it should. Any advise would be appreciated.
See Grouping tracks into albums.
tt2 -
HT1451 Can anyone tell me what the icon thingy's are at the top on the iTunes playlist
Can anyone tell me what the little icon thingy's are at the top on the iTunes playlist
Play and shuffle just to the right of the playlist name and over to the right an icon to change the view, unless you are looking at a different set of thingys?. Might help to post which version of iTunes. I'm using version 11.0.2.
tt2 -
I recently purchased a shutter release remote for my IPAD camera but the cord is only three feet long and I need an extension cord. I purchased a 3 banded AV extension but it doesn't work. I have been told that I need an extension cord that has AV and Mic to enable the remote shutter release to work with the extension cord. Can anyone tell me what the correct extension cable is and where I can find one? Thanks.
Greetings,
I've never seen this issue, and I handle many iPads, of all versions. WiFi issues are generally local to the WiFi router - they are not all of the same quality, range, immunity to interference, etc. You have distance, building construction, and the biggie - interference.
At home, I use Apple routers, and have no issues with any of my WiFi enabled devices, computers, mobile devices, etc - even the lowly PeeCees. I have locations where I have Juniper Networks, as well as Aruba, and a few Netgears - all of them work as they should.
The cheaper routers, Linksys, D-Link, Seimens home units, and many other no name devices have caused issues of various kinds, and even connectivity.
I have no idea what Starbucks uses, but I always have a good connection, and I go there nearly every morning and get some work done, as well as play.
You could try changing channels, 2.4 to 5 Gigs, changing locations of the router. I have had to do all of these at one time or another over the many years that I have been a Network Engineer.
Good Luck - Cheers,
M. -
Transferred backed-up data from external hard disk to new hard drive on my MacBook Pro which seemed to be successful. I now find that some (or maybe all) old emails have been resent. Can anyone tell me what has happened?
Greetings,
I've never seen this issue, and I handle many iPads, of all versions. WiFi issues are generally local to the WiFi router - they are not all of the same quality, range, immunity to interference, etc. You have distance, building construction, and the biggie - interference.
At home, I use Apple routers, and have no issues with any of my WiFi enabled devices, computers, mobile devices, etc - even the lowly PeeCees. I have locations where I have Juniper Networks, as well as Aruba, and a few Netgears - all of them work as they should.
The cheaper routers, Linksys, D-Link, Seimens home units, and many other no name devices have caused issues of various kinds, and even connectivity.
I have no idea what Starbucks uses, but I always have a good connection, and I go there nearly every morning and get some work done, as well as play.
You could try changing channels, 2.4 to 5 Gigs, changing locations of the router. I have had to do all of these at one time or another over the many years that I have been a Network Engineer.
Good Luck - Cheers,
M. -
I can't get Safari to load period. It quits immediately. According to the troubleshooting, I'm to un-install any third party plug ins. Can anyone tell me what I should be looking for? I don't recall installing anything that wasn't an upgrade.
Unplug your iBook from the AC power, shut it down and take the main battery out for about fifteen minutes. Then you can put the battery back in, plug the power back in and restart. This should reset the USB and FireWire ports.
If that doesn't help, you could reset the Power Management Unit. Follow the instructions in Knowledge Base Article #14449 for resetting your PMU.
You probably should also startup from your Mac OS X install disk and run the Disk Utility to "repair disk" on your hard drive. This will determine if you've got some kind of file directory/software problems with the files on your hard drive.
I'm not much at decoding kernel panic logs, but this line jumps out:
Kernel loadable modules in backtrace (with dependencies):
com.apple.filesystems.udf(1.4.1)@0x28a79000
Did you have a DVD movie in the drive at the time? DVD movie disks are UDF format, but not much else is.
-Doug -
Today I imported quite a lot of Audio CDs. When I wanted to listen to them I realised that most of them aren't in my library. And they did not appear in the recently added list either. Can anyone tell me what happened and where to find them? It's really strange because all the imorts definitely finished. Thanks!
Greetings,
I've never seen this issue, and I handle many iPads, of all versions. WiFi issues are generally local to the WiFi router - they are not all of the same quality, range, immunity to interference, etc. You have distance, building construction, and the biggie - interference.
At home, I use Apple routers, and have no issues with any of my WiFi enabled devices, computers, mobile devices, etc - even the lowly PeeCees. I have locations where I have Juniper Networks, as well as Aruba, and a few Netgears - all of them work as they should.
The cheaper routers, Linksys, D-Link, Seimens home units, and many other no name devices have caused issues of various kinds, and even connectivity.
I have no idea what Starbucks uses, but I always have a good connection, and I go there nearly every morning and get some work done, as well as play.
You could try changing channels, 2.4 to 5 Gigs, changing locations of the router. I have had to do all of these at one time or another over the many years that I have been a Network Engineer.
Good Luck - Cheers,
M. -
I have mac os x10.4.11 Tiger , i tried to update and after I did that when I tried to use itunes, but it doesn't open.. can anyone tell me what I have to do to fix this ??
Hello,
Leopard requirements/10.5.x...
* Mac computer with an Intel, PowerPC G5, or PowerPC G4 (867MHz or faster) processor
minimum system requirements
* 512MB of memory (I say 1.5GB for PPC at least, 2-3GB minimum for IntelMacs)
* DVD drive for installation
* 9GB of available disk space (I say 30GB at least)
Classic/OS9 Apps no longer supported.
Trouble is Apple no longer sells it, check eBay & such for the Retail version, not the Gray Discs...
http://www.ebay.com/sch/i.html?_nkw=mac+os+x+leopard+retail+10.5
There are workarounds if the 867MHz CPU is the only hangup...
http://sourceforge.net/projects/leopardassist/
http://lowendmac.com/osx/leopard/unsupported.html
So we know more about it...
At the Apple Icon at top left>About this Mac, report the version of OSX from that window, then click on More Info, then click on Hardware> and report this upto but not including the Serial#...
Hardware Overview:
Model Name: eMac
Model Identifier: PowerMac6,4
Processor Name: PowerPC G4 (1.2)
Processor Speed: 1.42 GHz
Number Of CPUs: 1
L2 Cache (per CPU): 512 KB
Memory: 2 GB
Bus Speed: 167 MHz
Boot ROM Version: 4.9.2f1 -
I have just bought a new laptop with Windows 8 and cannot load itunes from the existing disc or online as it is incompatible.Can anyone tell me what I can do now to get itunes on to my computer? Thank you
See the futher information area of Troubleshooting issues with iTunes for Windows updates for download advice and direct links if required.
See this migrate iTunes library post for advice on moving the library over from a previous computer and this post on deduplication.
tt2
Maybe you are looking for
-
I have Comcast Internet and have it connected to a Motorla Surfboard modem and have that running directly to a 2TB Time Capsule. The TC is serving as our time machine as well as our wireless router. We lost power in a storm a week ago and can no long
-
How to check paragraph in Reader document using API?
Hi, When I extract the content of the PDF (Reader) document through .Net code, I could see only carriage return character ('\r') when it's a new line. But with '\r' character, I can not say whether it's normal new line or it's a paragraph. Please let
-
Hi, I have just created a fairly simple 75-minute movie in FCP 7, and for the life of me, I can't send it to Compressor to make files for creating a DVD. Compressor will do its thing for a few hours, then "Failed". Then out of curiosity, I tried to e
-
Dynamic Cascading Parameters - cannot select/enter parameter value
I am rather new working with Crystal Reports and am having problems with Dynamic Cascading Parameters. I am using CR 2008 SP2, Version 12.2.0.290. Data is from SQL server. I have a report to print labels for parts in an order. I want to be able to
-
Hi, I have a Report for GL Reconciliation and it shows Source System Balances and GL Balances along with the Variance in these two and % Variance. Sample data is as follows: Year Month SYS Source System Bal GL Balances Variance %