Trigger function when variable a certain value?

Hi
I want a function to be triggered when a certain global var becomes true - I want to do this using an event listener.  I can do it as a one off using an if statement, but how do you set up a listener to trigger the function if the value becomes true at any time?
Thanks guys
Shaun

Sorry kglad - I'm struggling to work this out.
I've had a look at a few examples, but they don't make sense to me.
I just want Flash to ....
when globals.data.vari1 becomes true, gotoAndPlay(55);
Could you please show me how this is done?
Thanks in advance if you can help out.
Cheers
Shaun

Similar Messages

  • Trigger fails when variable used in WHERE statement

    I have a trigger that works when the following statment is in it:
    SELECT custcall.callrkey into v_callrkey from custcall where custcall.servno = 152345;
    But the trigger fails when I attempt to use a variable in the where statement as follows.
    SELECT custcall.callrkey into v_callrkey from custcall where custcall.servno = :new.servno ;
    Even though I have verified that the value of :new.servno is set to 152345 by outputting the value . That is the only difference between the working version and the non-working version. By not working I mean that the email which is to be sent by the trigger is not received.
    Can anyone give me any ideas of how I could troubleshoot this or what might me happening? I'm pretty new to this and
    feel that I'm missing something very simple. My apologies in advance if this has been posted elsewhere. I did spend a lot of time searching the forum before posting.
    This is Oracle 9i.
    Thanks!
    Full code probably not necessary but posted below just in case:
    create or replace
    TRIGGER EMAILNOTIFY_NEW_SR
    AFTER INSERT ON CUSTPROB
    FOR EACH ROW
    DECLARE
    --SMTP Variables
    vreply utl_smtp.reply;
    vreplies utl_smtp.replies;
    mailCONN utl_smtp.connection;
    mailHOST VARCHAR2(64) ;
    --MESSAGE Variables
    mailText VARCHAR2(64);
    mailFROM VARCHAR2(64);
    mailTO VARCHAR2(64);
    mailDATE VARCHAR2(20);
    v_servno number ;
    v_callrkey number ;
    --PROGRAM Variables
    i number;
    BEGIN
    --get some values from the database  
    --set values for variables...
    mailHOST:= '10.35.173.15'; --this will always stay the same 
    mailFROM := 'Facilities_Customer_Service_Center'; --this will always stay the same
    mailTO := '[email protected]';
    SELECT custcall.callrkey into v_callrkey from custcall where custcall.servno = :new.servno  ;
    SELECT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS') INTO mailDATE FROM dual;
    dbms_output.put_line('open_connection');
    dbms_output.put_line('---------------');
    vreply := utl_smtp.open_connection(mailHOST, 25, mailCONN);
    dbms_output.put_line('helo');
    dbms_output.put_line('----');
    vreply := utl_smtp.helo(mailCONN, mailHOST);
    dbms_output.put_line( 'code = ' || vreply.code );
    dbms_output.put_line( 'text = ' || vreply.text );
    dbms_output.put_line('mail');
    dbms_output.put_line('----');
    vreply := utl_smtp.mail(mailCONN, mailFROM);
    dbms_output.put_line( 'code = ' || vreply.code );
    dbms_output.put_line( 'text = ' || vreply.text );
    dbms_output.put_line('rcpt to');
    dbms_output.put_line('----');
    vreply := utl_smtp.rcpt(mailCONN, mailTO);
    dbms_output.put_line( 'code = ' || vreply.code );
    dbms_output.put_line( 'text = ' || vreply.text );
    dbms_output.put_line('open_data');
    dbms_output.put_line('---------');
    vreply := utl_smtp.open_data(mailCONN);
    dbms_output.put_line( 'code = ' || vreply.code );
    dbms_output.put_line( 'text = ' || vreply.text );
    --SMTP ENVELOPE STUFF (In case it is needed later).  
    --utl_smtp.write_data(mailCONN, 'From:'  ||mailFROM     || chr(13));
    -- utl_smtp.write_data(mailCONN, 'To: '||mailTo || chr(13));
    --utl_smtp.write_data(mailCONN, 'CC:      '||mailFROM     || chr(13));
    --utl_smtp.write_data(mailCONN, 'Date:    '||mailDATE     || chr(13));
    --utl_smtp.write_data(mailCONN, 'BCC:     '||mailFROM     || chr(13));
    --THE MESSAGE
    utl_smtp.write_data(mailCONN, 'Subject: '||'Your Facilities Service Request ' ||'(SR '||v_servno||')'|| chr(13));
    utl_smtp.write_data(mailCONN, '');
    utl_smtp.write_data(mailCONN, '');
    utl_smtp.write_data(mailCONN, 'Dear Customer ' || chr(13));
    utl_smtp.write_data(mailCONN, '');
    utl_smtp.write_data(mailCONN, 'This is to inform you of something.' || ' ' ||mailTO|| chr(13) );
    utl_smtp.write_data(mailCONN, 'Please call us with any questions or concerns. ' || '' || chr(13));
    --DEBUG
    utl_smtp.write_data(mailCONN, 'DEBUG: ' || ''|| chr(13));
    utl_smtp.write_data(mailCONN, 'v_Servno ' || v_servno || chr(13));
    utl_smtp.write_data(mailCONN, 'v_callrkey ' || v_callrkey || chr(13));
    --END THE MESSAGE
    dbms_output.put_line('close_data');
    dbms_output.put_line('----------');
    vreply := utl_smtp.close_data(mailCONN);
    dbms_output.put_line( 'code = ' || vreply.code );
    dbms_output.put_line( 'text = ' || vreply.text );
    dbms_output.put_line('quit');
    dbms_output.put_line('----');
    vreply := utl_smtp.quit(mailCONN);
    dbms_output.put_line( 'code = ' || vreply.code );
    dbms_output.put_line( 'text = ' || vreply.text );
    END;

    Justin,
    Thanks for the reply. I'm away for a couple of days but when I get back to this I'm going to follow up on your suggestion about servno. I'm starting to think that the issue isn't with servno but rather that the select query doesn't return anything because the value I'm trying to get is in another table and is not being inserted in time for me to get them. This will be easiy enough to test. To be honest, I don't know very much about how things are being inserted.
    I appreciate your and Tubby's (and Tom's) concerns. Maybe I'll go back to the drawing board next week. But note that I'm not inserting anything with this trigger--only sending an email based on the insert that is happening through an application. So unless I'm really missing it, my email is dependent on the insert but not vice versa. Since my email is absolutely critical but rather jus a courtesy thing, I was taking a pretty laid back attitude about it but it would be good for me to learn a better way.
    Thanks again to all! I'll report back what I find/decide.

  • Trigger function when loaded swf finishes

    I'm making a site that loads external swfs based on which
    button is clicked. When the swf loads it plays an intro and then
    stops at a certain point. My goal is that when you click another
    button the current swf plays an outro before the next one loads.
    The problem I'm having is making the outgoing movie trigger the
    function that loads the next.
    At first I tried just adding loadNextMovie(); to the last
    frame of the loaded swf. But for some reason this causes the two
    stops in the file from working so the thing just keeps looping. I
    have no idea why adding this function call would prevent stop();
    from working.
    Is there another way to have the end of movie trigger the
    function? Also, why doesn't adding loadNextMovie(); to the last
    frame of the loaded swf work?

    Ok, sure. I have main.swf that loads external.swf. Main.swf
    has a function that loads a different movie. Like this:
    function loadMovie():void {
    trace("movie loaded")
    This function is to be called from external.swf by putting
    this in the last frame:
    stop();
    loadMovie();
    But when I actually put loadMovie(); into external.swf the
    stop no longer works and it just loops. What am I doing wrong? Is
    trying to put this function call in the external swf the correct
    approach?

  • How to stop trigger function when in post query?

    Hi All,
    I have a problem, not able to find the solution.
    I have created a form with 10 field items.
    For a field item called RECEIVED_15G, i have created a trigger:WHEN-VALIDATE-ITEM, it works fine as per my requirement.
    The problem is that i want this trigger to work only when i run the form , that when system is in NORMAL mode.
    I don't want this trigger to work after i do execute query, even here the system is in NORMAL mode.
    So how do i make it to work ??
    Is it possible to stop that trigger work after i click execute query (Something that i can code in Post query) ??
    Help me . Thank You.
    Oracle Forms 6i,
    Oracle DB 9i.

    Hi
    pls share with us the code my guess ; the When-Validate-Item (WVI) trigger is firing because you are setting a value in an item from post-Query Trigger>
    Note: just assign a name in a display item in post-query trigger DONT assign an id or any db item.
    Amatu Allah

  • Trigger events when delete/modify certain folder in KM

    Dear Experts,
    I have a requirement like when certain folder is being deleted/modified I want an event need to be trigger, such that I will put some checks before these commands performed.
    Basically my requirement is, I have a custom iViews created and are using custom tables in databse.  When I create the folders in KM, I am creating/maintaining these folder reference in my custom tablese using my custom iView.
    Now when I delete the folder from KM, I want to show some warning message before deleting the folder and simulatenously these folder references should also be deleted from my custom tables.
    Please give me suggestions how to acheive the above scenario.
    Thanks in Advance,
    Chinna.

    Hi Yogalakshmi,
    I have created a Repository service using the document provided. I have registered the pre_delete_template  event using the below code         
    unregister(this,ResourceEvent.PRE_DELETE_TEMPLATE);
    I am printing some trace when this event occurs. Logs is being displayed after the folder gets deleted.
    Can you please provide me some code snippet for register predelete event, and on attempting to delete I would like to pop up a window with warning/confirmation message (confirmation popup window). Based on the confirmation from the popup window -- Ok/Cancel, I would like to perform few operations.
    I don't find any documents on Repository Services.
    Could you please provide me code/documents that fulfills my requirement.
    Thanks
    Chinna.

  • Problem with ALV filter functionality when filtered for multiple values

    Hi,
    I am facing a problem with ALV filter functionality.
    I have displayed an ALV with some columns col_A, col_B and col_C
    col_A---- col_B -
    col_C
    1----
    a -
    abc
    2----
    b -
    pqr
    3----
    c -
    lmn
    4----
    d -
    xyz
    5----
    f -
    stu
    From the settings link I am applying filter on column col_C and selected multiple values say 'pqr', 'xyz' and 'lmn'.
    Now the ALV is showing rows only for last selection i.e . results are fetched only for value 'lmn'.
    i.e. after applying the filter the ALV table looks as below:
    col_A---- col_B -
    col_C
    3----
    c -
    lmn
    But ideally it should be:
    col_A---- col_B -
    col_C
    2----
    b -
    pqr
    3----
    c -
    lmn
    4----
    d -
    xyz
    I could not find any OSS note related to this issue.
    Please help me resolve this issue.
    Thanks,
    Feroz

    Hi,
    I am facing a problem with ALV filter functionality.
    I have displayed an ALV with some columns col_A, col_B and col_C
    col_A---- col_B -
    col_C
    1----
    a -
    abc
    2----
    b -
    pqr
    3----
    c -
    lmn
    4----
    d -
    xyz
    5----
    f -
    stu
    From the settings link I am applying filter on column col_C and selected multiple values say 'pqr', 'xyz' and 'lmn'.
    Now the ALV is showing rows only for last selection i.e . results are fetched only for value 'lmn'.
    i.e. after applying the filter the ALV table looks as below:
    col_A---- col_B -
    col_C
    3----
    c -
    lmn
    But ideally it should be:
    col_A---- col_B -
    col_C
    2----
    b -
    pqr
    3----
    c -
    lmn
    4----
    d -
    xyz
    I could not find any OSS note related to this issue.
    Please help me resolve this issue.
    Thanks,
    Feroz

  • Trigger when outside of certain range

    I am trying to set up a trigger so that when the data acquired falls outside a given range data will start being recorded. I've been searching on labview and i can't find a way to set up a trigger for when voltage falls either above or below a certain value. all the triggers work when data falls within a certain range. if anyone can help me that'd be great. i'm working with labview 8.0 and daqmx with a usb 6008 data acquisition.
    thanks

    One method would be to do continuous data acquisition and make the determination of whether to save or not outside of the actual DAQ software. Capture continuously, save to a "functional global" (discussed at length in other threads), monitor the captured data in another loop with a check of whether the data is outside a range, if yes save to file.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • Trouble in BEx Analyzer when try to set values to the variables in ZXRSRU01

    Hi Experts!
    I have the trouble in BEx Analyzer when try to set values to the variables in ZXRSRU01 on i_step = 1.
    When variable's screen apeares the values is not those what was set in ZXRSRU01. When I try to trace
    this in RSRT I have no this problem, all the values are same as was set in ZXRSRU01.
    Thanks in advance.
    Best regards,
    Andrey Bychkov

    Hi
    Check this
    Documentation about variable types & their processing in i_step = 1, 2 etc.
    It may help you....
    Cheers

  • Ignore certain values when graphing

    Hi all,
    I am currently using labview to automatically QC check data from a weather station. I have one VI that checks the incomming data for errors and outputs the data with any corrections to a text file. I have another VI that opens the text file and graphs the results. If the first VI finds a obvious error, it exchanges the bad data point with -9999 to make sure the error is obvious. Therefore, a series of temperature data may start like this: 45,45.4,800,46.5,47.3 and end up like this 45,45.4,-9999,46.5,47.3
    My question is this. Is there anyway to have labview ignore certain values when graphing. I need the auto ranging feature turned on to insure that the graphs are legible, but if the -9999 value is included it creates a problem when the scales try to incorporate it. I need to be able to set labview to graph everything but to ignore the -9999 value when determining the scale. This would create an auto-ranged graph with the -9999 value simply going off the graph.
    Tim

    You can replace the -9999 values in your array data with the double precision value NaN (Not a Number - you can actually type that into a numeric control). LabVIEW will leave an empty spot when graphing, and it won't upset your autoscaling.
    Jarrod S.
    National Instruments

  • Why shared variable generates events when I write constant value?

    Hello all,
    I'm using LV 8.5 with DSC packet.
    I modified "DSC Events Demo".vi and made a test. I noticed that only variable which work okay is double typed. Why this code generate events all the time when I write constant values to shared variables? Double is okay, but string and boolean types not work okay. Is there any other people how have noticed same symption?
    Attachments:
    modified_dsc_event_demo1.zip ‏391 KB

    You may get an initial event on startup which is normal.  Also make sure that you have not enabled timestamp change events.

  • Sharepoint Designer Copy list item over to new list when certain value is met

    Hi,
    I am copying over an item in one list over to a new list once it meets certain criteria. I have attached the workflow of what I am trying to do here. I have also attached a screenshot of the list on which I am moving item. The list I am moving item
    to is identical.
    For some reason however this is not working for me. What is happening is when I change the value of 'Current Status' to anyying at all the item is moving. I only want the item to move when it is set to 'Solution Agreed'.
    - Body text cannot contain images or links until we are able to verify your account.
    Thanks,
    Martin

    Hi,
    According to your post, my understanding is that you want to copy a specific list item to another list using workflow.
    I have two list “CustomList001” and “CustomList002”. The list contains two column “Title” and “Current Status”(Choice type). Then I create a workflow for “CustomList001”.
    The following workflow step for your reference:
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Calling a java script function when the value of an item changes

    Hi,
    I have got 2 items which are of "Text field(disabled,saves state)" type. The items are "P2_Industry" and "P2_Industry_segment". Have a link next to each item label, so that a pop up opens. Industry pop up shows all the industries and based on the selected industry, the industry segment pop up shows only the corresponding industry segment. Now, there is a problem. Once an industry and an industry segment is selected, if we change the industry, the industry segment does not change, which is not right. I want the industry segment field value to become null once the industry field is changed. Thought of writing an onChange html cell attribute, but don't know why, it is not working in the case of "Text field(disabled,saves state)" item. It works fine for just "Text field" item.
    Could anyone please help me with a solution as the item must be of "Text field(disabled, saves state)" type.
    Thanks,
    Vignesh

    Hi,
    This is the function I use to return value for P2_INDUSTRY and a similar one for P2_IND_SEGMENT as well.
    <script>
    function test(){
    var radioLength = document.wwv_flow.p_ind_array.length;
    var retVal = '';
    if(radioLength == undefined)
              if(document.wwv_flow.p_ind_array.checked)
                   retVal = document.wwv_flow.p_ind_array.value;
              else
                   return "";
         for(var i = 0; i < radioLength; i++) {
              if(document.wwv_flow.p_ind_array.checked) {
              retVal = retVal + ';' +document.wwv_flow.p_ind_array[i].value;
    retVal = retVal.substring(1, retVal.length);
    opener.document.getElementById('P2_INDUSTRY').value = retVal;
    window.close();
    </script>
    I guess the change needs to be done in page 2 only because, on change of INDUSTRY, the function needs to be triggered to clear INDUSTRY_SEGMENT value.
    Thanks,
    Vignesh
    Edited by: Vignesh N on Nov 3, 2009 12:37 AM

  • Variable has no value when executing a scenario

    Hi,
    I have a simple package consists of two steps:
    1. Refresh a variable "V_FILENAME_D501" to get the value inputted from user. The refreshing statement is "select '#V_FILENAME_D501' and it is running in a SQLServer environment.
    2. Execute an interface which loading data from a file (filename from step 1) into an essbase database.
    The execution failed at step 1 with the following error message:
    java.lang.Exception: Variable has no value: CBS_PRD_PROJECT.V_FILENAME_D501
    at com.sunopsis.dwg.dbobj.SnpVarSess.getValue(SnpVarSess.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.bindSessVar(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.bindSessVar(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskPreTrt(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlV.treatTask(SnpSessTaskSqlV.java)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.i(e.java)
    at com.sunopsis.dwg.cmd.h.y(h.java)
    at com.sunopsis.dwg.cmd.e.run(e.java)
    at java.lang.Thread.run(Unknown Source)
    Any Idea what happens?
    regards,
    James.

    Hi James,
    How are you?
    You can't query a file data store so it will error out. You need to build a small logic for that. Please follow the below steps to implement that.
    1. In your source data store just give the resource name as #CBS_PRD_PROJECT.V_FILENAME_D501
    2. Drag and drop that data store as your source in the interface.
    3. Make your variable V_FILENAME_D501 data type as Alphanumeric, Action as Not Persistent.
    4. Drag and drop the twice variable in your package make that as a Declare variable and in the second step make that as Refresh Variable then in the third step your interface.
    5. Generate a scenario out of that and while executing that scenario give the Value as your desired file name, hit enter once you gave, otherwise it wont take the input and make sure that LAST VALUE is UNCHECKED.
    PS: You can still do it without Default Value as *<%=odiRef.getSrcTablesList("", "[SCHEMA]/[RES_NAME]", "", "")%>* :)
    Thanks,
    G
    Edited by: Gurusank on Mar 16, 2009 2:58 PM

  • Rgding ORA-04091:table PURCHSE_DTL is mutating,trigger/function maynot c it

    I wrote a trigger 'TRG_PURCHASE_DTL' to update the stock table 'BRANCH_ITEM_STOCK' based on the DML actions perfomed on tables PURCHASE_DTL and ISSUE_DTL, but I am getting following error:-
    ORA-04091: table PURCHASE_DTL is mutating, trigger/function may not see it
    and the value of 'BRANCH_ITEM_STOCK.purchase_qty' is updated to 10 instead of 18.
    The table structure and data is given below:
    -- ============================================================
    -- Table: BRANCH_ITEM_STOCK
    -- ============================================================
    create table BRANCH_ITEM_STOCK
    BRANCH_CODE NUMBER(6) not null,
    ITEM_CODE NUMBER(6) not null,
    PURCHASE_QTY NUMBER(6) null ,
    RECEIPT_QTY NUMBER(6) null ,
    ISSUE_QTY NUMBER(6) null ,
    BALANCE_QTY NUMBER(6) null ,
    REMARKS VARCHAR2(100) null ,
    constraint PK_RA25_BRANCH_ITEM_STOCK primary key (BRANCH_CODE, ITEM_CODE)
    -- ============================================================
    -- Table: PURCHASE_MST
    -- ============================================================
    create table PURCHASE_MST
    BRANCH_CODE NUMBER(6) not null,
    PURCHASE_YR NUMBER(6) not null,
    PURCHASE_NO NUMBER(6) not null,
    PURCHASE_DT DATE not null,
    QUOTATION_NO NUMBER(6) not null,
    QUOTATION_YR NUMBER(4) not null,
    VENDOR_CODE NUMBER(6) not null,
    RECEIPT_NO VARCHAR2(25) null ,
    constraint PK_PURCHASE_HDR primary key (BRANCH_CODE, PURCHASE_YR, PURCHASE_NO)
    -- ============================================================
    -- Table: PURCHASE_DTL
    -- ============================================================
    create table PURCHASE_DTL
    BRANCH_CODE NUMBER(6) not null,
    PURCHASE_YR NUMBER(6) not null,
    PURCHASE_NO NUMBER(6) not null,
    REC_SNO NUMBER(6) not null,
    ITEM_CODE NUMBER(6) not null,
    ITEM_QTY NUMBER(6) not null,
    ITEM_PRICE NUMBER not null,
    ITEM_AMT NUMBER not null,
    constraint PK_PURCHASE_DTL primary key (BRANCH_CODE, PURCHASE_YR, PURCHASE_NO, REC_SNO)
    -- ============================================================
    -- Table: ISSUE_MST
    -- ============================================================
    create table ISSUE_HDR
    BRANCH_CODE NUMBER(6) not null,/* Issued from Branch*/
    ISSUE_YR NUMBER(6) not null,
    ISSUE_NO NUMBER(6) not null,
    ISSUE_DT DATE not null,
    ISSUED_BY VARCHAR2(15) not null,
    ISSUED_TO_BRANCH VARCHAR2(15) not null,
    ISSUE_STATUS NUMBER(6) null,
    constraint PK_ISSUE_HDR primary key (BRANCH_CODE, ISSUE_YR, ISSUE_NO)
    -- ============================================================
    -- Table: ISSUE_DTL
    -- ============================================================
    create table ISSUE_DTL
    BRANCH_CODE NUMBER(6) not null,
    ISSUE_YR NUMBER(6) not null,
    ISSUE_NO NUMBER(6) not null,
    REC_SNO VARCHAR2(25) not null,
    ITEM_CODE NUMBER(6) not null,
    ITEM_DTL VARCHAR2(400) null ,
    ITEM_QTY NUMBER(6) null ,
    RECEIPT_QTY NUMBER(6) null ,
    constraint PK_RA25_ISSUE_DTL primary key (BRANCH_CODE, ISSUE_YR, ISSUE_NO, REC_SNO)
    Assume that the Contents of PURCHASE_MST is as follows:
    SELECT branch_code, purchase_yr, purchase_no FROM PURCHASE_HDR;
    BRANCH_CODE PURCHASE_YR PURCHASE_NO     
    100          2008          1     
    100          2009          1     
    100          2009          2     
    Now I tried to insert follwing values to the PURCHASE_DTL table:
    insert into purchase_dtl (BRANCH_CODE,PURCHASE_YR,PURCHASE_NO,rec_sno,
    ITEM_CODE,item_QTY)
    Values (100,2008,1,1,4,5)
    insert into purchase_dtl (BRANCH_CODE,PURCHASE_YR,PURCHASE_NO,rec_sno,
    ITEM_CODE,item_QTY)
    Values (100,2009,1,1,4,2)
    insert into purchase_dtl (BRANCH_CODE,PURCHASE_YR,PURCHASE_NO,rec_sno,
    ITEM_CODE,item_QTY)
    Values (100,2009,2,1,4,6)
    commit
    Now Contents of table ' PURCHASE_DTL ' is as follows:
    BRANCH_CODE PURCHASE_YR PURCHASE_NO     REC_SNO ITEM_CODE     ITEM_QTY
    100          2008          1     1          4     5
    100          2009          1     1          4     2
    100          2009          2     1          4     6
    I want to write a trigger which will insert/update/delete data into/from BRANCH_ITEM_STOCK,
    so that the contents of column Purchase_qty of table BRANCH_ITEM_STOCK should be as follows:
    BRANCH_CODE     ITEM_CODE     PURCHASE_QTY     RECEIPT_QTY     ISSUE_QTY     BALANCE_QTY
    100          4          13          0          0          13
    [Note:  i.e BRANCH_ITEM_STOCK.PURCHASE_QTY = SUM(PURCHASE_DTL.item_qty) 
         where PURCHASE_DTL.branch_code=100
         AND PURCHASE_DTL.item_code=4
    Now run the following update statement.
    update purchase_dtl
    set item_qty= 10
    where BRANCH_code=100
    and purchase_yr in ( 2008) and purchase_no =1 and rec_sno = 1 AND item_code = 4
    commit
    Now the actual contents of column Purchase_qty of table BRANCH_ITEM_STOCK should be updated as follows:
    BRANCH_CODE     ITEM_CODE     PURCHASE_QTY     RECEIPT_QTY     ISSUE_QTY     BALANCE_QTY
    100          4          18          0          0          18
    But I am facing problem here. I am getting following error:-
    ORA-04091: table PURCHASE_DTL is mutating, trigger/function may not see it
    and the value of purchase qty is updated to 10 instead of 18
    Similarly if any issue of items happen (for eg:- issue_qty=2 to branch_code 200), then the purchase_qty =18,issue_qty=2 , balance_qty:=18-2=16 .
    So for branch_code 200 , receipt_qty = 2.
    Pls help me how to achieve the above .
    Source code which I tried is given below : (but confused at the end )..please help
    CREATE OR REPLACE TRIGGER trg_purchase_dtl
    BEFORE INSERT ON PURCHASE_DTL
    for each row
    declare
    -- local variables here
    l_qty number(6);
    l_cnt NUMBER;
    BEGIN
    BEGIN
    SELECT COUNT(*) into l_cnt
    FROM BRANCH_item_stock b
    WHERE b.BRANCH_code = :new.BRANCH_code
    AND b.item_code = :new.item_code ;
    dbms_output.put_line('1.after selet cnt= '||l_cnt);
    EXCEPTION when no_data_found then
    l_cnt := 0;
    dbms_output.put_line('2.in expt NDF selet cnt= '||l_cnt);
    null;
    END;
    IF INSERTING THEN
    dbms_output.put_line('3.before if ...going to insert ');
    IF l_cnt = 0 THEN
    dbms_output.put_line('hihhiii.......lcnt=0...item_code='||:old.item_code||'~l_qty='||l_qty);
    IF INSERTING THEN
         INSERT INTO BRANCH_ITEM_STOCK
    (BRANCH_code,Item_Code, PURCHASE_QTY,RECEIPT_QTY, issue_qty, balance_qty)
         VALUES(:NEW.BRANCH_code,:NEW.Item_Code, :NEW.ITEM_QTY,0, 0, 0);
    END IF;
    ELSIF l_cnt >0 THEN
    SELECT purchase_qty into l_qty
    FROM BRANCH_Item_Stock
    WHERE BRANCH_code = :new.BRANCH_code
    AND item_code = :new.item_code ;
    l_qty := l_qty + :NEW.ITEM_QTY;
    dbms_output.put_line('6.after selet qty= '||l_qty ||'~new qty='||:NEW.ITEM_QTY||'~old qty='||:OLD.ITEM_QTY);
    dbms_output.put_line('7.before update '||l_qty);
    -- IF INSERTING OR UPDATING THEN
    UPDATE BRANCH_ITEM_STOCK
              SET PURCHASE_QTY = l_qty
              WHERE BRANCH_code = :new.BRANCH_code
    AND item_code = :new.item_code ;
    dbms_output.put_line('8.after update= '||l_qty);
    --END IF;
    END IF;
    END IF; -- end of INSERTING
    -- END;
    --EXCEPTION WHEN DUP_VAL_ON_INDEX THEN
         IF UPDATING THEN
              dbms_output.put_line('9.if UPDATING...qty= '||l_qty ||'~new qty='||:NEW.ITEM_QTY||'~old qty='||:OLD.ITEM_QTY);
    BEGIN
    dbms_output.put_line('~old unotcode='||:old.BRANCH_code||'~old.item_code='||:OLD.ITEM_CODE||'~old itemqty='||:old.item_qty);
    dbms_output.put_line('~new unotcode='||:new.BRANCH_code||'~new.item_code='||:new.ITEM_CODE||'~new itemqty='||:new.item_qty);
    SELECT NVL(SUM(item_qty), 0) into l_qty
         FROM Ra25_Purchase_Dtl
         WHERE BRANCH_code IN ( :old.BRANCH_code )
         AND item_code in ( :old.item_code)
         AND item_qty <> :old.item_code ;
    EXCEPTION WHEN OTHERS THEN
    dbms_output.put_line('10.in EWO'||sqlerrm);
    END;
    --l_qty := l_qty + :NEW.ITEM_QTY;         
    dbms_output.put_line('11.after selet qty= '||l_qty ||'~new qty='||:NEW.ITEM_QTY||'~old qty='||:OLD.ITEM_QTY);
         UPDATE BRANCH_ITEM_STOCK
              SET PURCHASE_QTY = l_qty      --:new.item_qty
              WHERE BRANCH_code = :old.BRANCH_code
              AND item_code = :old.item_code ;
              dbms_output.put_line('13.after update ');
         END IF;
    IF DELETING THEN
    DELETE FROM BRANCH_ITEM_STOCK
    WHERE BRANCH_CODE = :OLD.BRANCH_code
    AND ITEM_CODe = :OLD.item_code;
    END IF;
    end trg_purchase_dtl;
    Please help me how to resolve this problem asap.
    -------------------------------------------------------------------------------------------------------------------------------------------------

    Hi,
    Welcome to the forum!
    See this thread [Avoiding Mutating Tables|http://asktom.oracle.com/tkyte/Mutate/index.html]
    Tip: to preserve formatted code enclose it between {noformat}{noformat} tags (start and end tags are the same) :)
    Thank you for posting DDL and DML of basic data, all people that post should follow this approach.
    Regards,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Variable Personalization - "Save Value" Variant Setting missing in Bex 7.x

    Hallo Experts,
    in Bex 3.x when creating a Variant (Button "Save All Variants" in the Variable Pop-Up)  i was able to decide (via field "Save Values" in the "Save All Variants" Screen) wheter i want to save the values for a certain variable or not (NO_IMPORT).
    In Bex 7.x i'm not able to find a functionality (corresponding to NO_IMPORT) to decide which variable should be saved in the variant.
    Does anybody know if/where i can find this feature in BEX 7.x?
    Thanks in advance,
    Sabine

    Hallo Den,
    thanks for your reply!
    Unfortunately this doesn't solve my problem. It's not about saving variants in Bex 7.x. But different behaviour in Bex 7.x compared to Bex 3.x.
    In Bex 3.x when saving a variant it was possible to decide, whether a value for the variable should be saved or not (via drop down boxes in the "Save All Variants" screen).
    In Bex 7.x i just can set the variable value to blank, if i don't want a value to be saved. I have no more settings here, as in Bex 3.x.
    As a consequence: i can set mandatory variables to blank in a 3.x query, when i set "Save Values" for this variable to "NO". In Bex 7.X i will always get an Error Message ("enter a value for variable XY") when selecting a variant with mandatory variable = blank.
    Best regards,
    Sabine

Maybe you are looking for

  • Inverter Board HP G60-447CL

    I have a HP G60-447CL with a bad inverter board.  The inverter board as the follwoing inforation on it. 19.21072.081 W15-A LFk These 2 words are on a white sticker on the board. Then there is YNV-W15 on the pcboard in white letters. I need a new inve

  • Classic startup problems

    When I launch a classic app, the classic startup is very slow (5 minutes), and I get a window that says that it it trying to connect to a server, which I cancel out of (twice), and then when classic finally does launch, it usually starts up AppleWork

  • Updating a JFrame with a new panel

    Hi, i want to switch a JPanel placed in my JFrame. But if i do so, i always have to maximize the window and then bring it back again, to see the changes work completely. I tried both repaint() and validate() but both do not work that I always have to

  • Smartform via Email

    Hi All, I have developed a driver program and a smartform for Tax Invoice in SD module.The printing is going on well.The requirement is that the client wants that this Invoice should be sent via email.Please guide me for this. My functional guy has c

  • Replacing faulty boot HDD.

    My 4 year old G5 has developed some hard disc problems. Catalog errors reported, fsck report IO errors in single user mode. I've made an external firewire boot clone via CCC (Carbon Copy Cloner) & ran DiskWarrior. DW reports that it will not replace