Accessing variables in Trigger (e.g. NoTransaction, NoInserts)

Hi,
I have a table where a process writes n DELETEs and m INSERTs. The commit is called at the end of the process, and lets call this commit a transaction (trx1). I have a trigger set on the table that fires when either a DELETE or INSERT occurs.
I am looking for a way in the trigger to get the following info:
1) Total number of inserts and deletes = n + m
2) Unique id for trx1. I need this unique id to be able to differentiate the transactions.
Any tips would be very very helpful!!

May be something like:
SQL> create table trace_tab as select * from dual where rownum < 1;
&nbsp
Table created.
&nbsp
SQL> create or replace package my_pkg
  2  is
  3    l_del_count integer;
  4    l_ins_count integer;
  5    tx_del_count integer;
  6    tx_ins_count integer;
  7    txi varchar2(30) := '-1';
  8  end;
  9  /
&nbsp
Package created.
&nbsp
SQL> create or replace trigger bud_emp_copy
  2  before insert or delete on trace_tab
  3  declare
  4   new_txi varchar2(30) := DBMS_TRANSACTION.LOCAL_TRANSACTION_ID;
  5  begin
  6   if my_pkg.txi != new_txi then
  7     my_pkg.tx_del_count := 0;
  8     my_pkg.tx_ins_count := 0;
  9     my_pkg.txi := new_txi;
10   end if;
11   my_pkg.l_del_count := 0;
12   my_pkg.l_ins_count := 0;
13  end;
14  /
&nbsp
Trigger created.
&nbsp
SQL> create or replace trigger audfer_emp_copy
  2  after insert or delete on trace_tab
  3  for each row
  4  begin
  5    if deleting then
  6     my_pkg.l_del_count := my_pkg.l_del_count + 1;
  7    else
  8     my_pkg.l_ins_count := my_pkg.l_ins_count + 1;
  9    end if;
10  end;
11  /
&nbsp
Trigger created.
&nbsp
SQL> create or replace trigger aud_emp_copy
  2  after insert or delete on trace_tab
  3  begin
  4  if DBMS_UTILITY.FORMAT_ERROR_STACK is null then
  5     my_pkg.tx_del_count := my_pkg.tx_del_count + my_pkg.l_del_count;
  6     my_pkg.tx_ins_count := my_pkg.tx_ins_count + my_pkg.l_ins_count;
  7  end if;
  8  end;
  9  /
&nbsp
Trigger created.
&nbsp
SQL> insert into trace_tab select rownum from emp where rownum < 11;
insert into trace_tab select rownum from emp where rownum < 11
&nbsp                                    *
ERROR at line 1:
ORA-12899: value too large for column "SCOTT"."TRACE_TAB"."DUMMY" (actual: 2,
maximum: 1)
&nbsp
&nbsp
SQL> insert into trace_tab select rownum from emp where rownum < 10;
&nbsp
9 rows created.
&nbsp
SQL> begin
  2   dbms_output.put_line('Inserted ' || my_pkg.tx_ins_count || ' rows ');
  3   dbms_output.put_line('Deleted ' || my_pkg.tx_del_count || ' rows');
  4  end;
  5  /
Inserted 9 rows
Deleted 0 rows
&nbsp
PL/SQL procedure successfully completed.
&nbsp
SQL> delete from trace_tab where rownum < 4;
&nbsp
3 rows deleted.
&nbsp
SQL> begin
  2   dbms_output.put_line('Inserted ' || my_pkg.tx_ins_count || ' rows ');
  3   dbms_output.put_line('Deleted ' || my_pkg.tx_del_count || ' rows');
  4  end;
  5  /
Inserted 9 rows
Deleted 3 rows
&nbsp
PL/SQL procedure successfully completed.
&nbsp
SQL> /* New transaction */
SQL> commit;
&nbsp
Commit complete.
&nbsp
SQL> delete from trace_tab where rownum < 2;
&nbsp
1 row deleted.
&nbsp
SQL>  begin
  2    dbms_output.put_line('Inserted ' || my_pkg.tx_ins_count || ' rows ');
  3    dbms_output.put_line('Deleted ' || my_pkg.tx_del_count || ' rows');
  4   end;
  5   /
