Statement level trigger!!!!

Hi Gurus,
I have an issue here. I am inserting multiple rows in a table say A. so I wrote an after insert trigger for each row referencing new as new and old as old on table A. This trigger when fired inserts rows in table B.
These rows are selected from say table C by using the :new.column (one of the coulmns that are about to be inserted in tableA) of table A as parameter and then inserted into table B. But I want that trigger to fire only once though I am inserting multiple rows.
For this purpose I took out the "for each row and referencing new as new and old as old statements" to make it statement level trigger but in this case I am unable to use the :new.column of table A as parameters. Can anyone please suggest how to read the rows in statement level trigger that are being inserted in table A and pass them as parameters to select the values from table C and again insert them in table B. I know it is kinda confusing. Any suggestions...... Thanks in advance!!!!!

Hi warren,
Thnx for ur response. here is the code
CREATE OR REPLACE TRIGGER ALPHA_AIR
AFTER INSERT
ON ALPHA
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
l_source varchar2(10);
l_amount number;
l_comments varchar2(50);
BEGIN
     SELECT      b_source,
          b_amount,
          b_comments
     INTO     l_source,
          l_amount,
          l_comments
     FROM BETA
     WHERE beta_id=:new.alpha_id:
     INSERT INTO GAMMA
( g_source,
     g_amount,
     g_comments,
     date )
     VALUES (
          l_source,
          l_amount,
          l_comments,     
          sysdate);
END;
The trigger is on table ALPHA and it selects data from BETA using :new.alpha_id as parameter. But for multiple rows inserted in table ALPHA, multiple times rows are inserted in table GAMMA. So I made it statement level trigger but I cannot pass :new.alpha_id as parameter in the select statement. Is there any way to do this. Hope it makes sense.

