Excellent
Phil Adams, November 26, 2005 - 2:43 pm UTC
Tom,
The package/global variable...I think that would actually function as a session-specific setting (other sessions would not see it), correct? If that is the case this is a winning soultion.
Your answer reflects your understanding that there are two different operations of interest: updates and inserts. Thanks for pointing out the direct path load functionality...I did forget that feature. With this application/table I pre-load data into an intermediate table and then import using the APPEND hint. I am not sure if this approach will bypass the trigger (like a direct path load)... Can you respond to this? Relatedly, even though I use the APPEND hint my (somewhat vague) understanding is that this hint only "works" when multiple, specific conditions are met. That is, using the hint does not guarantee it will be used.
November 26, 2005 - 4:42 pm UTC
APPEND will not - insert /*+ append */ is "ignored" if the table has triggers/RI on it:
ops$tkyte@ORA10GR2> create table t ( x int );
Table created.
ops$tkyte@ORA10GR2> insert /*+ append */ into t select 1 from dual;
1 row created.
ops$tkyte@ORA10GR2> select * from t;
select * from t
*
ERROR at line 1:
ORA-12838: cannot read/modify an object after modifying it in parallel
ops$tkyte@ORA10GR2> create trigger t_trigger
2 before insert on t for each row
3 begin
4 dbms_output.put_line( 'trigger' );
5 end;
6 /
Trigger created.
ops$tkyte@ORA10GR2> insert /*+ append */ into t select 1 from dual;
trigger
1 row created.
ops$tkyte@ORA10GR2> select * from t;
X
----------
1
1
ops$tkyte@ORA10GR2>
<b>see we did not get the error as before - because of the trigger...</b>
Now I am baffled
Phil Adams, November 26, 2005 - 5:42 pm UTC
Your first insert /*+ append */ returned "1 row created" and the subsequent select returned an ORA-12838. Why?...the table did not have any trigger.
After you create the trigger you have another successful insert /*+ append */. Isn't that what your example shows?
I just cannot figure out the ORA-12838.
November 27, 2005 - 9:55 am UTC
in order to see that the append happened (a direct path operation), I queried the table.
IF you get the 12838 after an insert /*+ APPEND */, then APPEND was in place.
IF you do not get the 12838 - it was a conventional path insert.
I demonstrated that without a trigger - insert /*+ APPEND */ was "obeyed", and then WITH a trigger - the APPEND hint was ignored.
Unbaffeled
Phil Adams, November 26, 2005 - 11:23 pm UTC
I think I figured this out by looking at some of your previously answered questions...
Specifically, when the SELECT cannot read from the table following an insert /*+ append */ (i.e produces ORA-12838) this indicates that the insert was DIRECT PATH.
Alternately, when a SELECT can read from the table following an insert /*+ append */ this indicates that the insert was NOT a DIRECT PATH.