Trigger Table

<pre>
i have audit table as below
CREATE TABLE DS_JOB_LOG
JOB_ID NUMBER,
JOB_NAME VARCHAR2(200),
LOAD_DATE TIMESTAMP,
i am trying to write a trigger which does the job of inserting one sequence number kind of thing for the column JOB_ID in DS_JOB_LOG table.
Trigger should be fired when i insert the data into the columns JOB_NAME and LOAD_DATE .
Process: For every insert on the table it should create one new record and for any update(on JOB_NAME) it updates the row with just LOAD_DATE column
i am not strong at PLSQL could any one help me for this .
CREATE OR REPLACE TRIGGER TRIG_TEST
AFTER INSERT ON DS_JOB_LOG
FOR EACH ROW
BEGIN
UPDATE SCOTT.DS_JOB_LOG JOB_LOG
SET
JOB_LOG.JOB_ID = (
SELECT COALESCE(MAX(LG.JOB_ID),0) + 1
FROM SCOTT.DS_JOB_LOG LG
WHERE
LG.JOB_NAME=:new.JOB_NAME
END;
Regards
naren.

thanks for reply..
i have modified trigger code but trigger is created with error msg.
CREATE OR REPLACE TRIGGER TRIG_TEST
AFTER INSERT ON SCOTT.DS_JOB_LOG
FOR EACH ROW
BEGIN
UPDATE SCOTT.DS_JOB_LOG JOB_LOG
SET
JOB_LOG.JOB_ID = (
SELECT SCOTT.LOG_SEQ.NEXTVAL
FROM SCOTT.DS_JOB_LOG LG
WHERE
LG.JOB_NAME=:new.JOB_NAME
WHERE SCOTT.DS_JOB_LOG.JOB_NAME=:new.JOB_NAME
END;
i have created sequence
CREATE SEQUENCE SCOTT.LOG_SEQ
INCREMENT BY 1
START WITH 1
NOMAXVALUE
NOMINVALUE
NOCYCLE
CACHE 20
NOORDER
GO

Similar Messages

  • Need to increase performance-bulk collect in cursor with limit and in the for loop inserting into the trigger table

    Hi all,
    I have a performance issue in the below code,where i am trying to insert the data from table_stg into target_tab and in parent_tab tables and then to child tables via cursor with bulk collect .the target_tab and parent_tab are huge tables and have a row wise trigger enabled on it .the trigger is mandatory . This timetaken for this block to execute is 5000 seconds.Now my requirement is to reduce it to 5 to 10 mins.
    can someone please guide me here.Its bit urgent .Awaiting for your response.
    declare
    vmax_Value NUMBER(5);
      vcnt number(10);
      id_val number(20);
      pc_id number(15);
      vtable_nm VARCHAR2(100);
      vstep_no  VARCHAR2(10);
      vsql_code VARCHAR2(10);
      vsql_errm varchar2(200);
      vtarget_starttime timestamp;
      limit_in number :=10000;
      idx           number(10);
              cursor stg_cursor is
             select
                   DESCRIPTION,
                   SORT_CODE,
                   ACCOUNT_NUMBER,
                     to_number(to_char(CORRESPONDENCE_DATE,'DD')) crr_day,
                     to_char(CORRESPONDENCE_DATE,'MONTH') crr_month,
                     to_number(substr(to_char(CORRESPONDENCE_DATE,'DD-MON-YYYY'),8,4)) crr_year,
                   PARTY_ID,
                   GUID,
                   PAPERLESS_REF_IND,
                   PRODUCT_TYPE,
                   PRODUCT_BRAND,
                   PRODUCT_HELD_ID,
                   NOTIFICATION_PREF,
                   UNREAD_CORRES_PERIOD,
                   EMAIL_ID,
                   MOBILE_NUMBER,
                   TITLE,
                   SURNAME,
                   POSTCODE,
                   EVENT_TYPE,
                   PRIORITY_IND,
                   SUBJECT,
                   EXT_PRD_ID_TX,
                   EXT_PRD_HLD_ID_TX,
                   EXT_SYS_ID,
                   EXT_PTY_ID_TX,
                   ACCOUNT_TYPE_CD,
                   COM_PFR_TYP_TX,
                   COM_PFR_OPT_TX,
                   COM_PFR_RSN_CD
             from  table_stg;
    type rec_type is table of stg_rec_type index by pls_integer;
    v_rt_all_cols rec_type;
    BEGIN
      vstep_no   := '0';
      vmax_value := 0;
      vtarget_starttime := systimestamp;
      id_val    := 0;
      pc_id     := 0;
      success_flag := 0;
              vstep_no  := '1';
              vtable_nm := 'before cursor';
        OPEN stg_cursor;
              vstep_no  := '2';
              vtable_nm := 'After cursor';
       LOOP
              vstep_no  := '3';
              vtable_nm := 'before fetch';
    --loop
        FETCH stg_cursor BULK COLLECT INTO v_rt_all_cols LIMIT limit_in;
                  vstep_no  := '4';
                  vtable_nm := 'after fetch';
    --EXIT WHEN v_rt_all_cols.COUNT = 0;
        EXIT WHEN stg_cursor%NOTFOUND;
    FOR i IN 1 .. v_rt_all_cols.COUNT
      LOOP
       dbms_output.put_line(upper(v_rt_all_cols(i).event_type));
        if (upper(v_rt_all_cols(i).event_type) = upper('System_enforced')) then
                  vstep_no  := '4.1';
                  vtable_nm := 'before seq sel';
              select PC_SEQ.nextval into pc_id from dual;
                  vstep_no  := '4.2';
                  vtable_nm := 'before insert corres';
              INSERT INTO target1_tab
                           (ID,
                            PARTY_ID,
                            PRODUCT_BRAND,
                            SORT_CODE,
                            ACCOUNT_NUMBER,
                            EXT_PRD_ID_TX,         
                            EXT_PRD_HLD_ID_TX,
                            EXT_SYS_ID,
                            EXT_PTY_ID_TX,
                            ACCOUNT_TYPE_CD,
                            COM_PFR_TYP_TX,
                            COM_PFR_OPT_TX,
                            COM_PFR_RSN_CD,
                            status)
             VALUES
                            (pc_id,
                             v_rt_all_cols(i).party_id,
                             decode(v_rt_all_cols(i).product_brand,'LTB',2,'HLX',1,'HAL',1,'BOS',3,'VER',4,0),
                             v_rt_all_cols(i).sort_code,
                             'XXXX'||substr(trim(v_rt_all_cols(i).ACCOUNT_NUMBER),length(trim(v_rt_all_cols(i).ACCOUNT_NUMBER))-3,4),
                             v_rt_all_cols(i).EXT_PRD_ID_TX,
                             v_rt_all_cols(i).EXT_PRD_HLD_ID_TX,
                             v_rt_all_cols(i).EXT_SYS_ID,
                             v_rt_all_cols(i).EXT_PTY_ID_TX,
                             v_rt_all_cols(i).ACCOUNT_TYPE_CD,
                             v_rt_all_cols(i).COM_PFR_TYP_TX,
                             v_rt_all_cols(i).COM_PFR_OPT_TX,
                             v_rt_all_cols(i).COM_PFR_RSN_CD,
                             NULL);
                  vstep_no  := '4.3';
                  vtable_nm := 'after insert corres';
        else
              select COM_SEQ.nextval into id_val from dual;
                  vstep_no  := '6';
                  vtable_nm := 'before insertcomm';
          if (upper(v_rt_all_cols(i).event_type) = upper('REMINDER')) then
                vstep_no  := '6.01';
                  vtable_nm := 'after if insertcomm';
              insert into parent_tab
                 (ID ,
                 CTEM_CODE,
                 CHA_CODE,            
                 CT_CODE,                           
                 CONTACT_POINT_ID,             
                 SOURCE,
                 RECEIVED_DATE,                             
                 SEND_DATE,
                 RETRY_COUNT)
              values
                 (id_val,
                  lower(v_rt_all_cols(i).event_type), 
                  decode(v_rt_all_cols(i).product_brand,'LTB',2,'HLX',1,'HAL',1,'BOS',3,'VER',4,0),
                  'Email',
                  v_rt_all_cols(i).email_id,
                  'IADAREMINDER',
                  systimestamp,
                  systimestamp,
                  0);  
         else
                vstep_no  := '6.02';
                  vtable_nm := 'after else insertcomm';
              insert into parent_tab
                 (ID ,
                 CTEM_CODE,
                 CHA_CODE,            
                 CT_CODE,                           
                 CONTACT_POINT_ID,             
                 SOURCE,
                 RECEIVED_DATE,                             
                 SEND_DATE,
                 RETRY_COUNT)
              values
                 (id_val,
                  lower(v_rt_all_cols(i).event_type), 
                  decode(v_rt_all_cols(i).product_brand,'LTB',2,'HLX',1,'HAL',1,'BOS',3,'VER',4,0),
                  'Email',
                  v_rt_all_cols(i).email_id,
                  'CORRESPONDENCE',
                  systimestamp,
                  systimestamp,
                  0); 
            END if; 
                  vstep_no  := '6.11';
                  vtable_nm := 'before chop';
             if (v_rt_all_cols(i).ACCOUNT_NUMBER is not null) then 
                      v_rt_all_cols(i).ACCOUNT_NUMBER := 'XXXX'||substr(trim(v_rt_all_cols(i).ACCOUNT_NUMBER),length(trim(v_rt_all_cols(i).ACCOUNT_NUMBER))-3,4);
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)
              values
                (id_val,
                 'IB.Correspondence.AccountNumberMasked',
                 v_rt_all_cols(i).ACCOUNT_NUMBER);
             end if;
                  vstep_no  := '6.1';
                  vtable_nm := 'before stateday';
             if (v_rt_all_cols(i).crr_day is not null) then 
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)
              values
                (id_val,
                 --'IB.Correspondence.Date.Day',
                 'IB.Crsp.Date.Day',
                 v_rt_all_cols(i).crr_day);
             end if;
                  vstep_no  := '6.2';
                  vtable_nm := 'before statemth';
             if (v_rt_all_cols(i).crr_month is not null) then 
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)
              values
                (id_val,
                 --'IB.Correspondence.Date.Month',
                 'IB.Crsp.Date.Month',
                 v_rt_all_cols(i).crr_month);
             end if;
                  vstep_no  := '6.3';
                  vtable_nm := 'before stateyear';
             if (v_rt_all_cols(i).crr_year is not null) then 
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)
              values
                (id_val,
                 --'IB.Correspondence.Date.Year',
                 'IB.Crsp.Date.Year',
                 v_rt_all_cols(i).crr_year);
             end if;
                  vstep_no  := '7';
                  vtable_nm := 'before type';
               if (v_rt_all_cols(i).product_type is not null) then
                  insert into child_tab
                     (COM_ID,                                            
                     KEY,                                                                                                                                        
                     VALUE)
                  values
                    (id_val,
                     'IB.Product.ProductName',
                   v_rt_all_cols(i).product_type);
                end if;
                  vstep_no  := '9';
                  vtable_nm := 'before title';         
              if (trim(v_rt_all_cols(i).title) is not null) then
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE )
              values
                (id_val,
                 'IB.Customer.Title',
                 trim(v_rt_all_cols(i).title));
              end if;
                  vstep_no  := '10';
                  vtable_nm := 'before surname';
              if (v_rt_all_cols(i).surname is not null) then
                insert into child_tab
                   (COM_ID,                                            
                   KEY,                                                                                                                                          
                   VALUE)
                values
                  (id_val,
                  'IB.Customer.LastName',
                  v_rt_all_cols(i).surname);
              end if;
                            vstep_no  := '12';
                            vtable_nm := 'before postcd';
              if (trim(v_rt_all_cols(i).POSTCODE) is not null) then
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)                              
               values
                (id_val,
                 'IB.Customer.Addr.PostCodeMasked',
                  substr(replace(v_rt_all_cols(i).POSTCODE,' ',''),length(replace(v_rt_all_cols(i).POSTCODE,' ',''))-2,3));
              end if;
                            vstep_no  := '13';
                            vtable_nm := 'before subject';
              if (trim(v_rt_all_cols(i).SUBJECT) is not null) then
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)                              
               values
                (id_val,
                 'IB.Correspondence.Subject',
                  v_rt_all_cols(i).subject);
              end if;
                            vstep_no  := '14';
                            vtable_nm := 'before inactivity';
              if (trim(v_rt_all_cols(i).UNREAD_CORRES_PERIOD) is null or
                  trim(v_rt_all_cols(i).UNREAD_CORRES_PERIOD) = '3' or
                  trim(v_rt_all_cols(i).UNREAD_CORRES_PERIOD) = '6' or
                  trim(v_rt_all_cols(i).UNREAD_CORRES_PERIOD) = '9') then
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)                              
               values
                (id_val,
                 'IB.Correspondence.Inactivity',
                  v_rt_all_cols(i).UNREAD_CORRES_PERIOD);
              end if;
                          vstep_no  := '14.1';
                          vtable_nm := 'after notfound';
        end if;
                          vstep_no  := '15';
                          vtable_nm := 'after notfound';
        END LOOP;
        end loop;
                          vstep_no  := '16';
                          vtable_nm := 'before closecur';
        CLOSE stg_cursor;
                          vstep_no  := '17';
                          vtable_nm := 'before commit';
        DELETE FROM table_stg;
      COMMIT;
                          vstep_no  := '18';
                          vtable_nm := 'after commit';
    EXCEPTION
    WHEN OTHERS THEN
      ROLLBACK;
      success_flag := 1;
      vsql_code := SQLCODE;
      vsql_errm := SUBSTR(sqlerrm,1,200);
      error_logging_pkg.inserterrorlog('samp',vsql_code,vsql_errm, vtable_nm,vstep_no);
      RAISE_APPLICATION_ERROR (-20011, 'samp '||vstep_no||' SQLERRM:'||SQLERRM);
    end;
    Thanks

    Its bit urgent
    NO - it is NOT urgent. Not to us.
    If you have an urgent problem you need to hire a consultant.
    I have a performance issue in the below code,
    Maybe you do and maybe you don't. How are we to really know? You haven't posted ANYTHING indicating that a performance issue exists. Please read the FAQ for how to post a tuning request and the info you need to provide. First and foremost you have to post SOMETHING that actually shows that a performance issue exists. Troubleshooting requires FACTS not just a subjective opinion.
    where i am trying to insert the data from table_stg into target_tab and in parent_tab tables and then to child tables via cursor with bulk collect .the target_tab and parent_tab are huge tables and have a row wise trigger enabled on it .the trigger is mandatory . This timetaken for this block to execute is 5000 seconds.Now my requirement is to reduce it to 5 to 10 mins.
    Personally I think 5000 seconds (about 1 hr 20 minutes) is very fast for processing 800 trillion rows of data into parent and child tables. Why do you think that is slow?
    Your code has several major flaws that need to be corrected before you can even determine what, if anything, needs to be tuned.
    This code has the EXIT statement at the beginning of the loop instead of at the end
        FETCH stg_cursor BULK COLLECT INTO v_rt_all_cols LIMIT limit_in;
                  vstep_no  := '4';
                  vtable_nm := 'after fetch';
    --EXIT WHEN v_rt_all_cols.COUNT = 0;
        EXIT WHEN stg_cursor%NOTFOUND;
    The correct place for the %NOTFOUND test when using BULK COLLECT is at the END of the loop; that is, the last statement in the loop.
    You can use a COUNT test at the start of the loop but ironically you have commented it out and have now done it wrong. Either move the NOTFOUND test to the end of the loop or remove it and uncomment the COUNT test.
    WHEN OTHERS THEN
      ROLLBACK;
    That basically says you don't even care what problem occurs or whether the problem is for a single record of your 10,000 in the collection. You pretty much just throw away any stack trace and substitute your own message.
    Your code also has NO exception handling for any of the individual steps or blocks of code.
    The code you posted also begs the question of why you are using NAME=VALUE pairs for child data rows? Why aren't you using a standard relational table for this data?
    As others have noted you are using slow-by-slow (row by row processing). Let's assume that PL/SQL, the bulk collect and row-by-row is actually necessary.
    Then you should be constructing the parent and child records into collections and then inserting them in BULK using FORALL.
    1. Create a collection for the new parent rows
    2. Create a collection for the new child rows
    3. For each set of LIMIT source row data
      a. empty the parent and child collections
      b. populate those collections with new parent/child data
      c. bulk insert the parent collection into the parent table
      d. bulk insert the child collection into the child table
    And unless you really want to either load EVERYTHING or abandon everything you should use bulk exception handling so that the clean data gets processed and only the dirty data gets rejected.

  • How can I update the trigger table?

    I need a insert trigger on a table and also wants to insert the result value in one of its field.
    it gives mutating error........
    so wots the way of updating it? how can i update the same table.

    For example like this (inside the BEGIN/END section of the trigger):
    :NEW.Col2 := :NEW.Col1;
    C.

  • Trigger java client update when table changes

    I have a Java Swing client and a C worker program. Both need to communicate with each other via events (C writes progress to Oracle table, Java Swing client displays progress to user).
    I thought I'd do this via a trigger on an oracle table. However, I couldn't figure out how to achieve that. Well, creating the trigger was the easy part, but how do I let the trigger and as a follow-up a stored procedure communicate with my Java client? All the info I found was about triggers and how to store a Java method in an Oracle DB. That's not what I need. I guess I need to register my Java client somehow to monitor the trigger / table.
    Does anyone know how to do that? I'd prefer to not use any additional libraries (Oracle AQ libraries, Oracle streams). A simple trigger would suffice.
    Thank you very much for your help!

    rp0428 wrote:
    >
    The client should poll for updates.
    Pushing from the database, which your original suggestion and the others provides no benefit in terms of the enterprise and might cause unforseen and difficult to diagnose problems.
    >
    I don't agree with either of these comments. Please explain them and provide any supporting documentation or other reliabe sources that you are basing these comments on.
    In particular clarify whether your comments are about the technology of notification in general or whether you feel that the notification solution is not appropriate for this particular use case.
    Polling is generally a terribly wasteful, inefficient and non-productive method of trying to identify changes that happen in a database. Provide supporting documentation for that.
    Naturally the actual metrics for this depend on the number, types and frequency of the DB changes in general and with their relation to the polling frequency in particular.Yep. And most of the time the specifics for that is such that one or both the following is true
    1. The requirements are wrong (for example no GUI needs to be update 100 times a second.)
    2. The requirements are loose enough that polling is perfectly adquate and appropriate solution.
    Oracle itself has gone in the opposite direction with the technology that it develops as can be inferred by the various methods provided in recent releases to support replication and the technology underlying the support of fast refresh materialized views.
    Oracle has all sorts of stuff in it. That doesn't mean that it ideal for all situations or even most situations.
    These technologies include Advanced Queuing, Change Data Capture, Advanced Replication, Standby Databases and the like.
    The only major Oracle technology that I am aware of that does not tend towards publish/subscribe is LogMiner and it does not use polling but rather uses a batch query process.
    And yet for 20 years people have managed to implement large solutions without that.
    Detection of DB changes is difficult for even small single tables without using functionality provided by Oracle specifically for that purpose. There are many, many references in these forums and on the web in general where developers have attempted to 'roll-their-own' procedures for detecting changes after the fact. Most of these attempts are flawed both in their design and execution.
    And yet you think that this new technology will provide immediate error free solutions both on Oracles sides and the implementors side?
    Polling is generally wasteful and inefficient for several reasons. First, poll queries can execute repeatedly when there haven't been any changes at all. This effort is entirely wasted and non-productive.
    I have a large volume database server whose cpu utilization is less than 3% with a projected volume this year of 3/4 billion dollars. In the mid 1980s I was more concerned with utilization. Not so much any more.
    On the other hand experience would suggest that developers have far, far more problems getting the database designs right in the first place. So I don't have great confidence in their ability to use brand new technologies to solve large volume problems.
    And if they don't have large volumes then the point is moot.
    The poll queries cannot easily determine exactly when the change occured; change meaning it was COMMITTED to the database. The common approach of updating columns such as MODIFIED_DATE within a trigger are flawed because any such date/time assigned in the trigger is virtually guaranteed to occur BEFORE the data is actually committed.
    The classic flaw manifests itself when the trigger assigns a value before midnight but the commit actually occurs after midnight. Thus two INSERT/UPDATES can have their data COMMITTED at exactly the same SCN and timestamp value but the MODIFIED_DATE values can be for two different days.
    There is no way to query this data on a nightly basis to get 'changes that happened today' with the risk of missing data the next night when the extract occurs, or worse, duplicating some data in the extracts for two different nights.
    I agree that the design you specified is flawed.
    It however is an excellent demonstration of how a developer might create a flawed design - as I a suggested. New technologies do not fix flawed designs. All they do is provide even more ways to create flawed designs. Which is exacerbated by large volume needs.
    And 'pushing from the database'? The change notification process is similar to publish/subscribe mechanisms and also similar to the way that listeners are used in Java.
    Certainly you wouldn't suggest that Java applications should 'poll' GUI objects to see if a user has taken any action would you?
    I agree your analogy is not apt for this discussion.

  • Can I use CSS to target a table or a DIV

    Ok, I am trying to use DW Layers so when I click on a
    thumbnail, I can trigger the "SetTextofLayer". The reason i do this
    is because I dont know of any other way to do it., but as you all
    know, the positioning of DW layers is absolute. So is there a
    simple way i can have an image trigger the change of text in a
    table or div. How do I do that? I looked, but all Ive found was
    tutorials on how to swap an image, not change text. Is there anyway
    to trigger table data using an image? Any help would be greatly
    appreciated
    -psy

    Look again at how I did it on my sample page. I removed ALL
    positioning
    from the div after applying the behavior (leaving it as a
    position:static,
    the default). It still works fine.
    http://murraytestsite.com/stol-text2.html
    shows a few tweaks I did -
    1. Moved the onclick event to an <a> tag surrounding
    the <img> tag so that
    you get a proper cursor on the image.
    2. Added a return false to the onclick event to avoid an IE
    flake.
    3. Added quotes to your STOL code.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "psypent81" <[email protected]> wrote in
    message
    news:[email protected]...
    > Hi,
    > Thanks again. Ive tried using the two methods A) Using
    the SetTextofLayer
    > -Which is nice, but it brings me to the whole absolute
    vs relative
    > positioning
    > deal.
    > Here's what I tried:
    >
    >
    http://www.helenbwilson.com/SetTextofLayer-01
    >
    > It's great but it still stays in an absolute position
    even though I
    > changed the
    >
    > #imageLayer {
    > position:relative;
    > width:400px;
    > height:400px;
    > z-index:1;
    > left: 290px;
    > top: 94px;
    > }
    >
    > I also tried to use the change of position to this page:
    >
    >
    http://www.helenbwilson.com/helen-portfolio-1.html
    >
    > All it did was make my caption disappear completely!
    > Actually, I tried both on that one page. If you click,
    you dont get the
    > caption anymore, whereas in
    >
    >
    http://www.helenbwilson.com/helen-portfolio-2.html
    >
    > you get the captions, albeit in absolute position form..
    > I just want this to be a quick patch, since I am now
    beginning to see the
    > light in terms of CSS positioning
    >
    > So what exactly am I doing wrong (Besides the obvious
    answer of Do not use
    > DW
    > Layers, lol) .
    > I really appreciate all the help. Thanks
    >
    > -psypent
    >

  • Need help in deleting multiple tables

    Hi,
    In one of my scenario i want to delete One record from the table, but there are some child and sub child exist for the table. And the on delete cascade is not set fro any of the table.
    Structure of my table,
    Table-1
    tab1_pk
    tab1_name
    Table-2
    tab2_pk
    tab1_pk
    Table-3
    tab3_pk
    tab2_pk
    i want to delete the record from Table-1 and all the related record of Table-2 and Table-3 in a single query.
    Plz help

    Dear 786725,
    What has just came to my mind at first sight is that you can create a trigger for your approach. I don't think that a single query will delete some rows from more than one table.
    Please go to the http://tahiti.oracle.com , select your database version and search for the after trigger. Hint: You may need to use the FOR EACH ROW clause and you again may need to use :old :new parameters in the trigger to have the information of what has just been deleted from the relevant table.
    Hope That Helps.
    Ogan
    Edited by: Ogan Ozdogan on 05.Ağu.2010 19:00
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7004.htm#SQLRF01405
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b31695/dialogs.htm#sthref454
    4.24 Create Trigger
    The following information applies to a trigger, which is which is a stored PL/SQL block associated with a table, a schema, or the database, or an anonymous PL/SQL block or a call to a procedure implemented in PL/SQL or Java. The trigger is automatically executed when the specified conditions occur.
    Schema: Database schema in which to create the trigger.
    Name: Name of the trigger. Must be unique within the database.
    Add New Source in Lowercase: If this option is checked, new text is entered in lowercase regardless of the case in which you type it. This option affects only the appearance of the code, because PL/SQL is not case sensitive in its execution.
    Trigger tab
    Trigger Type: The type of object on which to create the trigger: TABLE, VIEW, SCHEMA, or DATABASE. (The remaining items depend on the type of trigger.)
    Table Owner or View Owner: For a trigger on a table or a view, the name of the owner of the table or the view.
    Table Name or View Name : For a trigger on a table or a view, the name of the table or the view.
    Before or After: For a trigger on a table, select Before to cause the database to fire the trigger before executing the triggering event, or select After to cause the database to fire the trigger after executing the triggering event.
    Statement Level or Row Level: For a trigger on a table, Statement Level fires the trigger once before or after the triggering statement that meets the optional trigger constraint defined in the WHEN condition; Row Level fires the trigger once for each row that is affected by the triggering statement and that meets the optional trigger constraint defined in the WHEN condition.
    Insert, Update, Delete: For a trigger on a table or a view, Insert fires the trigger whenever an INSERT statement adds a row to a table or adds an element to a nested table; Update fires fire the trigger whenever an UPDATE statement changes a value in one of the columns specified in Selected Columns (or in any column if no columns are specified); Delete fires the trigger whenever a DELETE statement removes a row from the table or removes an element from a nested table.
    Referencing - Old: For a trigger on a table, the correlation names in the PL/SQL block and WHEN condition of a row trigger to refer specifically to old value of the current row.
    Referencing - New: For a trigger on a table, the correlation names in the PL/SQL block and WHEN condition of a row trigger to refer specifically to new value of the current row.
    Available Columns: For a trigger on a table, lists the columns from which you can select for use in an Update trigger definition.
    Selected Columns: For a trigger on a table, lists the columns used in an Update trigger definition.
    When: For a trigger on a table, an optional trigger condition, which is a SQL condition that must be satisfied for the database to fire the trigger. This condition must contain correlation names and cannot contain a query.
    Schema: For a trigger on a schema, the name of the schema on which to create the trigger.
    Available Events: For a trigger on a schema or database, lists events from which you can select for use in the trigger definition.
    Selected Events: For a trigger on a schema or database, lists events used in the trigger definition.
    DDL tab
    This tab contains a read-only display of a SQL statement that reflects the current definition of the trigger.
    "

  • STORED PROCEDURE & DATABASE TRIGGER

    제품 : FORMS
    작성날짜 : 1995-11-07
    * STORED PROCEDURE
    1. Oracle Forms 4.5에서는 PL/SQL Code를 Server-Side에 저장하거나 Forms 내 Trigger, Procedure로 갖을 수도 있다.
    다음과 같은 경우 Procedure를 Database Server에 저장하는 방법을 선택하는
    것이 좋다.
    - Procedure가 Standard한 기능을 제공하여 다른 Tool이 공유할 수 있을 때.
    - Procedure가 중요한 DML 기능을 가질 경우.
    - Oracle Forms 4.5에서는 PL/SQL의 Version을 1.1까지 지원하므로, PL/SQL
    Version 2.X 의 기능이 필요한 경우.
    2. Stored Procedure의 제한사항
    (1) Server가 7.0 이상이어야 한다.
    (2) Pass되는 Variable은 2000 Byte이하이어야 한다.
    - 2000이 넘으면 Truncate가 되고, PL/SQL에서 Value_Error Exception이
    발생한다.
    (3) Menu PL/SQL에서는 Stored Procedure와 Function을 부를 수 없다.
    (4) Stored Subprogram의 정의가 바뀐 경우, Forms를 다시 Server와 Connect
    하기 전에는 영향을 주지 않는다.
    3. Oracle 7 Server 에서 제공하는 Standard Package들
    - dbms_alert
    - dbms_ddl
    - dbms_describe
    - dbms_lock
    - dbms_mail
    - dbms_output
    - dbms_pipe
    - dbms_session
    - dbms_snapshot
    - dbms_standard
    - dbms_transaction
    - dbms_utility
    < Oracle7 Developers Guide 참조>
    4. Calling Stored Procedures
    (1) Database Procedure는 Server-Side PL/SQL Engine에 의해 실행되도록
    Design된 PL/SQL Block이다.
    (2) Stored Procedure를 Call하기 위해서는 EXECUTE Privilege가 필요하다.
    (3) Server-Side Procedure와 Forms에서의 PL/SQL의 중요한 차이점은
    Server-Side 에서는 Forms의 Bind Variable (:Block_Name.Item_Name 등)
    을 인식하지 못한다는 것이다.
    (4) Parameter/Return이 가능한 Data Type
    - VARCHAR2 : Maximum of Varchar2(2000)
    - NUMBER
    - DATE
    - BOOLEAN
    제한사항
    - TABLE%ROWTYPE, TABLE.COLUMN%ROWTYPE으로 정의된 것은 Reference가
    안된다.
    - Unsupported Parameter나 Return Value를 사용하면 다음의 Error가
    발생한다.
    * PL/SQL error 313 at line xxx, column yyy 'PROCNAME'
    not declared in this scope.
    * PL/SQL error 201 at line xxx, column yyy identifier 'FUNCTNAME'
    must be declared.
    (5) Formal Parameter의 Default Value
    - Defulat Value는 제공하지 않는다.
    - User가 임의로 줄 수 있다.
    - Procedure Private_Test(a in VARCHAR2 := 'Hello' b in
    VARCHAR2 := 'There') IS
    BEGIN
    Dbms_Output.Put_Line(a);
    Dbms_Output.Put_Line(b);
    END;
    (6) 다른 User의 Stored Subprogram이나 Remote Database를 Call하려면
    - User Name이나 Database Link명을 숨기기 위하여 Synonym을 생성하여야
    한다.
    - CREATE SYNONYM lib_hr_syn FOR libowner.lib_hr;
    - Program에서 Call할 때에는 ss_num ;= lib_hr_syn.get_ssn(:EMP.EMPNO);
    5. PL/SQL Compiler가 해당 Procedure를 찾는 순서
    (1) Current PL/SQL Block 내에 정의되어 있는가?
    (2) Standard PL/SQL Command인가?
    (3) Oracle Forms 내의 Built-in Procedure 혹은 Function인가?
    (4) User_Named Procedure 혹은 Function인가?
    (5) Server-side에 정의된 DBMS_STANDARD Package인가?
    (6) Current user가 Server-Side의 어떤 Procedure나 Function을 Access
    하는가?
    * 이상의 질문에 대하여 전부 'NO'라는 대답이 나오면 Compiler는 다음과 같은
    Error Message를 준다.
    - PL/SQL error 313 at line xxx, column yyy 'PROCNAME' not declared in
    this scope.
    - PL/SQL error 201 at line xxx, column yyy identifier 'FUNCTNAME'
    must be declared.
    * DATABASE TRIGGER
    1. Database Trigger는 Forms에서의 Trigger와 개념적으로 거의 동일하다.
    차이점은 Trigger가 Fire되는 원인을 제공하는 사건과 후속코드가 실행되는
    장소가 틀린 것이다.
    2. Database Trigger는 Table과 연관된 PL/SQL Block들이다. Table에 대한
    UPDATE, INSERT, DELETE 등의 행위에 의해 Fire된다.
    3. Error 발생 시에는 RAISE_APPLICATION_ERROR Built-In Procedure를 사용하
    여 Error를 표시한다.
    RAISE_APPLICATION_ERROR Procedure에서는 Error Number가 20000 - 20999의
    Range를 가진다.
    4. Creating & Editing Database Triggers
    아래와 같은 적절한 권한이 주어진다면 Forms Designer Mode에서 Database
    Trigger를 직접 Create, Edit, Compile, Browse 할 수 있다.
    - Execute Privilege, Create Privilege, Compile Privilege,
    Drop Privilege
    * Create하려면
    - Navigator에서 Database Objects와 Table Nodes를 Expand한다.
    - 원하는 Table을 선택하고 Expand한다.
    - Triggers Nodes를 선택하고 Menu Bar의 Navigator*Create를 선택한다.
    - Database Trigger Editor에서 작성, compile한다.
    * Edit 하려면
    - Navigator에서 Database Objects와 Table Nodes를 Expand한다.
    - 원하는 Table을 선택하고 Expand한다.
    - 원하는 Trigger에서 Double-Click하면 Editor가 나타난다.
    - Database Trigger Editor에서 변경, compile한다.

    not possible via forms
    you can debug it on SQL Developer by using manual INSERT Updates commands

  • TRIGGER ERROR: bad bind variable

    Hello,
    I'm just starting off with oracle and am trying to do the same as auto_increment in mysql is doing by creating this sequence and trigger, but on the trigger I am getting the following error:
    error:
    PLS-00049: bad bind variable 'TAKEOVER_USERS.TAKEOVER_UID'This is the code for trigger, table and sequence:
    trigger:
    CREATE OR REPLACE TRIGGER  "TAKEOVER_USERS_T1"
    BEFORE
    insert on "TAKEOVER_USERS"
    for each row
    begin
    select TAKEOVER_UID.nextval into :takeover_users.TAKEOVER_UID from dual;
    end;Table:
    CREATE TABLE  "TAKEOVER_USERS"
       ( "TAKEOVER_UID" NUMBER NOT NULL ENABLE,
    "TAKEOVER_FBID" VARCHAR2(20) NOT NULL ENABLE,
    "takeover_accepted_terms" NUMBER(1,1) NOT NULL ENABLE,
    "takeover_lastName" VARCHAR2(30),
    "takeover_firstName" VARCHAR2(30),
    "takeover_country" VARCHAR2(40),
    "takeover_session" VARCHAR2(50) NOT NULL ENABLE,
    "takeover_created" TIMESTAMP (6) NOT NULL ENABLE,
      CONSTRAINT "takeover_users_PK" PRIMARY KEY ("TAKEOVER_UID") ENABLE
       )sequence:
    CREATE SEQUENCE   "TAKEOVER_UID"  MINVALUE 1 MAXVALUE 99999999999999 INCREMENT BY 1 START WITH 1 NOCACHE  NOORDER  NOCYCLEYou got any idea what I need to change to make this work?
    Thanks!
    Christine

    if your DB is 11g you can try this
    CREATE OR REPLACE TRIGGER  "TAKEOVER_USERS_T1"
    BEFORE
    insert on "TAKEOVER_USERS"
    for each row
    begin
    :NEW.TAKEOVER_UID:=TAKEOVER_UID.nextval;
    end;if 10g or older..
    CREATE OR REPLACE TRIGGER  "TAKEOVER_USERS_T1"
    BEFORE
    insert on "TAKEOVER_USERS"
    for each ROW
    BEGIN
    SELECT TAKEOVER_UID.NEXTVAL INTO :NEW.TAKEOVER_UID FROM dual;
    end;Regards,
    Prazy

  • Tables for Collection, dispute and credit management

    Hi SAP Gurus,
    I would appreciate if any one could provide the list of tables for collection, dispute and credit management. Thanks!
    Regards,
    aj

    I think you mean the tables for FSCM.
    The easiest way to find it is to do SE16 FDM*
    FDM_AR_WRITEOFFS               FSCM-DM: Automatic Write-Offs Not Executed
    FDM_BUFFER                     Cluster for Decoupling in 1-System Scenari
    FDM_BW_INV_DELTA               Delta Queue for BI Invoice Extractor
    FDM_COLL_CCOLOAD               Company Codes for which Initial Load Perfo
    FDM_COLL_CFIELD                FSCM-COL: Relevant Fields for Document Cha
    FDM_COLL_COMPCOD               FSCM-COL: Active Company Codes of Collecti
    FDM_COLL_DUNNLEV               Harmonized Dunning Levels
    FDM_COLL_LASTPAY               Last Payments of Business Partner
    FDM_COLL_LTRIG                 Missing Entries of Table FDM_COLL_STRIG
    FDM_COLL_SFIELD                FSCM-COL: Relevant Fields for Document Cha
    FDM_COLL_STRIG                 FSCM-COL: Control of Trigger Update in TRO
    FDM_COLL_TROBJ                 FSCM-COL: Trigger Table for Collections Ma
    FDM_CONTACT_BUF                Personalization of Contact Person Data
    FDM_DCOBJ                      FSCM-DM Integration: Disputed Objects
    FDM_DCPROC                     FSCM-DM Integration: Dispute Case Processe
    FDM_P2P_ATTR                   Attributes of Promise to Pay; Required for
    FDM_PERSONALIZE                Personalization of Collections Management
    FDM1                           Cash Management & Forecast: Line Items of
    FDM2                           Cash management line items from MM purchas
    FDMV                           Cash Planning Line Items of Earmarked Fund
    Hope this helps, award points if useful.

  • Insert trigger with if condition

    Hi.
    I am new sql programming and I am trying to write a insert trigger.
    I have created an insert-trigger that inserts into another table(p_person) whenever the trigger table (p_personmds) gets insterted:
    CREATE OR REPLACE TRIGGER INSERT_P_PERSON_TG
    AFTER INSERT ON P_PERSONMDS
    FOR EACH ROW
    BEGIN
    insert into P_PERSON (person,person_id,person_name,email_address,disabled)
    values (seq_p_person.nextval,:new.person_id,:new.person_name,:new.email_address,:new.disabled);
    END INSERT_P_PERSON_TG;
    After testing the trigger I discovered that I need to add some checking to the trigger:
    If person_id already exists in the p_person table I need to just update the 'DISABLED' column and set it to 'null' value.
    So I tried modifying the trigger:
    CREATE OR REPLACE TRIGGER TESTMDS.INSERT_P_PERSON_TG
    AFTER INSERT ON TESTMDS.P_PERSONMDS
    FOR EACH ROW
    BEGIN
    IF :new.disabled is not null
    THEN
    update p_person set disabled=NULL where person_id=:old.person_id;
    ELSE
    insert into P_PERSON (person,person_id,person_name,email_address,disabled)
    values (seq_p_person.nextval,:new.person_id,:new.person_name,:new.email_address,:new.disabled);
    END IF;
    END INSERT_P_PERSON_TG;
    Hovewer the triggers seems to ignore the first if update condition and only inserts another row with mulitiple values.
    Anyone know what I am doeing wrong here?

    user12064835 wrote:
    so if I use: 'IF :OLD.Disabled is not NULL then' ,
    will :OLD:Disabled represent the p_person table or do I have to come up with something new?if you use :old.Disable, it will run always the ELSE-block.
    you should write your block as same thing like follows:
    IF :new.disabled is not null THEN
      update p_person set disabled=NULL where person_id=:old.person_id;
      IF SQL%ROWCOUNT = 0 THEN --this block will be executed if there was no row updated in table p_person
        insert into P_PERSON (person,person_id,person_name,email_address,disabled)
        values (seq_p_person.nextval,:new.person_id,:new.person_name,:new.email_address,:new.disabled);
      END IF;
    ELSE
      insert into P_PERSON (person,person_id,person_name,email_address,disabled)
      values (seq_p_person.nextval,:new.person_id,:new.person_name,:new.email_address,:new.disabled);
    END IF;but
    user12064835 wrote:
    if DISABLED column is not null in p_person table I want to insert a null value in the DISABLED column in p_person
    where the person_id that gets inserted in p_personmds table = person_id in p_person table.means
      update p_person set disabled=NULL where person_id=:old.person_id AND disabled is not NULL; 

  • Data base trigger gone wild

    Hello guys, i need your help, so whats going on is that i have builded a database trigger and it fires "before update".When im testing that trigger and try to update a certain field (in my case,the end_date) , the data base blocks and..it does nothing.
    I put here an excert of the trigger
    CREATE OR REPLACE TRIGGER APPS.JE_UBS_TAX_BANK_ACCOUNT_TRG
    BEFORE UPDATE
    OF START_DATE
    ,END_DATE
    ON AP.AP_BANK_ACCOUNT_USES_ALL
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    tmpvar NUMBER;
    n_org_id ubs.je_ubs_tax_pay_method.org_id%type :=null;
    -- Declaração das variáveis de JE_UBS_TAX_PAY_METHOD
    n_start_date ubs.je_ubs_tax_pay_method.start_date%type :=null;
    n_end_date ubs.je_ubs_tax_pay_method.end_date%type :=null;
    -- Cursor À JE_UBS_TAX_PAY_METHOD
    cursor c_pay_methods is
    SELECT start_date, end_date
    FROM ubs.je_ubs_tax_pay_method
    WHERE bank_account_id = :NEW.external_bank_account_id
    AND org_id = n_org_id;
    -- Declaração de Excepcoes
    -- exception_general exception; -- Excepcao
    BEGIN
    apps.je_ubs_all_debug_api.insert_log ('Inicio do trigger' || SQLERRM, ' JE_UBS_TAX_BANK_ACCOUNT_TRG');
    n_org_id := apps.fnd_profile.VALUE ('ORG_ID');
    open c_pay_methods;
    fetch c_pay_methods into n_start_date,
    n_end_date;
    loop
    IF UPDATING (:old.end_date)
    THEN
    IF (n_end_date > :new.end_date)
    THEN
    BEGIN
    UPDATE ubs.je_ubs_tax_pay_method
    SET end_date = :NEW.end_date
    WHERE bank_account_id = :new.external_bank_account_id
    AND org_id = n_org_id;
    EXCEPTION
    WHEN OTHERS
    THEN
    apps.je_ubs_all_debug_api.insert_log ('Error at Update end_date of je_ubs_tax_pay_method' || SQLERRM, ' JE_UBS_TAX_BANK_ACCOUNT_TRG');
    RAISE;
    apps.je_ubs_all_debug_api.insert_log ('Updated end_date at je_ubs_tax_pay_method ' || SQLERRM, ' JE_UBS_TAX_BANK_ACCOUNT_TRG');
    END;
    END IF;
    END IF;
    I think the problem must be insuficient privilegies but im not sure. I saved the trigger at the "apps" schema,the trigger table is at the "ap" schema, and the cursor table is at another schema, the "ubs"
    I didn´t saved the trigger at the same schema as the trigger table ("AP"), because i did not have priviliges.
    Help me if you can.

    eheh ! no guys, i just posted a little of the trigger. but ill post everything:
    CREATE OR REPLACE TRIGGER APPS.JE_UBS_TAX_BANK_ACCOUNT_TRG
    BEFORE UPDATE
    OF START_DATE
    ,END_DATE
    ON AP.AP_BANK_ACCOUNT_USES_ALL
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    NAME: JE_UBS_TAX_BANK_ACCOUNT_TRG
    PURPOSE:
    REVISIONS:
    Ver Date Author Description
    1.0 18-08-2008 José Fernandes 1. Created this trigger.
    tmpvar NUMBER;
    n_org_id ubs.je_ubs_tax_pay_method.org_id%type :=null;
    -- Declaração das variáveis de JE_UBS_TAX_PAY_METHOD
    n_start_date ubs.je_ubs_tax_pay_method.start_date%type :=null;
    n_end_date ubs.je_ubs_tax_pay_method.end_date%type :=null;
    -- Cursor À JE_UBS_TAX_PAY_METHOD
    cursor c_pay_methods is
    SELECT start_date, end_date
    FROM ubs.je_ubs_tax_pay_method
    WHERE bank_account_id = :NEW.external_bank_account_id
    AND org_id = n_org_id;
    -- Declaração de Excepcoes
    -- exception_general exception; -- Excepcao
    BEGIN
    apps.je_ubs_all_debug_api.insert_log ('Inicio do trigger' || SQLERRM, ' JE_UBS_TAX_BANK_ACCOUNT_TRG');
    n_org_id := apps.fnd_profile.VALUE ('ORG_ID');
    open c_pay_methods;
    fetch c_pay_methods into n_start_date,
    n_end_date;
    loop
    IF UPDATING (:old.end_date)
    THEN
    IF (n_end_date > :new.end_date)
    THEN
    BEGIN
    UPDATE ubs.je_ubs_tax_pay_method
    SET end_date = :NEW.end_date
    WHERE bank_account_id = :new.external_bank_account_id
    AND org_id = n_org_id;
    EXCEPTION
    WHEN OTHERS
    THEN
    apps.je_ubs_all_debug_api.insert_log ('Error at Update end_date of je_ubs_tax_pay_method' || SQLERRM, ' JE_UBS_TAX_BANK_ACCOUNT_TRG');
    RAISE;
    apps.je_ubs_all_debug_api.insert_log ('Updated end_date at je_ubs_tax_pay_method ' || SQLERRM, ' JE_UBS_TAX_BANK_ACCOUNT_TRG');
    END;
    END IF;
    END IF;
    IF UPDATING (:old.start_date)
    THEN
    IF (n_start_date < :new.start_date)
    THEN
    BEGIN
    UPDATE ubs.je_ubs_tax_pay_method
    SET start_date = :new.start_date
    WHERE bank_account_id = :new.external_bank_account_id
    AND org_id = n_org_id;
    EXCEPTION
    WHEN OTHERS
    THEN
    apps.je_ubs_all_debug_api.insert_log ('Error at Update start_date of je_ubs_tax_pay_method ' || SQLERRM, ' JE_UBS_TAX_BANK_ACCOUNT_TRG');
    RAISE;
    apps.je_ubs_all_debug_api.insert_log ('Updated start_date of je_ubs_tax_pay_method ' || SQLERRM, ' JE_UBS_TAX_BANK_ACCOUNT_TRG');
    END;
    END IF;
    END IF;
    end loop;
    apps.je_ubs_all_debug_api.insert_log ('Success - End of trigger ' || SQLERRM, ' JE_UBS_TAX_BANK_ACCOUNT_TRG');
    EXCEPTION
    WHEN OTHERS
    THEN
    apps.je_ubs_all_debug_api.insert_log ('Exception - When Others ' || SQLERRM, ' JE_UBS_TAX_BANK_ACCOUNT_TRG');
    RAISE;
    END je_ubs_tax_bank_account_trg;
    ***************************************************

  • Deadlock error in trigger

    I created the following trigger and my requirement is updating the table with status column y, if the status column null values are less
    than particular number have to insert few records into the same table...here is the code..
    CREATE OR REPLACE TRIGGER WMOS_TEMP.insert_rec
    after UPDATE
    ON RSORT_TEMP
    REFERENCING NEW AS New OLD AS Old
    for each row
    WHEN (
    new.status = 'Y'
    DECLARE
    null_count pls_integer;
    pragma autonomous_transaction;
    begin
    select count(*) into null_count from rsort_temp where status is null;
    dbms_output.put_line ('null_count'||null_count);
    if(null_count < 2) then
    INSERT INTO rsort_temp
    SELECT 1,ddm.dock_door_brcd, ah.SHPMT_NBR, ch.case_nbr,NULL
    FROM case ch, asn ah, master ddm
    WHERE ch.ORIG_NBR = ah.SHPMT_NBR
    AND ch.ORIG_NBR = ddm.curr_nbr
    AND ah.stat_code >= 10
    AND ah.stat_code <= 30
    AND ch.stat_code = 0
    AND SUBSTR (ddm.brcd, 1, 2) = 'DR' and rownum < 10 ;
    commit;
    end if;
    END;
    but I got the following error:
    ORA-04091: table WMOS_TEMP.RECEIVEANDSORT_TEMP is mutating, trigger/function may not see it
    ORA-06512: at "WMOS_TEMP.INSERT_REC", line 4
    ORA-04088: error during execution of trigger 'WMOS_TEMP.INSERT_REC'
    Can you tell me how to code so that my requirement got done.
    Thanks,

    Hi,
    There's a lot wrong with this solution. You need to read about the mutating table error.
    First, in a row-level trigger you cannot reference your own trigger table in a select, insert, update or delete, because a change is still in progress, there's no consistent picture of the data there.
    Second, you can't commit transactions in a trigger, they're not an atomic part of a transaction.
    The "pragma autonomous transaction" was not created to circumvent those issues, so you need to rethink your logic. You either have to put that code in a stored procedure, likely the ideal option, or you could
    use the workaround with a package, and using statement level trigger with the row level to accomplish that logic (which Tom shows in his AskTom post below).
    Read these texts please. There's some database fundamentals you need to grasp before you think of the best solution for this problem.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:9579487119866
    http://www.oracle.com/technology/oramag/oracle/08-sep/o58asktom.html

  • Can i see the deleted rows in trigger?

    Hi all, i need to found a similar behavior for this code in sql server:
    SELECT ID FROM DELETED WHERE ID > 100
    The DELETED table is defined like that:
    "The deleted table stores copies of the affected rows during DELETE and UPDATE statements. During the execution of a DELETE or UPDATE statement, rows are deleted from the trigger table and transferred to the deleted table."
    Can i access these rows in ORACLE? I tried with ":old" but i couldn't obtain good results.
    Thanks
    Marcos

    No. You can create FOR EACH ROW trigger and apply logic there.
    SY.

  • Call a Package in another schema  from a Trigger?

    Is there a method to call a package procedure from a trigger when the package exists within a different schema than the trigger (table)?
    Do you need a dblink to execute a procedure in a different schema within the same database?

    Hello,
    you need execute prvilege given to target schema on source package and you can create synonym in target schema as well. And you don't need dblink if the procedure resides in same schema or different schema in same database
    CREATE OR REPLACE TRIGGER myschema.test_trg
       BEFORE INSERT OR DELETE OR UPDATE
       ON test_table
       REFERENCING NEW AS new OLD AS old
       FOR EACH ROW
    DECLARE
    BEGIN
       -- How to pass parameters
       otherschema.mypkg.myproc (:new.id, :new.code);
    END;
    /Regards

  • Segment size

    Hi i had a table with 45 lakhs of records. i had a trigger for updation. i had written an update query which updates 25 lakhs records. but i terminated the session while update is going on. i deleted what ever rows got updated in the trigger table. but now when i check in dba_segments my trigger table is showing aroung 2 GB size even though it has only 60,000 records.
    what may be the problem? should i use alter tablespace <tablespace_name> coalecse; command?
    plz guide me
    thanks in advance.

    The easiest way to clear up deleted block is using "MOVE" clause.
    Syntax: ALTER TABLE tab_name MOVE options
    But keep in mind that you need free spaces where the table moves.
    For instance:
    SQL> select bytes from dba_segments where segment_name = 'REDO_TEST';
    BYTES
    1048576
    SQL> delete from redo_test;
    SQL> commit;
    SQL> select bytes from dba_segments where segment_name = 'REDO_TEST';
    BYTES
    1048576
    SQL> alter table redo_test move;
    SQL> select bytes from dba_segments where segment_name = 'REDO_TEST';
    BYTES
    65536

Maybe you are looking for

  • How to settle sales order to CO-PA

    Hello all: 1. create sales order , on item level has settlement rule to PSG:CO-PA 2. in sales order click COSTING button (calculator button) to put in cost estimate 3. KB21n to record actual time for activity 4. VF01 to generate billing 5. in my bill

  • GE70 2OE: How to successfully update to Windows 8.1

    Hi all.  I have successfully upgraded my MSI GE70 2OE (non-raid sku) to Windows 8.1.  It is a little bit of a headache, but I will cover what I did in order to get it to work*. 1) Download Windows 8.1 from the Windows Store.  It will download and aut

  • LabVIEW 32 bit on Win7 OS vs. XP 32 bit

    I need to know if it is at all possible to create an installer in LabVIEW 2010 32 bit Win7 that would work on a XP 32 bit target machine. How do you guys work around this issue if it exists? I thought I could do it by keeping an XP platfrorm availabl

  • Need information on the battery

    Hello. Before i get an electronic like the iPod Touch, i try to gather as much information as i possibly can so i can have everything ready and all of the knoweledge about it so i dont screw it up and so i can use it correctly, im trying not to sound

  • Change sort order of UWL items at Launch WebDynpro iview

    In my Universal Worklist, wen i click on Launch WebDynpro button, the list of leaves displaying in a pop-up. But all the things r dispalying in ascending order. How can i sort it in Descending order. Do i need any customization for this or any standa