Similar Messages

  • Confusion in Order of row and statement level trigger

    Hi can anyone tell me, if i create some trigger on table emp as in below order..
    BEFORE INSERT .. ROW LEVEL
    BEFORE INSERT .. STMNT LEVEL
    AFTER INSERT .. ROW LEVEL
    AFTER INSERT .. STMNT LEVEL
    than what will will be order of execution of trigers?
    How oracle will decide order?
    plz provide me some documents related to triggers execution order..thnx in advance..!

    PC wrote:
    Hi.. Got answer about order..but 1 strange point i m feeling that
    in case of, before insert.. stmnt level triger fire 1st then before insert.. row level.
    but in case of after insert.. row level trigger fireing 1st then after insert.. stmnt level ..
    can you explain this also..Why is it strange.
    You've got a statement you are executing.
    The first thing possible is that you are 'before' the statement.
    The next thing possible is that the statement executes for each row.
    Thus for each row, there is a point 'before' each row and a point 'after' each row.
    Once the statement has executed, you are 'after' the statement.
    So, it is only logical that the statement triggers surround the statement and the row triggers are within the statement, and of course 'before' comes before 'after'.

  • 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.

  • Need help in Statement level triggers.

    Hi All,
    I would like to clarify few things about statement level triggers. here are my doubts,
    1. does a statement level trigger have access to the column values of each row that the trigger affects? if so provide me with some examples.
    Thanks,
    james.

    Not by default. If you need to see the column values in an after-statement trigger, you need to use a row-level trigger to accumulate the values in a package variable. This approach would use a before-statement trigger to clear the variable (a table of records based on the rowtype of the table, usually), the after-row trigger to add a row's column values, and then the after-statement trigger to loop through the PL/SQL table (array, collection, etc.) and do whatever is needed.

  • Getting iteration number in row level trigger

    Hi. Is there a way to get iteration number in row level trigger? Or to access data inserted in statement level trigger from row level trigger (statement level trigger are supposed to be executed before row level triggers but I cannot access them).
    I'm using Oracle 10g.

    My oracle version:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    TNS for 64-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    And business problem is like this:
    I need to have two log tables for some tables in my database:
    First log table is a statement level log. After insert or update or delete it should get one new row with mentioning date, time, sid, query type and some additional information.
    Second table should include all columns from table logged, date, time, sid and operation type.
    The problem is, I need exact the same date and time for each row in both log tables.
    Someone said that sysdate should return same value for query execution time. But it have nothing to do with triggers fired on this query.
    So you may say that I'm curious about getting exact same date and time for one statement level trigger and for each execution of row level trigger.

  • Basic Level Trigger Detection

    Hi..
    I am new to LabVIEW so please bear with me.. I am trying to measure the RPM of my motor which has an optical pick up tachometer attached to it.. The signal is analog and has two states
    1. 0 (here the output is in the order of millivolts and is very low)
    2. 1 (Here the outout is a steady 10V)
    i need to find the time between the two leading edges of the high state so that i can convert it to an RPM. but my basic level trigger detection always outputs a FALSE value even if the signal is above the set LEVEL. hence i am not able to get a time stamp differnce at all..
    i dont know if there is a better way to do this. its basically just measring the pulses of my signal. Can anyone suggest a way
    Attached is the VI 
    Solved!
    Go to Solution.
    Attachments:
    Acq&Graph Voltage-trig Clk.vi ‏33 KB

    Hi Shankar,
    If you use the timestamp of the trigger location, it should be more accurate.
    Jared S.
    Applications Engineering
    National Instruments
    Attachments:
    timedifference.png ‏16 KB

  • Row level trigger updating the entire table instead of affected rows

    I am using orace 8.1.7. My problem is I have a row level trigger that should fire only once ( and insert a row in my auditing table). But it is doing it for the entire table. This only happens when I have more than two columns in an Update clause. Has anyone run into this problem before. Any help would be highly appreciated.
    thanks,
    dinesh

    create or replace trigger contact_audit
    before update or delete on contact
    for each row
    declare
    v_audit_type char(1);
    v_audit_item varchar2(64) := 'CONTACT';
    v_acct_seqid number;
    Begin
    if inserting then
         v_audit_type := 'I';
    elsif updating then
    v_audit_type := 'U';
    elsif deleting then
    v_audit_type := 'D';
    end if;
    select acct_seqid into v_acct_seqid
    from account_contact
    where email = :old.contact_email;
    insert into audit_event ( id, audit_item, audit_type, audit_date, acct_seqid, col_1, col_2, col_3, col_4, col_5, col_6, col_7, col_8,
    col_9, col_10, col_11, col_12, col_13, col_14, col_15, col_16, col_17, col_18, col_19, col_20)
    values (audit_event_sq.nextval, v_audit_item, v_audit_type, sysdate, v_acct_seqid, :old.contact_email, :old.contact_type, :old.contact_last, :old.contact_first,
    :old.title, :old.address1, :old.address2, :old.address3, :old.city, :old.state, :old.zip_code5, :old.zip_code4, :old.zip_code_barcode, :old.country, :old.phone_no,
    :old.phone_ext, :old.receive_info_email_yn, :old.pwd_encrypted, :old.pwd_question, :old.pwd_answer);
    End;

  • Difference between rew level triggers and statement level triggers

    Hi All
    I would like to know the exact difference between rew level triggers and statement level triggers.Please provide me with an example.
    Thanks
    Anand

    What is difference between row & statement?
    One statement can change many rows.
    Difference determines how many times the trigger fires or under what conditions.

  • Capturing value in after insert or update row level trigger

    Hi Experts,
    I'm working on EBS 11.5.10 and database 11g. I have trigger-A on wip_discrete_jobs table and trigger-B on wip_requirement_operations table.When ever i create discrete job, it inserts record in both wip_discrete_jobs and wip_requirement_operations.
    Note:2 tables are like master-child relation.
    Trigger-A: After Insert.Row Level trigger on wip_discrete_jobs
    Trigger-B:After Insert,Row Level trigger on wip_requirement_operations
    In Trigger A:
    I'm capturing wip_entity_id and holding in global variable.
    package.variable:=:new.wip_entity_id
    In Trigger B:
    I'm using the above global variable.
    Issue: Let's say i have create discrete job,it's wip_entity_id is 27, but the global variable is holding the previous wip_entity_id(26),not current value.It looks like before trigger A event is complete, trigger B is also in process, i think this could be the reason it's not storing the current wip_entity_id in the global variable.
    I need your help how to have the current value in the global variable so that i can use that in the trigger B.
    Awaiting response at the earliest.
    Thanks

    798616 wrote:
    Hi Experts,
    I'm working on EBS 11.5.10 and database 11g. I have trigger-A on wip_discrete_jobs table and trigger-B on wip_requirement_operations table.When ever i create discrete job, it inserts record in both wip_discrete_jobs and wip_requirement_operations.
    Note:2 tables are like master-child relation.
    Trigger-A: After Insert.Row Level trigger on wip_discrete_jobs
    Trigger-B:After Insert,Row Level trigger on wip_requirement_operations
    In Trigger A:
    I'm capturing wip_entity_id and holding in global variable.
    package.variable:=:new.wip_entity_id
    In Trigger B:
    I'm using the above global variable.
    Issue: Let's say i have create discrete job,it's wip_entity_id is 27, but the global variable is holding the previous wip_entity_id(26),not current value.It looks like before trigger A event is complete, trigger B is also in process, i think this could be the reason it's not storing the current wip_entity_id in the global variable.
    I need your help how to have the current value in the global variable so that i can use that in the trigger B.
    Awaiting response at the earliest.
    ThanksMy head hurts just thinking about how this is being implemented.
    What's stopping you from creating a nice and simple procedure to perform all this magic?
    Continue with the global/trigger magic at your own peril, as you can hopefully already see ... nothing good will come from it.
    Cheers,

  • Question about call statement in trigger

    I faced a question in written exam.
    A CALL statement inside a trigger allow us to call
    a)package
    b)procedure
    c)function
    d)another trigger
    Can anyone give me answer with reason?
    I used CALL statement inside trigger but not allowing to use it. Might be earlier in oracle CALL statement we can use..its only a guess so I am asking in forum..
    plz guide me..
    rgds,
    pc

    You can use CALL in a trigger without resorting to EXECUTE IMMEDIATE
    SQL> create table t1 (
      2    col1 number
      3  );
    Table created.
    SQL> create procedure t1_proc
      2  as
      3  begin
      4    dbms_output.put_line( 'In T1_PROC' );
      5  end;
      6  /
    Procedure created.
    SQL> ed
    Wrote file afiedt.buf
      1  create trigger trg_t1
      2    before insert on t1
      3    for each row
      4* call t1_proc
      5  /
    Trigger created.
    SQL> set serveroutput on;
    SQL> insert into t1 values( 1 );
    In T1_PROC
    1 row created.I can't think of any reason that you'd actually intentionally structure your code this way in this day and age because it would be rather likely to cause confusion for whoever had to support this in the future. But it is valid syntax that probably made sense back in Oracle 5.
    Justin

  • Error in posting :First create the jurisdiction code at state level ()-URGE

    Hi,
    We are getting ERROR "First create the jurisdiction code at state level ()" at the time of postiong . This is HST calculated on benefit that we are trying to post;;
    GL account tax category is defined as '<' in FS01 and posting without tax  allowed is not checked. Are we missing aything;
    Regards,
    Neelima

    Hi Neelima,
    Tax Jurisdiction code is related mainly to US.
    Please check the if tax jurisdiction code is maintained in SPRO > Financial Accounting > Financial Accounting Global Settings 's basic settings part. If not, maintain the same for the state. This might help you.
    Best Regards,
    Venkat.
    Edited by: Venkateswara Sarma Bhamidipati on Jan 1, 2011 4:45 AM

  • SP2013 VS State level Workflow error

    Hi All,
    I have my application running smoothly which uses 2 stage state level workflow, in workflow some basic calculations happening and assign tasks to users as task progress, after first stage of workflow i get this error message in log file on button click, 
    Stack trace:   
    at Microsoft.SharePoint.SPListItem.PrepareItemForUpdate(SPWeb web, Boolean bMigration, Boolean& bAdd, Boolean& bPublish, Object& objAttachmentNames,
    Object& objAttachmentContents)   
     at Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean
    bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents, String filename, Boolean bPreserveItemUIVersion)   
     at RedMills.Intranet.Workflows.Layouts.RedMills.ExpenseManager.ExpenseApprovalForm.Submit_Click(Object sender, EventArgs e)   
     at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)   
     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)   
     at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)   
     at System.Web.UI.Page.ProcessRequest()   
     at System.Web.UI.Page.ProcessRequest(HttpContext context)   
     at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   
     at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)   
     at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)   
     at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)   
     at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)   
     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)   
     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)   
     at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)   
     at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)   
     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)   
     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
    could not figure out what the error is , please help 

    Hi,                                                             
    If you want to know more about how the error occurred, it is recommended to debug the workflow to get more details about the error.
    Here are some links about how to debug workflow in SharePoint 2013 for your reference:
    http://www.c-sharpcorner.com/UploadFile/shyjumohan/how-to-debug-workflow-with-workflow-manager-1-0-and-visual-s/
    http://ranaictiu-technicalblog.blogspot.in/2013/03/sharepoint-2013-workflow-debugdiagnosis.html
    http://www.andrewconnell.com/blog/SP2013-Workflow-Advanced-Workflow-Debugging-with-Fiddler
    Best regards
    Patrick Liang
    TechNet Community Support

  • Block level trigger vs form level trigger

    Hello.
    I want to know what is better - to use block or form trigger?
    I have many blocks in my form. I need to write custom code in (for example) key-crerec trigger.
    Should i put trigger into each block or should i create one at form level like:
    if :system.current_block = 'BLOCK1' then
    create_record;
    elsif...
    end if;
    Thanks.
    Message was edited by:
    DejanH

    Hello,
    If you have to handle this stuff in more than one block, it seems more generic to put the code in a form-level trigger if you don't want to duplicate it several times.
    Francois

  • Why Module level trigger contains "WHEN-CHECKBOX-CHANGED" trigger in Forms 6i?

    Hi,
    Why Module level trigger contains triggers like "WHEN-CHECKBOX-CHANGED", "WHEN-BUTTON-PRESSED" etc.? "WHEN-CHECKBOX-CHANGED" trigger is present in CheckBox & "WHEN-BUTTON-PRESSED" trigger in Button. Then why these triggers are also presnt in Module?
    Can anyone please clarify my doubt?

    There's a lot of triggers that are present at different "scopes". Like they exist at the item level, the block level,
    the module level...
    The idea is if you have an action that should only occur at that one single item it can do in the item trigger. If
    it's for all of them on the block, in the block level trigger. If for all of them ever, at the module level.
    For example suppose you wanted it to do a next_item after the trigger executed you can put that logic in the module
    level trigger. A key thing to notice here is the trigger hierarchy. That is essential to know about.
    Right click on one of these triggers in the object navigator. The execution hierarchy is override, before and after.
    since each of these levels of the same trigger has this execution hierarchy this is, well, potentially not easy to
    understand what is going to happen. I would typically have a per-item trigger be before and a higher level trigger
    be after.
    And this execution hierarchy thing is something I'd love to see enhanced in the gui. I wish it was a lot easier to see
    what the execution hierarchy is when editing a trigger text. I wish one could see and modify the execution hierarchy on the
    same screen as the trigger text and what would be really great is some way to tell how the trigger hierarchy will sort out
    at run time. For example if one is looking at an item level trigger it would be fabulous to know that as is, that trigger will be
    overridden by a higher level trigger and so on. Or vice versa if one is looking at a block level or form level trigger that it is
    overridden by a lower level trigger, or it will execute before or after some other trigger. I don't know what is defined to happen
    with various levels of triggers that have the same execution hierarchy. Like suppose they are all override,before,after.. then
    what happens? It'd be good to know.

  • First create the jurisdisction code 'JI' at state level

    Hi Gurus
    We have a problem with travel trip expenses while posting to accounting. We got the following error
    "First create the jurisdisction code 'JI' at state level " while posting to accounting. We have maintained all the tables including
    "no input tax" checked in table V_706D_B." and also the transaction code OBCL to create the jurisdiction code at state level. We got this error after applying the service packs level upto 30. If anyone knows the solution please help me to resolve this issue..
    Thanks
    Kumar

    Sally
    Thanks for your quick response.  As mentioned in my message we have already maintained the table V_706D_B with radio button checked 'no input tax'.  We had this problem after we applied the service packs upto 30 level.  Please let me know if you have any other solutions.
    Thanks
    Kumar

Maybe you are looking for

  • My ipod not recognisable by itunes i have tried everything suggested by app

    ok, here is how it started. i wanted album art in my ipod, so i searched the web got all the album art i could and put in each album stored in my itunes. everything was going smoothly when it came to one particular album and from tat time i m having

  • How do I fix the error message in iTunes on apple tv?

    I have an apple tv 1st generation. When I go to the genres menu and search I get an error message. It says it cannot connect to iTunes and the store is temporarily unavailable. This has gone on for several days. I have tried restarting the apple tv,

  • Fail to import metadata

    Hi, I am trying to import metadata from existing module, I have the DB link and I had imported several tables few months ago. Now after several months I try to import more tables, I click on the module and click import I get the import metadata wizar

  • How to delete candidate profiles from e-recruitment

    Hi Experts, Could you please advice on how to delete the candidate profiles from the backend, could you please let me know the configuration required to perform this. Is there a standard background job or standard procedure of deleting candidates? Re

  • BR Tools Drop a table

    Hi I have scheduled a job to delete the records in the table TST03 because it unusually went to occupy 89GB of data... After I schedule this job to delete spools older than 2 weeks I can estimate that the total space occupied by TST03 at anytime will