How to call or not call a Trigger in same table based on condition?

Hi
How to call or not call a Trigger in below situations..
If a table contains a record of same value i.e,
[i[u]]ID
1
1
3
In above ID 1 is repeated for two times.
In this situations i don't want to call a trigger..
But, the value ID is for 3, now i want to fire a trigger.
Based on this i want to delete in another table.
How can I check it?
Thanks

Thanks for ur reply..
The below is my scnario..
I am having two table
employee
Id empcol
101 111
101 222
102 444
Department
id deptcol
101 457
101 678
102 543
The above is my table structure no one column is PK, so i m not able create FK.
When I am deleting from employee where id =101 and empcol=111,
the above record is deleted.
At present I am using After Update Trigger..
So trigger is called and delete the id 101 in Department table.
In my scenario i can't delete a record in Department table
bcoz i am having id morethan 101 in employee table.
If employee table contains one ID like 102 the Trigger should works.
How can I check the condition After delete on employee table it contains morethan same employee id?
The below is my Trigger..
CREATE OR REPLACE TRIGGER CALL_TRIGGER
AFTER DELETE ON Employee
FOR EACH ROW
DECLARE
count_id pls_integer;
BEGIN
SELECT COUNT(*) INTO count_id from Employee WHERE ID <>:new.ID;
IF( count_id >1) THEN
DELETE FROM Depratment where ID=:old.ID;
END IF;
END;
I am geting an error ORA-04091 table is mutuating, trigger cannot seen it.
I had tried with package and package body also.. But no luck.
Thanks