Inserted 0 rows
Deleted 1 rows
&nbsp
PL/SQL procedure successfully completed.Rgds.

Similar Messages

  • How to access variables outside user exit

    Hi,
    I'm working with a user exit and my problem is that in a particular moment I have to access variables located outside the scope of the user exit (they are in a standard program)
    How can I reach these variables?
    thanks in advance

    Hi,
    If they are global variables then you can access them using Global assign technique,
    For example,
    FIELD-SYMBOLS: <fs_value> TYPE ANY.
    ASSIGN ('(SAPMV45A)XVBAK') TO <fs_value>.
    It is basically,
    ASSIGN ('(<Std. Program Name>)<Variable name>') TO <field symbol>.
    NOTE: To make sure they are accessible in your user exit, just put a break-point in the user exit and once you are there in debugging, type in,
    (<Std. Program Name>)<Variable name> in the Field names section and if it does not show it in RED then it is accessible..
    Hope this helps.. 
    Sri
    Message was edited by: Srikanth Pinnamaneni

  • How to Access Variables defined in the PopUpWindow

    Hi Friends
    I am building a flex site using flex builder 2.....
    Here I need your help.....
    My Problem is how to store a variable from a popup window
    I have this problem while in the login window comes as popup
    while clicking login button in the page a popup where user
    can enter username and password...
    after submitting if the login is successufl the popup
    vanish...
    After a successful login I need to store the logged user name
    in the main index page but I am not able to store
    At first I created a variable 'loggedUsername' in the popup
    panel and after success log i assigned the username to it ... after
    it i am not able to get the loggedUsername..
    doubting I defined the variable in the main index.mxml page
    but this variable is not accessible from the loginwidow.mxml page
    where the popup will function...
    Heip me
    how to store the name if the user login is success..
    thanks
    Chintu...

    Lets say you have a public property in your application like
    public var name:String = "John Smith";
    to access this using an inline item renderer:
    <mx:itemRenderer>
    <mx:Component>
    <mx:VBox>
    <mx:TextInput text={outerDocument.name} />
    </mx:VBox>
    </mx:Component>
    </mx:itemRenderer>
    To access variables of the applicaton you can use
    Application.application.name (for example) to reference "global"
    variables, so you might also use this technique. With an inline
    item renderer, the outerDocument property will refer to the
    component which contains the renderer.

  • How to access variables declared in main mxml in itemrenderer files

    Hi,
    I have a main mxml which has a cutomRenderer that defines two
    mxml components
    namely raidobutton and textinput.
    Now in this TextInput.as i need to access variable defined in
    main mxml.
    Please suggest a way.
    Thanks,
    Lucky

    Lets say you have a public property in your application like
    public var name:String = "John Smith";
    to access this using an inline item renderer:
    <mx:itemRenderer>
    <mx:Component>
    <mx:VBox>
    <mx:TextInput text={outerDocument.name} />
    </mx:VBox>
    </mx:Component>
    </mx:itemRenderer>
    To access variables of the applicaton you can use
    Application.application.name (for example) to reference "global"
    variables, so you might also use this technique. With an inline
    item renderer, the outerDocument property will refer to the
    component which contains the renderer.

  • How To Access Variables In Process Model For Use In Main Sequence

    Hi everyone, in my sequence file I callback the PreUUT sequence file.  I want to be able to use one of the local variables I assign in this callback sequence in my main sequence.  In my main sequence this variable will trigger if I should run some tests or not in my main sequence.  Is this possible?  How would I do this?
    Thanks so much!

    U need to make a parameter in your Callback, parameters are seen outside of sequences, then in PreUUT u will make statement to update parameter, or use the parameter in your callback  directly
    Parameters.MyPara=Locals.MyLoc
    etc

  • Can't access variables in specific S7-1200 DB's in LabVIEW project

    Hi all,
    I'm trying to establish a connection between LabVIEW and a Siemens S7-1200 though Ethernet and SIemens OPC Server.
    The physical connection is OK (I can ping S7-1200 with no problem).
    When I needed to access variables from specifics DB's inside S7-1200 ( I want to access variable DB190,X0.4), I called Siemens support and they said I had to modify the variable's definition when using OPC Scout, from "MX0.4" to "DB190,X0.4", and then it was possible to access this variable.
    Same solution (renaming the path) applies to NI OPC Client, I can read and write variables properly.
    My problem is that when I try to add variables in LabVIEW Project, I can't find those variables whose address were modified, so I can't access the correct variable in my program.
    I tried to change the variable path in Multiple Variable Editor, but it doesn't work either.
    Any suggestions on what I can try??

    First: Avoid the ODBC/JDBC Bridge if at all possible.
    It's the worst JDBC driver I've ever seen. It's buggy
    and a great hindrance both to learning and to
    producing usefull code.I agree that there might be problems with M$ Access, but there are problems with all databases, including MySQL (e.g., no referential integrity in free download version). It's capable enough for the query the OP is trying to execute.
    The problem is with his code, not Access or the bridge driver. He'll go through a lot of effort to switch databases and still have this problem. Better to understand what HE'S done wrong and fix it so he'll do it correctly for all databases, including Access.
    You just need to be more careful with your query, I'm sure.
    %

  • Access variables in Package.

    Hi I have a apackage called share.server , in which I have defined
    Hashtable hash;
    i have another file in share package as Impl, here i want to call the "hash"
    how can i access the same "hash" in Impl.java from FilServer which is in share.server package.
    Please respond urgent, assignment is due soon.
    Thanks for any response.

    what?!
    variables belong to classes, not packages. If you want to access variables between classes you need to define some kind of public interface for them (getters and setters... ring any bells?). This is basic basic OOP, and is called encapsulation. First thing you need to do is get a basic 'OOP with java' type book and read it fully. We can't help you if you can't help yourself/

  • Access variables within a timer

    How can I access variables within a timer?
    I mean variables, that I can use in another class that extends applet i.e.?

    The Code can be compiled now with the Java Compiler.
    But the image won't move on the screen.
    import java.applet.*;
    import java.awt.*;
    import java.util.*;
    public class ChangingApplet extends Applet {
      private Image EricsBild;
      private int x,y;
      private TimerTask update;
      public void start() {
      EricsBild = getImage(getCodeBase(), "heuschrecke.gif");
      x=5;y=5;
        update = new TimerTask() {
          public void run() {
            if (x<300) x++;
            if (y<200) y++;
            if (x>3) x--;
            if (y>2) y--;
            repaint();
        Timer t = new Timer(false);
        t.schedule(update, 1000, 1000);
      public void stop() {
        update.cancel();
      public void paint(Graphics g) {
        g.drawImage(EricsBild,x,y,this);
    }

  • Accessing variable in main mxml from component

    I have the following problem, i have a main mxml and
    component mxml which i import in my main file. I need to access
    variable in main mxml file from that component but i don't know how
    to reference my main mxml from component? Can someone please help
    me with this?
    thanks in advance

    Try this
    this.parentApplication.main_mxml.variableID = 34;
    Rgds
    JFB
    "msabljic" <[email protected]> wrote in
    message
    news:fd2u5k$a17$[email protected]..
    >I have the following problem, i have a main mxml and
    component mxml which i
    > import in my main file. I need to access variable in
    main mxml file from
    > that
    > component but i don't know how to reference my main mxml
    from component?
    > Can
    > someone please help me with this?
    >
    > thanks in advance
    >

  • From which verison of oracle support the :NEW variable in trigger

    A trigger using the :NEW variable can be compiled in oralce 10g but can't in oracle7 .
    Does oracle 7 support the :NEW variable?

    >
    A trigger using the :NEW variable can be compiled in oralce 10g but can't in oracle7 .
    Does oracle 7 support the :NEW variable?
    >
    You can answer questions like this yourself by always checking the documentation first.
    NEW is not a variable, it is a correlation name.
    See 'The Trigger Body' section in the Oracle7 Server Application Developer's Guide
    http://docs.oracle.com/cd/A57673_01/DOC/server/doc/ADG73/ch9.htm
    >
    The Trigger Body
    The trigger body is a PL/SQL block that can include SQL and PL/SQL statements. These statements are executed if the triggering statement is issued and the trigger restriction (if included) evaluates to TRUE. The trigger body for row triggers has some special constructs that can be included in the code of the PL/SQL block: correlation names and the REFERENCING option, and the conditional predicates INSERTING, DELETING, and UPDATING.
    Accessing Column Values in Row Triggers
    Within a trigger body of a row trigger, the PL/SQL code and SQL statements have access to the old and new column values of the current row affected by the triggering statement. Two correlation names exist for every column of the table being modified: one for the old column value and one for the new column value. Depending on the type of triggering statement, certain correlation names might not have any meaning.
    A trigger fired by an INSERT statement has meaningful access to new column values only. Because the row is being created by the INSERT, the old values are null.
    A trigger fired by an UPDATE statement has access to both old and new column values for both BEFORE and AFTER row triggers.
    A trigger fired by a DELETE statement has meaningful access to old column values only. Because the row will no longer exist after the row is deleted, the new values are null.
    The new column values are referenced using the NEW qualifier before the column name, while the old column values are referenced using the OLD qualifier before the column name. For example, if the triggering statement is associated with the EMP table (with the columns SAL, COMM, etc.), you can include statements in the trigger body similar to
    IF :new.sal > 10000 . . .
    IF :new.sal < :old.sal . . .
    Old and new values are available in both BEFORE and AFTER row triggers. A NEW column value can be assigned in a BEFORE row trigger, but not in an AFTER row trigger (because the triggering statement takes effect before an AFTER row trigger is fired). If a BEFORE row trigger changes the value of NEW.COLUMN, an AFTER row trigger fired by the same statement sees the change assigned by the BEFORE row trigger.
    Correlation names can also be used in the Boolean expression of a WHEN clause. A colon must precede the OLD and NEW qualifiers when they are used in a trigger's body, but a colon is not allowed when using the qualifiers in the WHEN clause or the REFERENCING option.
    The REFERENCING Option

  • How to access variables in webservice

    Hai,
    I am using SAP Netweaver Developer Studio. I want to handle the error codes by using a variable in the session bean. but i am not able to access the variable . please help me asap.

    ok, the answer is here
    http://blog.flexexamples.com/2008/08/28/creating-a-component-instance-by-class-name-in-act ionscript-30/

  • How to access variables indirectly using JSTL

    Hi,
    I have a variable called titleInsert pointing to a session variable someSessionVariable. The jsp has access to titleInsert but would like to output the value of someSessionVariable which is pointed to by tilesInsert.
    If I have something like
    <c:out value="${titleInsert}"/>
    the name of the session variable is being displayed but not the value.
    I tried something like
    <c:out value="$${titleInsert}"/> and
    <c:out value="${${titleInsert}}"/> and both resulted in JSP exceptions.
    Is there a way to display the value of someSessionVariable?
    Help appreicated,
    Kumar

    You use the implicit variable sessionScope, and the square brackets notation.
    <c:out value="${sessionScope[titleInsert]}"/>Cheers,
    evnafets

  • How to access variables across JSP and JavaScript?

    Hi,
    I have some .js files and in those files, some of the methods need to access to the variables that I'd declare in the jsp files. How do I do it?
    Anne

    You can do it this way, but I'm not sure if this is what you had in mind.
    Say you had a java variable called XString. And you wanted to display
    the value of XString in a javascript Alert. Here's how:
    <html>
    <body>
    <% String XString = "Hi There!"; %>
    </body>
    <script language="javascript">
    alert("<%=XString%>");
    </html>Hope This Help,
    P.

  • How to access variables from other class

        public boolean inIn(Person p)
            if  (name == p.name && natInsceNo == p.natInsceNo && dateOfBirth == p.dateOfBirth)
                 return true;
            else
                 return false;
        }//returns true if Person with same name/natInsceNo/dateOfBirth as phello,
    here am trying to compare the existing object with another object.
    could you please tell me how to access the variables of other class because i meet this error?
    name cannot be resolved!
    thank you!

    public class Person
        protected String name; 
        protected char gender;      //protected attributes are visible in the subclass
        protected int dateOfBirth;
        protected String address;
        protected String natInsceNo;
        protected String phoneNo;
        protected static int counter;//class variable
    //Constractor Starts, (returns a new object, may set an object's initial state)
    public Person(String nme,String addr, char sex, int howOld, String ins,String phone)
        dateOfBirth = howOld;
        gender = sex;
        name = nme;
        address = addr;
        natInsceNo = ins;
        phoneNo = phone;
        counter++;
    public class Store
        //Declaration of variables
        private Person[] list;
        private int count;
        private int maxSize;
    //constructor starts
        public Store(int max)
             list = new Person[max];//size array with parameters
             maxSize = max;
             count = 0;
        }//end of store
    //constructor ends
    //accessor starts  
        public boolean inIn(Person p)
           return (name == p.name && address == p.address && natInsceNo == p.natInsceNo);
        }//returns true if Person with same name/natInsceNo/dateOfBirth as phope it helps now!

  • How to access variables??

    how to access public variables of any other class??
    suppose i have a file temp.java file ..& i know all the public variables. and
    i want to access the variable of those temp.class file which extends JApplet or Applet..
    and as u know it will declare public void init() .. & in this function only all declaration will be there.
    so now how to invoke this init() function from any mymethod()..to access public variables...

    its not working. for me..
    the variable which i m trying to access is non static.. its displays the error :
    Exception in thread "AWT-EventQueue-1" java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread
    and by one method i have connected database also.. and it has been called from init()..
    i have collected the data from the database..and i m storing the data in one ArrayList ..
    and i want to access that ArrayList..

Maybe you are looking for

  • How to I restore missing StickiesDatabase file from Time Machine?

    I have looked all over for a solution to this. Basically, I am trying to restore a stickiesdatabase file from a Time Machine backup. I put in a new HD and am slowly pulling files over in pieces. The thing is, the backup that had the stickies I want t

  • Dashboard Performance Issue

    HI Ingo, Thanks a lot for the wonderful postings in SDN and for your blogs on SAP BI/BO Solution architecture. I  am looking for few clarifications on SAP BO Xcelsius Dashboards.  Though I know limitations on component number and data volumes which c

  • RFC Receiver Error

    Hi Im doing a File-RFC-File scenario wothout BPM. Getting the following error in RFC reveiver Adapter <SAP:AdditionalText>com.sap.aii.af.ra.ms.api.DeliveryException: RfcAdapter: receiver channel has static errors: can not instantiate RfcPool caused b

  • U2 album showing purchased but can't download on my iPhone

    When I go on iTunes the album shows purchased but I can't find it ANYWHERE on my phone.  I'm aware of the fixes from my desktop but I haven't seen any to download it on my phone (I'm not near my desktop). Thanks

  • A problem about getEnhancedMicrophone()

    In my AIR application code as below step 1. var microphone:Microphone = Microphone.getEnhancedMicrophone(); step 2. var connection:NetConnection = new NetConnection(); connection.connect("rtmp://localhost:1935/emcs"); step 3. var httpService:HTTPServ