Similar Messages

  • I am facing issue in Receiving incoming calls, Name not getting displayed though the same has been saved in my phone book!! I have done sync from Windows contacts.. please help if some1 knows how to rectify the issue...

    I am facing issue in Receiving incoming calls, Name not getting displayed though the same has been saved in my phone book!! I have done sync from Windows contacts.. please help if some1 knows how to rectify the issue...

    Has your carrier been having issues with Call Display? Do the telephone numbers come up when people call, or does it just show 'Unknown Number' or 'Blocked' ?

  • How to populate data in the same table based on different links/buttons

    Hi
    I'm using jdeveloper 11.1.4. I have a use case in which i need to populate data in the same table based on click of different links.
    Can anyone please suggest how can this be achieved.
    Thanks

    I have a use case in which i need to populate data in the same table based on click of different linksDo you mean that you need to edit existing rows ?
    What format do you have the date in - table / form ?

  • Forwarded calls are not "call-parked"

    Dear Lync experts,
    please could You help me that the following scenario is not possible or I need to change some config parameter:
    - there are two extensions ("A" and "B")
    - a call park group was defined and both extension were added to this call-park group (call pickup group)
    - extension "A" was forwarded to extension "B" (using Lync client- Call Forwarding - Forward my call to- Delegate "B")
    - there is an incoming call to "A", it is ringing at "B" (because of the forward option), but dialing the call-park-group number we are not able to pickup this call.... I do not understand why?!
    Thanks in advance:
    Norbert

    Hi,
    Would you please tell us why you want to forward call to another account in the same call park group?
    Base on my understanding, if cancel the call forwarding, other users could pick up the call. Please check if it works after cancelling call forwarding setting. Please check if the issue still happen when cancelling call forwarding.
    Best Regards,
    Eason Huang
    Eason Huang
    TechNet Community Support

  • How to copy  existing  row  value into new row  with a trigger. Same table

    Oracle guru,
    I am looking for a before or after trigger statement that will copy existing values inserted in the previous row into columns A & B. Then insert those values in a new row into column A & B if null? Same table. Hopefully my question is clear enough.
    -Oracle 10g express
    -I have an existing " before insert trigger" that insert id and timestamps when a new row is created.
    -Table is composed of column like id,timestamps,A,B and more.
    Thanks in advance
    Pierre

    957911 wrote:
    Oracle guru,
    I am looking for a before or after trigger statement that will copy existing values inserted in the previous row into columns A & B. Then insert those values in a new row into column A & B if null? Same table. Hopefully my question is clear enough.
    -Oracle 10g express
    -I have an existing " before insert trigger" that insert id and timestamps when a new row is created.
    -Table is composed of column like id,timestamps,A,B and more.
    Thanks in advance
    PierreI will call it a very Wrong design.
    It is a wrong Table Design. You are duplicating the data in table and not complying with the Database Normalization rules.
    How about Verifying if Column A & B are NULL before inserting and inserting another row and avoiding it in Triggers?
    If you are bent to achieve this, below code might be helpful. However, I would never go with this approach. If you would care about explaining the reason for going ahead with such a data model, people could suggest better alternative that might conform with Normalization rules.
    create or replace trigger trg_test_table
    after insert on test_table
    for each row
    declare
      pragma autonomous_transaction;
    begin
      if :new.col_a is null and :new.col_b is null then
        insert into test_table
        select 2, systimestamp, col_a, col_b
          from test_table
         where pk_col = (select max(pk_col) from test_table b where b.pk_col < :new.pk_col);
      end if;
      commit;
    end trg_test_table;Read SQL and PL/SQL FAQ and post the mentioned details.
    Do not forget to mention output from
    select * from v$version;

  • How can I start a new paragraph within the same table cell?

    In Numbers, when adding text within a table frame, how can I start a new line within the same frame (rather than advancing to the next cell)?  I'd like to enter a mini-list of several items of various lengths of data.

    While Wayne's answer solves your problem, another possibility is to uncheck the box at the bottom of the Table inspector for "Return key moves to next cell." If that is unchecked, the return key types a paragraph return within the cell (the same as Option Return with the box checked).
    With that box unchecked, Shift Return types a soft return (new line without a paragraph break).

  • How do I search for overlapping polygons in the same table?

    I have a table of approxiimately 1200 polygons. How can I find the records where there is an overlap between any of these polygon records? I'm using oracle Spatial 11g R2.

    Hi,
    use
    SDO_GEOM.RELATE
    reference link: SDO_GEOM Package (Geometry)
    hope this helps.
    Regards,

  • How do I extract a set of rows from a table based on specified criteria?

    I am using Numbers '08. I have a table that looks like this:
    I would like to, programmatically, find the MAX amount of all the 'Clothing' category items. More generally I'd like it to work like the COUNTIF function where I can do this:
    MAX(INCLUDEIF('Table::Category', 'Clothing'))
    I think my intention is clear.
    I suppose an alternate way is to create a table for every category and just do a MAX over that table, but this seems redundant since I already have that data in this particular table. Thanks!

    The easiest way, to me, is to add a new column to you data table which only shows values from rows that match the category for which you want to find the max():
    The new column (in this example) is titled "Active Category" and is selected from a Summary table.  Add a new table titled "Summary" as shown.
    Make cell B2 contain the category.
    Let's get the data table set up with the new column:
    E2=IF(C2=Summary :: $B$2, D2, "")
    select E2 and fill down.  This will only show the amount IF the category in column C matches what you entered in the summary table:
    Now let's complete the summary table:
    B3=MAX(Data :: E)
    I hope this helps

  • How to join each row with other in the same table without repeating, please help

    Hi,
    I have a table say Adjustment having following data
    Emp_Id                  
    Adjustment_id                      
    Date
    1000101               
    1000300                               
    2014-02-12 00:00:00.000
    1000101               
    1000301                               
    2014-02-12 00:00:00.000
    1000101               
    1000302                               
    2014-02-12 00:00:00.000
    1000101               
    1000303                               
    2014-02-12 00:00:00.000
    1000102               
    1000302                               
    2014-02-12 00:00:00.000
    1000102               
    1000303                               
    2014-02-12 00:00:00.000
    1000102               
    1000304                               
    2014-02-12 00:00:00.000
    And I want following records:
    Emp_Id                  
    Adjustment_id      Adjustment_id1              
          Date
    1000101               
    1000300                1000301                               
    2014-02-12 00:00:00.000
    1000101               
    1000300                1000302                               
    2014-02-12 00:00:00.000
    1000101               
    1000300               
    1000303                               
    2014-02-12 00:00:00.000
    1000101               
    1000301                1000302                               
    2014-02-12 00:00:00.000
    1000101               
    1000301                1000303                               
    2014-02-12 00:00:00.000
    1000101               
    1000302                1000303                               
    2014-02-12 00:00:00.000
    1000102               
    1000302                1000303                               
    2014-02-12 00:00:00.000
    1000102               
    1000302                1000304                               
    2014-02-12 00:00:00.000
    1000102                    
    1000303               
         1000304                                       
    2014-02-12 00:00:00.000

    Hi Uri,
    I am using SQL Server 2008, and I am trying join each adjustment_id with all other adjustment_id having same Date and Emp_id.
    so for following table records:
    Emp_Id                 
    Adjustment_id                
    Date
    1000102               
    1000302                         
    2014-02-12 00:00:00
    1000102               
    1000303                         
    2014-02-12 00:00:00
     1000102                   
    1000304                               
    2014-02-12 00:00:00
    Output should be:
    Emp_Id        
    Adjustment_id      Adjustment_id     
    Date
    1000102      
    1000302               1000303              
    2014-02-12 00:00:00 (first row with 2nd)
    1000102      
    1000302               1000304              
    2014-02-12 00:00:00 (first row with 3rd)
    1000102      
    1000303               1000304              
    2014-02-12 00:00:00 (2nd row with 3rd)

  • How to assign value in Statement level trigger?

    The below is my package body with trigger code..
    CREATE OR REPLACE PACKAGE BODY trigger_api AS
    TYPE t_change_rec IS RECORD (
    id tab1.id%TYPE,
    action tab1_audit.action%TYPE
    TYPE t_change_tab IS TABLE OF t_change_rec;
    g_change_tab t_change_tab := t_change_tab();
    PROCEDURE tab1_row_change (p_id IN tab1.id%TYPE,
    p_action IN VARCHAR2) IS
    BEGIN
    g_change_tab.extend;
    g_change_tab(g_change_tab.last).id := p_id;
    g_change_tab(g_change_tab.last).action := p_action;
    END tab1_row_change;
    PROCEDURE tab1_statement_change IS
    l_count NUMBER(10);
    BEGIN
    -- FOR i IN g_change_tab.first .. g_change_tab.last LOOP
    SELECT COUNT(*)
    INTO l_count
    FROM tab1;
    delete from tab1_audit where id=p_id;
    else
    dbms_output.put_line('Inside Else'||l_count);
    end if;
    -- END LOOP;
    -- g_change_tab.delete;
    END tab1_statement_change;
    END trigger_api;
    Trigger
    CREATE OR REPLACE TRIGGER tab1_asiu_trg
    -- AFTER INSERT OR UPDATE ON tab1
    AFTER DELETE ON tab1
    BEGIN
    trigger_api.tab1_statement_change;
    END;
    Calling Trgger
    Delete from tab1 where id='100';
    In the above package body which contains delete query, in that query i have to pass the value '100' i,e what are values i am giving in the (Delete from tab1 where id='100';) query.
    It shows error p_id Invalid Identifier..
    Thanks

    This wouldn't be related to your other threads would it by any chance?
    Re: How to call or not call a Trigger in same table based on condition?
    Re: Is it possible to use SELECT statement in TRIGGER?
    Can't you just stick to one thread to deal with your issue rather than asking it several times in different ways?
    You'll just cause confusion and frustrate people who are trying to help.

  • Trigger Issue while updating same table

    Hi all,
    I am creating one after insert trigger on table tests, which will check, if application id is null, application will be fetched from another table and update the table
    tests table. But this trigger is not updating the application id of the table tests
    CREATE OR REPLACE
    TRIGGER TB_REC_APPL_TESTS1
    AFTER INSERT ON tests FOR EACH ROW
    DECLARE
    v_application_id NUMBER;
    v_rec_appl_tests_id NUMBER;
    v_a_recruit_id NUMBER;
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    v_rec_appl_tests_id := :NEW.rec_appl_tests_id;
    v_a_recruit_id := :NEW.a_recruit_id;
    IF :NEW.a_applic_id IS NULL THEN
    SELECT a_applic_id INTO v_application_id FROM recruit WHERE a_recrut_id = v_a_recruit_id;
    dbms_output.PUT_LINE(v_application_id||'-'||v_rec_appl_tests_id);
    UPDATE tests SET a_applic_id = v_application_id
    WHERE rec_appl_tests_id = v_rec_appl_tests_id;--:NEW.rec_appl_tests_id;
    END IF;
    commit;
    END;
    Thanks in advance,
    Pal

    user546710 wrote:
    Hi all,
    I am creating one after insert trigger on table tests, which will check, if application id is null, application will be fetched from another table and update the table
    tests table. But this trigger is not updating the application id of the table tests
    CREATE OR REPLACE
    TRIGGER TB_REC_APPL_TESTS1
    AFTER INSERT ON tests FOR EACH ROW
    DECLARE
    v_application_id NUMBER;
    v_rec_appl_tests_id NUMBER;
    v_a_recruit_id NUMBER;
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    v_rec_appl_tests_id := :NEW.rec_appl_tests_id;
    v_a_recruit_id := :NEW.a_recruit_id;
    IF :NEW.a_applic_id IS NULL THEN
    SELECT a_applic_id INTO v_application_id FROM recruit WHERE a_recrut_id = v_a_recruit_id;
    dbms_output.PUT_LINE(v_application_id||'-'||v_rec_appl_tests_id);
    UPDATE tests SET a_applic_id = v_application_id
    WHERE rec_appl_tests_id = v_rec_appl_tests_id;--:NEW.rec_appl_tests_id;
    END IF;
    commit;
    END;
    Thanks in advance,
    Palyou are creating triger on the table and updating it. It will not allow to update since you are firing trigger on same table.
    Best practice is to use other table to update or any other operation.

  • How to call a package in a trigger

    I have package that is called via a "Submit" in a from used to enter daily production. We are implementing a barcoding system that will automatically populate the tables behind this form (one header and one line level table). I need to write a trigger or something that fires up the code behind the 'Submit' process whenever these tables are updated.
    Is there a way to do this by calling the package in a trigger?
    Please help.
    Thanks
    Edited by: asgar_amin on Feb 3, 2009 10:50 AM

    I'm not quite sure what your requirement is.
    Do you want to know which forms-trigger you can use to call your submit-package, or do you want to know how to call the submit-package from a database-trigger?
    If the second one, it depends on what parameters your package-procedur/function gets as IN-parameters. Is it the ID of the header-record, the detail-record or no parameter at all.
    Depending on that you could either use a AFTER-STATEMENT-trigger on either Header or lines-tables, or if you have to gather the ids a combination of a BEFORE-STATEMENT, an AFTER-INSERT FOR EACH ROW and an AFTER-STATEMENT-trigger.
    To go more into detail, please provide some more information.

  • How to log in with my old Apple account? I forgot my pass and I did change my apple ID before canceling first?? I am from Croatia so did folow al the discussion and the to resolve the problem but no luck. Can not call from Croatia the Apple help desk

    How to log in with my old Apple account? I forgot my pass and I did change my apple ID before canceling first?? I am from Croatia so did folow al the discussion and the to resolve the problem but no luck. Can not call from Croatia the Apple help desk.i did try all the options but I can not find the phone number to call from Croatia,
    I can not change my Apple ID to the old mail (not possible!)
    The old mail don't accept the new password..
    I can not delete the Icloud all the time asking my the password of the old mail!
    I realy need help

    You can not merge accounts.
    Apps are tied to the Apple ID used to download them, you can not transfer them.

  • When I press on a land line number, the phone does not call the number, but comes up with a screen to send a text to it.  How do I get my phone to default to phoneing a landline?

    When I press on a land line number, the phone does not call the number, but comes up with a screen to send a text to it.  How do I get my phone to default to phoneing a landline?  When I press a mobile number in contacts, the phone automatically phones the number.  I do not mind this as I hardly ever send texts, but I would like to have the option of what to do.  This seems such an obvious issue but I can not solve it even with much web searching.  Thanks!

    I can't delete my question, so I'll just say that you press on the type of number written in the box to the left of the box you typye the number into.  Dumb or what? 

  • How do I remove my caller id from my samsung convoy phone so that the person I call does not see my name?

    How do I remove my caller id from my samsung convoy phone so that the person I call does not see my name?

    MojaveMoon's solution will work if there is only one person you want to block your ID from; if you want to block your caller ID from everyone, you can go to your account online, go to Change Features, and scroll down till you see Caller ID block.  Instructions say that once this is activated, you can dial *82 before any # you WANT to display your number to, but all others will be blocked.
    If you are on a Family share plan, the account owner needs to log in and choose your line to activate this feature.

Maybe you are looking for

  • When i try to install iPlanet App Server on NT, I do not get screen to enter license key valid for evaluation. --- " cache File Read error"

    When i try to install iPlanet App Server on NT, I do not get screen to enter license key valid for evaluation. Also during installation screens an error window is displayed saying "cache File Read error -- Could not read ProductKey entry from the cac

  • Does time machine wear out drives?

    granted that all mechanical devices wear out, but does use of Time Machine with its hourly/daily/weekly backups cause more wear on a drive? the hourly backups will move more data depending on the work one is doing. The constant backing up is great fo

  • AP Invoice - Credit memo - negative payment amount

    Hello all, I am working in 11i oracle apps. In AP_invoices_all table there is an invoice_id that has a negative amount on it I understood that it is a credit memo. Can you please explain what a credit memo is and how does it affect a business Also, w

  • How to put Skype button in adobe flash website

    how to put Skype button in adobe flash website. I got the code from "http://www.skype.com/intl/en-us/tell-a-friend/wiza​rd/" but unfortunately it can generate codes for only html websites and emails but my site is in flash and these codes are not wor

  • 2 Node RAC abnormal behaviour

    Platform: "HP-UX 11.23 64-bit" Database: "10.2.0.4 64-bit" RAC: 2 Node RAC setup Our RAC setup has been properly done and RAC is working fine with load balancing i.e clients are getting connection on both instances. BUT the issue I am facing with my