Detecting changes in JTable

I am using a JTable to display information that the user will update. I would like to wait until all of the changes have been made, then process the updates in response to a button click. Is there a way to determine which cells have been updated without going through the whole table and checking for equality?

A simple way is this:
Use the DefaultTableModel.
Create a custom Class row extends Vector. this represents a row Vector in your data model.
Add to row class an attribute: for example: boolean changed and set it false in the constructor.
Now you must write the setValueAt method of the model, where you must read the previous value, sets the new value, and then check for changes and set the changed attribute.
Finally, in the save ButtonListener you check the changed boolean for all rows.

Similar Messages

  • Detecting changes

    hi folks,
    I have a swing application that has a functionality to save the input. I want to know what is the common way to detect modification of input. If there's modification, i want to prompt the user to save if he/she is closing down the app. I'm thinking about using a listener on all input components(JTextField, JList, JComboBox,JTable,JButton). But the listener would be different for each type of component, ActionListener for JButton, CaretListener for JTextField, ListSelectionListener for JList, ect. So I want to write a class that implements all these Listeners, and if any of those events is triggered, then I know there's modification been made.
    My question is: is there a better/more efficient/more elegant way of detecting changes in my app?
    If not, any comments on my approach?
    thanks!!

    You can write an unique class implementing DocumentListener, ActionListener, ItemListener, etc..
    But you still have to add the listener to all the components.
    I'm thinking you can write a method void register(JComponent pane) Depending on the class JTextField,JCheckBox, etc... you add the class as a DocumentListener,
    as an ActionListener, etc. If the component is a container, you can recursively invoke the method
    for all the children

  • XY-Graph / Plot legend: How to detect changes in 2nd/3rd/4th ... legend position

    Hello,
    I have an XY-Graph with 4 plots. How can I detect, for example, the color change of the second plot in the legend. The active plot, using a property node, is always plot 0. So I am not able to detect changes in the 2nd/3rd ... plot.
    Any ideas?
    Thanks a lot.
    Best regards,
    Michael
    Solved!
    Go to Solution.

    You can do it with an event sturcture.
    Attachments:
    Plot detect.vi ‏25 KB

  • Event Structure's value change, not detecting changes when tabbing thru array of clusters

    Hi!  I have an array of clusters (int, int, string, int) control, and want to detecting changes made to the it.  I used the Event Structure's value change case on the array, it works excellent except that it'll only detect the changes when you click out of the element or press the enter key (the one by the numbers, not carriage return).  I want it to detect the changes when I tab thru the cluster or array too, but I can't figure it out... Does anyone have any ideas?
    Thanks!

    mfitzsimons wrote:
    altenbach
    Tried Value Change with my example done in 7.1 and it doesn't trgger an event.  That is why I suggested Mouse Down.
    Curious. I did a few minor edits in 8.0 before saving as 7.1, but the simple value change event got triggered just fine when the value vas terminated with a tab in 7.1. Every time.  Strange....
    Are you on 7.1 or 7.1.1? Maybe there's a difference (I am using 7.1.1).
    LabVIEW Champion . Do more with less code and in less time .

  • Detect changes in an instance

    Hello,
    how can I detect changes in an instantiated object? I could serialize the object and write it into a file. After some minutes I could write it a second time into a file. Now I could compare the two files. But I thing this is not the best way for doing this, isnt't it.
    Any suggestions?
    Thanks

    it can be of any help, here's how I implement object changes:
    /** Interface for object instances comparison */
    interface ContentComparable {
       /** Returns a string describing the object instance for comparison */
       public String getCompareString();
    /** Custom class sample */
    public class CustomClass implements ContentComparable {
       private String    customField1;
       private int       customField2;
       /** Constructor */
       private CustomClass(String field1, int field2) {
          this.customField1 = field1;
          this.customField2 = field2;
       //------------------------------------------------------------ ContentComparable ---
       /** Returns a string describing the object instance for comparison */
       public String getCompareString() {
          String content = this.getClass().getName() + "["
                           + "customField1='" + this.customField1 + "', "
                           + "customField2=" + this.customField2 + "]";
           return content;          
       /** Returns TRUE if the object is equal to an other object
        * @param   otherobj  the other object
        * @return  TRUE or FALSE
        * @see #getCompareString()
       public boolean equals(Object otherobj) {
          if (otherobj instanceof CustomClass) {
             CustomClass classobj = (CustomClass)otherobj;
             return this.getCompareString().equals(classobj.getCompareString());
          return false;
    }With that, you just have to keep a copy of the getCompareString() of the object before any changes are made.
    When you want to test changes, call this method:
       // private member to hold copy of unchanged object string
       private String oldObjectValue;
       // Returns TRUE if object has changed
       private boolean testDataChanged() {
          if (oldObjectValue == null) oldObjectValue = object.getCompareString();
          String newObjectValue = object.getCompareString();
          return !oldObjectValue.equals(newObjectValue);  
       //...Hope this helped,
    Regards.

  • Adobe Revel not detecting changes to my catalogue

    When I sign in to Adobe Revel via Elements 12 it says it is detecting changes but then does nothing; no sync'ing symbol or anything.  Any ideas?

    Hi,
    Yes I did that when it wouldn't sync and it all got uploaded.  My iPad photos sync fine so I'm thinking it may be my pc. Macafee maybe?
    Sent from my iPad

  • Elements Agent stuck on Detecting Changes in PSE13

    I am running PSE13 on a Windows 8.1 desktop.
    My photo catalogue has about 40K pictures, but only 3K have been uploaded from PSE13 to Revel.  The Elements Agent is stuck on "Detecting Changes" and not synchronizing with Revel.
    I have signed out/in within PSE13 and turned the Elements Agent off and then on.  Still no changes.
    On my desktop, I have turned off all services and startup programs except for Adobe programs.
    Looking for help.

    Thanks a lot for replying, your example is being of help but
    i think you misunderstood my post and i still have some doubts.
    More than one item can be a winner, not just one, so i will
    have to call an update for each item.
    On my fill method i have something like this:
    public List fill(List fillParameters){
    List results = new ArrayList();
    results = dao.getBids();
    results = checkWinners(results); //this function checks each
    item and sets the winner porperty to true or false.
    return results;
    So when i call on Flex DataService.fill() it obtains the list
    of bids and each has its winner property to true or false. Then i
    insert a new item and the fill method is executed again (due to
    autoRefreshFill) and winner properties is set again but the
    updateCollection message only includes the new added item, it
    doesn't check for updates.
    So now, the real deal is where would i call the updateItem to
    push the changes? Should i call the updateItem inside the
    createItem function? on the refreshFill function? inside the fill
    function?
    I have checkWinners() function which is the one i call inside
    the fill function and that sets the winner property of each item,
    should i call the DataServiceTransaction.updateItem from there? I
    have my doubts because i am calling this function inside the fill
    method.
    So it all sums up in "where should i call the updateItem?"
    Thanks for you help, hope you can help me out with this last
    issue :)

  • Detecting changes in video

    Greetings all. I'm new to video editing and Premiere.
    Is anyone aware of a plug-in or software that can detect changes in video? I have been setting up my camera to shoot lightning vids, then walking away for minutes at a time. Needless to say, the flashes can be as short as a couple of frames, and locating these extremely short sections of clips can be very time consuming when visually searching frame-by-frame.
    I would think there would be a need for something like this for not only my situation, but for nature video or surveillance. The ideal app would locate changes in the scene and mark or log the locations.
    Thanks for any advice.
    Jeff Barnett

    Ok, wise guy! Are you telling me that you wouldn't chase lightning with me just because I've been hit before? Basic math: The odds are the same for me being struck now as they were the first time when I was 9. It's not like I go out wrapped in tin foil and climb trees to catch the perfect shot!
    And I'm sorry, but I ain't 18 no more ... I'm 55. I finally realized that I'm not indestructible like I was at that age. Besides, call me a weenie, but lightning images with interesting content (cityscape and North GA mountains in the distance), shot from within a giant Faraday cage (office building), is more visually interesting than from under the eaves of an aluminum strip shopping center with a tree shrouded 7-11 in the foreground! We have lots of trees here! LOL Like I said ... never found the great shot!
    Actually, my Canon does have a pre-roll function, but only 3 seconds, if I recall correctly. Really cool feature that I've used in conjunction with my remote to record a wren repeatedly returning to feed her hatchlings in a barn.
    I've used slaves for still work, but I'm not sure if I can get one to trigger my camcorder. I would either have to have some kind of PC (flash trigger) to infrared remote converter, or one that converts to the LANC input. Maybe other options, but I haven't discovered them.
    Thanks for the info, chuckle, and vote of confidence!
    Jeff

  • Detecting changes in the replication site list

    Is there a way, when using the replication manager, to detect changes in the replication site list without having to continuously call repmgr_site_list()?
    Even if you still need to call repmgr_site_list() to determine just what changed, it would still be useful to only call it when the result would be different than the previous call.

    Currently, no. However, we are working on an enhancement for a future
    release that would include such a feature.
    Drop me an email, if you like. My address conforms to the Oracle
    convention: [email protected]
    Alan Bram
    Oracle

  • Detecting changes in database

    Hi,
    I connected to MySQL database using JDBC, displayed all data I need. But now I would like to detect changes in database (for example when somebody in network insert new row, I need get an event and then read data from database again).
    Did any body know how to detect changes in database???
    Thank you.
    Petr

    your question is too general, there are many ways of doing this. what is it you're doing?

  • What are detected changes in tfs vs 'changes'

    Hello,
    I've done a lot of changes in our tfs collection like creating different branches and renaming/moving stuff, and change our primary workspace from server to local (vs2013).
    After checking in EVERYTHING from inside VS, when I'm issuing the command 'tf status', it returns a lot of changes, and the final line tels me "0 change(s), 3858 detected change(s)"   (every change is an 'add' type) . I've never seen
    that. what does it mean, that difference betwee 'changes' and 'detected changes' ? When I check from pending changes from VS it shows ZERO changes.
    Also, I've seen that 'tf status' has a toogle '[/nodetect]' that our beloved docs at msdn do not explain, they only mention it (https://msdn.microsoft.com/en-us/library/9s5ae285.aspx)... What's the point for that option ?
    Thanks in advance,
    Roger Tranchez

    Hi Roger,
    take a look at this blog post (http://blogs.msdn.com/b/phkelley/archive/2013/05/29/server-workspaces-vs-local-workspaces.aspx)
    While edits in a local workspace can be pended implicitly just by editing the file, adds and deletes still must be explicitly pended. However, TFS version control’s workspace scanner also detects new files which are ‘candidates’ for addition, and missing
    files and folders which are candidates for deletion. The Team Explorer’s Pending Changes Page has a link which shows the number of detected adds and deletes, and provides a link to the Promote Candidate Changes dialog which can be used to pend ‘real’ adds
    or deletes on these items. This is called “promoting” the candidate adds and/or deletes – because they become real pending changes.
    Detect Changes comes from local Workspace.
    Regards,
    Daniel

  • Data changes in JTable

    hi experts
    i'm tring to detect the data change in the JTable. The java.sun.com
    gives one ex on this using "TableModelListener". but the program is
    giving errors on using that. I want to detect the data changes
    and also to save the data in its new form. how can i do it??
    Also, if ur having a large table data and the user changes only one cell , do i have to write the whole table back to the database ???
    Ashish

    here is the code. if i write "implements TableModelListener" then
    an error occurs
    import java.sql.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class TableDisplay extends JFrame implements TableModelListener{
    private Connection connection;
    private JTable table;
    public TableDisplay()
    //using JDBC to connect to a Microsoft ODBC database.
    String url = "jdbc:odbc:trial";
    String username = "ashish";
    String password = "ashish";
    // Load the driver to allow connection to the database
    try {
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    connection = DriverManager.getConnection(
    url, username, password );
    catch ( ClassNotFoundException cnfex ) {
    System.err.println(
    "Failed to load JDBC/ODBC driver." );
    cnfex.printStackTrace();
    System.exit( 1 ); // terminate program
    catch ( SQLException sqlex ) {
    System.err.println( "Unable to connect" );
    sqlex.printStackTrace();
    getTable();
    setSize( 500, 350 );
    show();
    private void getTable()
    Statement statement;
    ResultSet resultSet;
    try {
    String query = "SELECT * FROM shippers";
    statement = connection.createStatement();
    resultSet = statement.executeQuery( query );
    displayResultSet( resultSet );
    statement.close();
    catch ( SQLException sqlex ) {
    sqlex.printStackTrace();
    private void displayResultSet( ResultSet rs )
    throws SQLException
    // position to first record
    boolean moreRecords = rs.next();
    // If there are no records, display a message
    if ( ! moreRecords ) {
    JOptionPane.showMessageDialog( this,
    "ResultSet contained no records" );
    setTitle( "No records to display" );
    return;
    Vector columnHeads = new Vector();
    Vector rows = new Vector();
    try {
    // get column heads
    ResultSetMetaData rsmd = rs.getMetaData();
    for ( int i = 1; i <= rsmd.getColumnCount(); ++i )
    columnHeads.addElement( rsmd.getColumnName( i ) );
    // get row data
    do {
    rows.addElement( getNextRow( rs, rsmd ) );
    } while ( rs.next() );
    // display table with ResultSet contents
    table = new JTable( rows, columnHeads );
         table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane scroller = new JScrollPane( table );
    getContentPane().add(
    scroller, BorderLayout.CENTER );
    validate();
    catch ( SQLException sqlex ) {
    sqlex.printStackTrace();
    private Vector getNextRow( ResultSet rs,
    ResultSetMetaData rsmd )
    throws SQLException
    Vector currentRow = new Vector();
    for ( int i = 1; i <= rsmd.getColumnCount(); ++i )
    /* switch( rsmd.getColumnType( i ) ) {
    case Types.VARCHAR:
    currentRow.addElement( rs.getString( i ) );
    break;
    case Types.INTEGER:
    currentRow.addElement(
    new Long( rs.getLong( i ) ) );
    break;
    default:
    System.out.println( "Type was: " +
    rsmd.getColumnTypeName( i ) );
    currentRow.addElement( rs.getString( i ) );
    return currentRow;
    public void shutDown()
    try {
    connection.close();
    catch ( SQLException sqlex ) {
    System.err.println( "Unable to disconnect" );
    sqlex.printStackTrace();
    public static void main( String args[] )
    final TableDisplay app = new TableDisplay();
    app.addWindowListener(
    new WindowAdapter() {
    public void windowClosing( WindowEvent e )
    app.shutDown();
    System.exit( 0 );

  • Changing a JTable's model

    Hello everyone,
    I dont have a whole lot of experience w/ JTables and this problem has been troubling me for a while now. I have a JTable that significantly changes when the user hits the calculate button, so instead of going through the trouble of completely reformatting the table by adding/removing columns and table headers, I simple make a new model and set the table's model to the new one, and then call table.updateUI(). The problem is that my custom cell renderer that displays a down or up arrow depending on how the given column is sorted stops working. The sorter works properly and the table displays properly, but the arrows do not change from up to down or vise versa when a column is resorted. The whole process works just fine the first time, but the more times the user pushes the calculate button the more off it gets. I have added a flag in the actionPerformed method in my cell renderer that tells me when the table header is clicked. Every time the calculate button is hit, more flags appear when the table header is clicked. Therefore the arrows change position on odd numbers and do not on evens (because the evens cancel eachother out and the arrow appears to sit still), however the sorter still works properly. It seems as though somehow a new mouse listener or cell renderer is added after each time the calculate button is pressed. Either that or the entire table is not being reset somehow and something is still invisible in the background.
    Here is some of my code.
    // The initial table with no data
    String[] str = {"class 1", "class 2", "class 3", "class 4", "class 5", "= GPA"};
    String[][]  data= {{"", "", "", "", "", ""},
    pmModel = new ProjectionModel(str, data);
    mainTable = new JTable(pmModel);
    mainTable.getTableHeader().setDefaultRenderer(new SortButtonRenderer());
    // After the calculate button has been pushed:
    // The table is reset here. TableSorter extends TableMap
        ProjectionModel newModel = new ProjectionModel(courseList, charList);
        TableSorter sorter = new TableSorter(newModel);
        // this method is shown below
        sorter.addMouseListenerToHeaderInTable(mainTable);
        sorter.sortedUp = false;
        mainTable.addNotify();
        mainTable.setModel(sorter);
        // SortButtonRenderer extends TableCellRenderer
        SortButtonRenderer renderer = new SortButtonRenderer();
        mainTable.getTableHeader().setDefaultRenderer(renderer);
        // set the arrow to DOWN on the first column
        renderer.setSelectedColumn(0);
        renderer.setSelectedColumn(0);
        mainTable.updateUI();
    // This is the addMouseListenerToTable(JTable table) found in the TableSorter class
        public void addMouseListenerToHeaderInTable(JTable table) {
            final TableSorter sorter = this;
            final JTable tableView = table;
            tableView.setColumnSelectionAllowed(false);
            MouseAdapter listMouseListener = new MouseAdapter() {
                public void mouseClicked(MouseEvent e) {
                    TableColumnModel columnModel = tableView.getColumnModel();
                    int viewColumn = columnModel.getColumnIndexAtX(e.getX());
                    int column = tableView.convertColumnIndexToModel(viewColumn);
                    if (e.getClickCount() == 1 && column != -1) {
                      SortButtonRenderer renderer =
                            (SortButtonRenderer)tableView.getTableHeader().getDefaultRenderer();
                        //int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK;
                        //boolean ascending = (shiftPressed == 0);
                        boolean ascending = (renderer.getLastColumn() == column && !sortedUp);
                        renderer.setLastColumn(column);
                        sorter.sortByColumn(column, ascending);
                        if (ascending) sortedUp = true;
                        else sortedUp = false;
                        renderer.setSelectedColumn(column);
                        // the flag that prints the column that is pressed
                        System.out.println(column + " " + sortedUp);
            JTableHeader th = tableView.getTableHeader();
            th.addMouseListener(listMouseListener); // it seems like i need a way to remove any
    // previous mouseListeners here, i think this would solve the problem
        }The flag's output looks something like this:
    < first time calculate button is clicked >
    < column 0 is clicked> 0 false
    < column 0 is clicked again > 0 true
    < second time calculate button is clicked >
    < column 0 is clicked >
    0 false
    0 true
    notice they cancel eachother out so the arrow stays in the same position
    < third time calculate button is clicked >
    < column 0 is clicked >
    0 false
    0 true
    0 false
    notice they dont cancel eachother out, so the arrow changes positions
    This problem is really bugging me. I appreciate any help. Thanks.
    -kc

    Well I fixed my problem but I kind of cheated...
    I used a static variable in the class that inits the GUI to keep track of the MouseListeners that are added to the table headers by the TableSorter. In the TableSorter class's addMouseListenerToTableHeader(JTable table) class I added a line of code before the "th.addMouseListener(listListener)" line: "th.removeMouseListener(Projector.lastListener))"
    It works but it kind of sucks. If there is a better way to do it that would be great. I'm sorry if you read through all of that stuff and then I ended up fixing my own problem anyway :(
    Thanks anyway.
    -kc

  • Way to listen for change in JTable cell?

    I am having troubles trying to catch a key event while the user is entering text inside a given JTable cell (x/y location). The JTable only seems to manage String objects in it's cells so I can't place a JTextField in there with a KeyListener on it.
    Currently, I can only get control of the application once the user has left the cell they are editing.
    Does anyone have an example of a JTable 'cell KeyListener' scenario? At this point I want to see if I can print 'hello world' each time I type a character within a cell. Then I'll go from there....

    If you want to know when the contents of a cell have been updated you should use a TableModelListener.
    If you want to know when a character is added/removed from the cell editor then you need to first understand how this works with a simple text field.
    Typically you would use a DocumentListener to receive notifies of a change to the text field. However, within the DocumentEvent you wouldn't be able to change the text field as this notification comes after the text field has already been updated.
    If you need to ability to intercept changes to the text field before they happen, then you would need to use a DocumentFilter. An example of using a DocumentFilter is given in the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#filter]Text Component Features.
    Once you get your regular text field working the way you want, the next step to create a DefaultCellEditor using this JTextField and use this editor in your JTable. The above tutorial also has a section on using editors in a table.

  • Detecting Change in Elements between Versions of XML Doc

    Hi There
    I have a structured XML Schema based table in XMLDB 9.2.0.4 and am trying to detect when a non-repeating element off the root element changes (audit).
    I have created a row level update trigger and each time one element is changed via UPDATEXML two or three other elements are detected as changed. I am wondering if I have some sort of DOM fidelity issue here and perhaps my trigger is not the best for detecting this. we use XS:ANY elements in the XML schema and I know that there appears to be space injection into the element tag content and also extraneous namespace tags on tags in the XS:ANY elements.
    Can you give me any advice on my schema XSD and perhaps my trigger. Maybe what I am trying to do is not possible until 10g version of XMLDB.
    XSD
    ====
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- edited with XMLSpy v2005 U (http://www.xmlspy.com) by Martyn J Ricks (University of Tasmania) -->
    <!-- edited with XMLSPY v2004 rel. 4 U (http://www.xmlspy.com) by Grant John Hyland (University of Tasmania) -->
    <xs:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns="http://www.utas.edu.au/cu" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.utas.edu.au/cu" elementFormDefault="qualified" attributeFormDefault="unqualified" xdb:storeVarrayAsTable="true">
         <xs:element name="UnitSetYear" type="UnitSetYearType" xdb:defaultTable="CU_UNIT_SET_YEARS_XML">
              <xs:annotation>
                   <xs:documentation>Comment describing your root element</xs:documentation>
              </xs:annotation>
         </xs:element>
         <xs:complexType name="OfferedInCoursesType" xdb:SQLType="CU_UN_OFFEREDINCRSS_TYP">
              <xs:sequence>
                   <xs:element name="Course" minOccurs="0" maxOccurs="unbounded" xdb:SQLName="OFFERED_IN_COURSE" xdb:SQLType="VARCHAR2" xdb:SQLCollType="CU_UN_OFFERED_IN_CRS_COLTYP">
                        <xs:annotation>
                             <xs:documentation>Unit set is involved in these courses, as specified in the quality assurance manual.</xs:documentation>
                        </xs:annotation>
                        <xs:simpleType>
                             <xs:restriction base="xs:string">
                                  <xs:length value="3"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:element>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="RecommendedTextType" mixed="true" xdb:SQLType="CU_UN_RECOMMENDEDTEXT_TYP">
              <xs:sequence>
                   <xs:any namespace="##any" processContents="skip" maxOccurs="unbounded" xdb:SQLType="VARCHAR2"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="RecommendedTextsType" xdb:SQLType="CU_UN_RECOMMENDEDTEXTS_TYP">
              <xs:sequence>
                   <xs:element name="RecommendedText" type="RecommendedTextType" minOccurs="0" maxOccurs="unbounded" xdb:SQLCollType="CU_UN_RECOMMEND_TEXT_COLTYP" xdb:SQLName="RECOMMENDED_TEXT"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="RequiredTextType" mixed="true" xdb:SQLType="CU_UN_REQUIREDTEXT_TYP">
              <xs:sequence>
                   <xs:any namespace="##any" processContents="skip" maxOccurs="unbounded" xdb:SQLType="VARCHAR2"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="RequiredTextsType" xdb:SQLType="CU_UN_REQUIREDTEXTS_TYP">
              <xs:sequence>
                   <xs:element name="RequiredText" type="RequiredTextType" minOccurs="0" maxOccurs="unbounded" xdb:SQLName="REQUIRED_TEXT" xdb:SQLCollType="CU_UN_REQUIRED_TEXT_COLTYP">
                        <xs:annotation>
                             <xs:documentation>Prescribed texts</xs:documentation>
                        </xs:annotation>
                   </xs:element>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="BAMajorsType" xdb:SQLType="CU_UN_BAMAJORS_TYP">
              <xs:sequence>
                   <xs:element name="BAMajor" maxOccurs="unbounded" xdb:SQLName="BA_MAJOR" xdb:SQLType="VARCHAR2" xdb:SQLCollType="CU_UN_BA_MAJORS_COLTYP">
                        <xs:annotation>
                             <xs:documentation>Majors that this unit applies to in the BA degree course</xs:documentation>
                        </xs:annotation>
                        <xs:simpleType>
                             <xs:restriction base="xs:string">
                                  <xs:maxLength value="20"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:element>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="AssessType" mixed="true" xdb:SQLType="CU_UN_ASSESS_TYPE">
              <xs:sequence>
                   <xs:any namespace="##any" processContents="skip" maxOccurs="unbounded"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="ReqTextType" mixed="true" xdb:SQLType="CU_UN_REQTEXT_TYP">
              <xs:sequence>
                   <xs:any namespace="##any" processContents="skip" maxOccurs="unbounded"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="RequisiteType" xdb:SQLType="CU_UN_REQUISITE_TYP">
              <xs:sequence>
                   <xs:element name="ReqType" xdb:SQLName="REQUISITE_TYPE" xdb:SQLType="VARCHAR2">
                        <xs:simpleType>
                             <xs:restriction base="xs:string">
                                  <xs:maxLength value="6"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:element>
                   <xs:element name="ReqText" type="ReqTextType" xdb:SQLName="REQUISITE_TEXT"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="RequisitesType" xdb:SQLType="CU_UN_REQUISITES_TYP">
              <xs:sequence>
                   <xs:element name="Requisite" type="RequisiteType" minOccurs="0" maxOccurs="unbounded" xdb:SQLName="REQUISITE" xdb:SQLCollType="CU_UN_REQUISITE_COLTYP"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="TeachPatternType" mixed="true" xdb:SQLType="CU_UN_TEACHPATTERN_TYP">
              <xs:sequence>
                   <xs:any namespace="##any" processContents="skip" maxOccurs="unbounded" xdb:SQLType="VARCHAR2"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="DescType" mixed="true" xdb:SQLType="CU_UN_DESC_TYP">
              <xs:sequence>
                   <xs:any namespace="##any" processContents="skip" maxOccurs="unbounded"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="SpecialNoteType" mixed="true" xdb:SQLType="CU_UN_SPECIALNOTE_TYP">
              <xs:sequence>
                   <xs:any namespace="##any" processContents="skip" maxOccurs="unbounded"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="UnitSetYearType" xdb:SQLType="CU_UN_UNITSETYEAR_TYP">
              <xs:sequence>
                   <xs:element name="UnitSetID" xdb:SQLName="UNITSET_ID">
                        <xs:simpleType>
                             <xs:restriction base="xs:integer">
                                  <xs:minInclusive value="10000000"/>
                                  <xs:totalDigits value="8"/>
                                  <xs:fractionDigits value="0"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:element>
                   <xs:element name="Year" xdb:SQLName="YEAR">
                        <xs:annotation>
                             <xs:documentation>The academic year of the unit set</xs:documentation>
                        </xs:annotation>
                        <xs:simpleType>
                             <xs:restriction base="xs:integer">
                                  <xs:totalDigits value="4"/>
                                  <xs:fractionDigits value="0"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:element>
                   <xs:element name="UnitSetLabel" xdb:SQLName="SET_LABEL" xdb:SQLType="VARCHAR2">
                        <xs:annotation>
                             <xs:documentation>The label that will be used as terms of reference for the unit set</xs:documentation>
                        </xs:annotation>
                        <xs:simpleType>
                             <xs:restriction base="xs:string">
                                  <xs:maxLength value="20"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:element>
                   <xs:element name="UnitSetTitle" xdb:SQLName="UNIT_TITLE" xdb:SQLType="VARCHAR2">
                        <xs:annotation>
                             <xs:documentation>The Unit Set Title for the Year</xs:documentation>
                        </xs:annotation>
                        <xs:simpleType>
                             <xs:restriction base="xs:string">
                                  <xs:maxLength value="100"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:element>
                   <xs:element name="Offered" xdb:SQLName="OFFERED" xdb:SQLType="VARCHAR2">
                        <xs:annotation>
                             <xs:documentation>Is the unit on offer this year (Y/N). Defaults to Y.</xs:documentation>
                        </xs:annotation>
                        <xs:simpleType>
                             <xs:restriction base="xs:string">
                                  <xs:length value="1"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:element>
                   <xs:element name="SpecialNote" type="SpecialNoteType" xdb:SQLName="SPECIAL_NOTE"/>
                   <xs:element name="InWeb" xdb:SQLName="IN_WEB" xdb:SQLType="VARCHAR2">
                        <xs:annotation>
                             <xs:documentation>Should this Unit Set appear on the web.</xs:documentation>
                        </xs:annotation>
                        <xs:simpleType>
                             <xs:restriction base="xs:string">
                                  <xs:length value="1"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:element>
                   <xs:element name="Desc" type="DescType" xdb:SQLName="DESCRIPTION" xdb:SQLType="CLOB">
                        <xs:annotation>
                             <xs:documentation>Short description of Unit content</xs:documentation>
                        </xs:annotation>
                   </xs:element>
                   <xs:element name="Staff" xdb:SQLName="STAFF" xdb:SQLType="VARCHAR2">
                        <xs:annotation>
                             <xs:documentation>Staff teaching this unit.</xs:documentation>
                        </xs:annotation>
                        <xs:simpleType>
                             <xs:restriction base="xs:string">
                                  <xs:maxLength value="500"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:element>
                   <xs:element name="TeachPattern" type="TeachPatternType" xdb:SQLName="TEACHING_PATTERN">
                        <xs:annotation>
                             <xs:documentation>Number of lectures , tutorials, laboratories and workshops</xs:documentation>
                        </xs:annotation>
                   </xs:element>
                   <xs:element name="Requisites" type="RequisitesType" xdb:SQLName="REQUISITES"/>
                   <xs:element name="Assess" type="AssessType" xdb:SQLName="ASSESSMENT">
                        <xs:annotation>
                             <xs:documentation>Mode of assessment and percentages</xs:documentation>
                        </xs:annotation>
                   </xs:element>
                   <xs:element name="BAMajors" type="BAMajorsType" minOccurs="0" xdb:SQLName="BA_MAJORS"/>
                   <xs:element name="RequiredTexts" type="RequiredTextsType" xdb:SQLName="REQUIRED_TEXTS"/>
                   <xs:element name="RecommendedTexts" type="RecommendedTextsType" xdb:SQLName="RECOMMENDED_TEXTS"/>
                   <xs:element name="OfferedInCourses" type="OfferedInCoursesType" xdb:SQLName="OFFERED_IN_COURSES"/>
              </xs:sequence>
         </xs:complexType>
    </xs:schema>
    Trigger
    ========
    CREATE OR REPLACE TRIGGER CU_UNITSETYR_XML_AUDR_TRG
    AFTER DELETE OR UPDATE
    ON CU_UNIT_SET_YEARS_XML
    FOR EACH ROW
    DECLARE
    v_user VARCHAR2(30);
    v_old_xml_doc xmltype;
    v_new_xml_doc xmltype;
    v_old_unitset_id cu_unit_sets.unitset_id%TYPE;
    v_old_offered VARCHAR2(1);
    v_new_offered VARCHAR2(1);
    v_old_inweb VARCHAR2(1);
    v_new_inweb VARCHAR2(1);
    v_old_title VARCHAR2(100);
    v_new_title VARCHAR2(100);
    v_old_staff VARCHAR2(500);
    v_new_staff VARCHAR2(500);
    v_old_special_note xmltype;
    v_new_special_note xmltype;
    v_old_unit_desc xmltype;
    v_new_unit_desc xmltype;
    v_old_teach_pattern xmltype;
    v_new_teach_pattern xmltype;
    v_old_assess xmltype;
    v_new_assess xmltype;
    v_old_offered_in_courses xmltype;
    v_new_offered_in_courses xmltype;
    v_old_BA_Majors xmltype;
    v_new_BA_Majors xmltype;
    v_old_req_texts xmltype;
    v_new_req_texts xmltype;
    v_old_reco_texts xmltype;
    v_new_reco_texts xmltype;
    v_old_year INTEGER;
    v_mod_type VARCHAR2(1);
    BEGIN
    -- Establish the username from the CUM_PORTAL_APP context
    v_user := sys_context('CUM_PORTAL_APP','CURRENT_USER');
    IF (v_user IS NULL) THEN
    -- Means that CUM Portal App did not make the change
    v_user := USER;
    END IF;
    -- Determine modification type
    IF (updating) THEN
    v_mod_type := 'U';
    ELSIF (deleting) THEN
    v_mod_type := 'D';
    END IF;
    v_old_xml_doc := :OLD.sys_nc_rowinfo$;
    v_new_xml_doc := :NEW.sys_nc_rowinfo$;
    SELECT extractvalue(v_old_xml_doc, '/UnitSetYear/UnitSetID'),
    extractvalue(v_old_xml_doc, '/UnitSetYear/Year'),
    extractvalue(v_old_xml_doc, '/UnitSetYear/Offered'),
    extractvalue(v_new_xml_doc, '/UnitSetYear/Offered'),
    extractvalue(v_old_xml_doc, '/UnitSetYear/UnitSetTitle'),
    extractvalue(v_new_xml_doc, '/UnitSetYear/UnitSetTitle'),
    extract(v_old_xml_doc, '/UnitSetYear/SpecialNote'),
    extract(v_new_xml_doc, '/UnitSetYear/SpecialNote'),
    extract(v_old_xml_doc, '/UnitSetYear/Desc'),
    extract(v_new_xml_doc, '/UnitSetYear/Desc'),
    extractvalue(v_old_xml_doc, '/UnitSetYear/Staff'),
    extractvalue(v_new_xml_doc, '/UnitSetYear/Staff'),
    extractvalue(v_old_xml_doc, '/UnitSetYear/InWeb'),
    extractvalue(v_new_xml_doc, '/UnitSetYear/InWeb'),
    extract(v_old_xml_doc, '/UnitSetYear/TeachPattern'),
    extract(v_new_xml_doc, '/UnitSetYear/TeachPattern'),
    extract(v_old_xml_doc, '/UnitSetYear/Assess'),
    extract(v_new_xml_doc, '/UnitSetYear/Assess'),
    extract(v_old_xml_doc, '/UnitSetYear/OfferedInCourses'),
    extract(v_new_xml_doc, '/UnitSetYear/OfferedInCourses'),
    extract(v_old_xml_doc, '/UnitSetYear/BAMajors'),
    extract(v_new_xml_doc, '/UnitSetYear/BAMajors'),
    extract(v_old_xml_doc, '/UnitSetYear/RequiredTexts'),
    extract(v_new_xml_doc, '/UnitSetYear/RequiredTexts'),
    extract(v_old_xml_doc, '/UnitSetYear/RecommendedTexts'),
    extract(v_new_xml_doc, '/UnitSetYear/RecommendedTexts')
    INTO v_old_unitset_id,
    v_old_year,
    v_old_offered,
    v_new_offered,
    v_old_title,
    v_new_title,
    v_old_special_note,
    v_new_special_note,
    v_old_unit_desc,
    v_new_unit_desc,
    v_old_staff,
    v_new_staff,
    v_old_inweb,
    v_new_inweb,
    v_old_teach_pattern,
    v_new_teach_pattern,
    v_old_assess,
    v_new_assess,
    v_old_offered_in_courses,
    v_new_offered_in_courses,
    v_old_BA_Majors,
    v_new_BA_Majors,
    v_old_req_texts,
    v_new_req_texts,
    v_old_reco_texts,
    v_new_reco_texts
    FROM dual;
    IF (v_old_unitset_id IS NOT NULL AND v_old_year IS NOT NULL) THEN
    -- Had to do this to avoid problems with create resource statement which on insert appears
    -- to manifest itself as an update of a null document????
    IF (updating OR deleting) THEN
    -- Audit the XML document
    INSERT INTO cu_unit_set_years_xml_audit
    (unitset_id, YEAR, xml_doc, mod_type, mod_by, mod_date)
    VALUES
    (v_old_unitset_id,
    v_old_year,
    v_old_xml_doc.getclobval(), -- convert to clob
    v_mod_type,
    USER,
    SYSDATE);
    END IF;
    IF (updating AND v_old_offered != v_new_offered) THEN
    cu_events_pkg.log_event(p_event_type => 'USOFF',
    p_enacted_by => v_user,
    p_subject_type => 'UNITSETX',
    p_subject_id => to_char(v_old_unitset_id),
    p_subject_year => v_old_year,
    p_previous_values =>
    xmltype('<RowSet>
    <Row>
    <Col ColName="Offered">'||v_old_offered||'</Col>
    </Row>
    </RowSet>'));
    END IF;
    IF (updating AND v_old_inweb != v_new_inweb) THEN
    cu_events_pkg.log_event(p_event_type => 'USINWEB',
    p_enacted_by => v_user,
    p_subject_type => 'UNITSETX',
    p_subject_id => to_char(v_old_unitset_id),
    p_subject_year => v_old_year,
    p_previous_values =>
    xmltype('<RowSet>
    <Row>
    <Col ColName="Publish on Web">'||v_old_inweb||'</Col>
    </Row>
    </RowSet>'));
    END IF;
    IF (updating AND v_old_title != v_new_title) THEN
    cu_events_pkg.log_event(p_event_type => 'USTIT',
    p_enacted_by => v_user,
    p_subject_type => 'UNITSETX',
    p_subject_id => to_char(v_old_unitset_id),
    p_subject_year => v_old_year,
    p_previous_values =>
    xmltype('<RowSet>
    <Row>
    <Col ColName="UnitSet Title">'||v_old_title||'</Col>
    </Row>
    </RowSet>'));
    END IF;
    IF (updating AND v_old_special_note.getClobVal() != v_new_special_note.getClobVal()) THEN
    cu_events_pkg.log_event(p_event_type => 'USSPECN',
    p_enacted_by => v_user,
    p_subject_type => 'UNITSETX',
    p_subject_id => to_char(v_old_unitset_id),
    p_subject_year => v_old_year,
    p_previous_values =>
    xmltype('<RowSet>
    <Row>
    <Col ColName="Special Note">'||NVL(v_old_special_note.getStringVal(),'NULL')||'</Col>
    </Row>
    </RowSet>'));
    END IF;
    IF (updating AND v_old_unit_desc.getClobVal() != v_new_unit_desc.getClobVal()) THEN
    cu_events_pkg.log_event(p_event_type => 'USDESC',
    p_enacted_by => v_user,
    p_subject_type => 'UNITSETX',
    p_subject_id => to_char(v_old_unitset_id),
    p_subject_year => v_old_year,
    p_previous_values =>
    xmltype('<RowSet>
    <Row>
    <Col ColName="Description">'||NVL(v_old_unit_desc.getClobVal(),'NULL')||'</Col>
    </Row>
    </RowSet>'));
    END IF;
    IF (updating AND v_old_staff != v_new_staff) THEN
    cu_events_pkg.log_event(p_event_type => 'USSTAFF',
    p_enacted_by => v_user,
    p_subject_type => 'UNITSETX',
    p_subject_id => to_char(v_old_unitset_id),
    p_subject_year => v_old_year,
    p_previous_values =>
    xmltype('<RowSet>
    <Row>
    <Col ColName="Staff">'||NVL(v_old_staff,'NULL')||'</Col>
    </Row>
    </RowSet>'));
    END IF;
    IF (updating AND v_old_teach_pattern.getClobVal() != v_new_teach_pattern.getClobVal()) THEN
    cu_events_pkg.log_event(p_event_type => 'USTEACHP',
    p_enacted_by => v_user,
    p_subject_type => 'UNITSETX',
    p_subject_id => to_char(v_old_unitset_id),
    p_subject_year => v_old_year,
    p_previous_values =>
    xmltype('<RowSet>
    <Row>
    <Col ColName="Teaching Pattern">'||NVL(v_old_teach_pattern.getClobVal(),'NULL')||'</Col>
    </Row>
    </RowSet>'));
    END IF;
    IF (updating AND v_old_assess.getClobVal() != v_new_assess.getClobVal()) THEN
    cu_events_pkg.log_event(p_event_type => 'USASSESS',
    p_enacted_by => v_user,
    p_subject_type => 'UNITSETX',
    p_subject_id => to_char(v_old_unitset_id),
    p_subject_year => v_old_year,
    p_previous_values =>
    xmltype('<RowSet>
    <Row>
    <Col ColName="Asessment">'||NVL(v_old_assess.getClobVal(),'NULL')||'</Col>
    </Row>
    </RowSet>'));
    END IF;
    IF (updating AND v_old_offered_in_courses.getStringVal() != v_new_offered_in_courses.getStringVal()) THEN
    cu_events_pkg.log_event(p_event_type => 'USOFFCRS',
    p_enacted_by => v_user,
    p_subject_type => 'UNITSETX',
    p_subject_id => to_char(v_old_unitset_id),
    p_subject_year => v_old_year,
    p_previous_values =>
    xmltype('<RowSet>
    <Row>
    <Col ColName="Offered in Courses">'||NVL(v_old_offered_in_courses.getClobVal(),'NULL')||'</Col>
    </Row>
    </RowSet>'));
    END IF;
    IF (updating AND ((v_old_BA_Majors IS NULL) OR (v_old_BA_Majors.getStringVal() != v_new_BA_Majors.getStringVal()))) THEN
    -- Special Treatment here because the BAMajors tag is optional.
    -- If missing this causes an error with the getClobVal() method.
    IF (v_old_BA_Majors IS NULL) THEN
    cu_events_pkg.log_event(p_event_type => 'USBAMAJ',
    p_enacted_by => v_user,
    p_subject_type => 'UNITSETX',
    p_subject_id => to_char(v_old_unitset_id),
    p_subject_year => v_old_year,
    p_previous_values =>
    xmltype('<RowSet>
    <Row>
    <Col ColName="BAMajors">NULL</Col>
    </Row>
    </RowSet>'));
    ELSE
    cu_events_pkg.log_event(p_event_type => 'USBAMAJ',
    p_enacted_by => v_user,
    p_subject_type => 'UNITSETX',
    p_subject_id => to_char(v_old_unitset_id),
    p_subject_year => v_old_year,
    p_previous_values =>
    xmltype('<RowSet>
    <Row>
    <Col ColName="BAMajors">' || v_old_BA_Majors.getStringVal() ||'</Col>
    </Row>
    </RowSet>'));
    END IF;
    END IF;
    IF (updating AND v_old_req_texts.getClobVal() != v_new_req_texts.getClobVal()) THEN
    cu_events_pkg.log_event(p_event_type => 'USREQTXT',
    p_enacted_by => v_user,
    p_subject_type => 'UNITSETX',
    p_subject_id => to_char(v_old_unitset_id),
    p_subject_year => v_old_year,
    p_previous_values =>
    xmltype('<RowSet>
    <Row>
    <Col ColName="Required Texts">'||NVL(v_old_req_texts.getClobVal(),'NULL')||'</Col>
    </Row>
    </RowSet>'));
    END IF;
    IF (updating AND v_old_reco_texts.getClobVal() != v_new_reco_texts.getClobVal()) THEN
    cu_events_pkg.log_event(p_event_type => 'USRECOTXT',
    p_enacted_by => v_user,
    p_subject_type => 'UNITSETX',
    p_subject_id => to_char(v_old_unitset_id),
    p_subject_year => v_old_year,
    p_previous_values =>
    xmltype('<RowSet>
    <Row>
    <Col ColName="Recommended Texts">'||NVL(v_old_reco_texts.getClobVal(),'NULL')||'</Col>
    </Row>
    </RowSet>'));
    END IF;
    END IF;
    END;

    Be aware that you could also do an ALTER SESSION instead of a ALTER SYSTEM. This would prevent to shutdown the database to make the change, within the session, active.
    M

Maybe you are looking for

  • Sap integration with third party software

    hey all, we are actually trying to integrate sap with EAI( IBM WEBSPERE third party software) and here date needs to flow from EAI - SAP. and we have done that through BAPI and in the EAI we got a message saying that the data base has been created bu

  • Embedding fonts in pdf

    Hi there, this questions sounds a bit lame but it got me puzzled. I have to produce a pdf where the client (without any design skills) can edit some parts of the text without having the font so the pdf must have embedded fonts. When I check the pdf i

  • User exit or functional module for multiple GR of Production order.

    Hi All,        I have done a enhancement in CO11N so that batches can get created in production order  confirmation. Now When I go to MIGO to do GR I have option to enter the nulitple batches against the production order. But what I am looking for is

  • BIOS won't update (Error 1275) on G530 (MT 4446)

    G530 (MT 4446) with BIOS v. 1.09 and a fresh installation of Windows 7 Professional 64-bit. I want to update my BIOS to v. 1.10 in accordance with: http://support.lenovo.com/us/en/products/laptops-and-netbooks/lenovo-g-series-laptops/lenovo-g530/down

  • Say in selection screeen (ie is in select-options) i have selected record r

    say in selection screeen (ie is in select-options) i have selected record range from 1000 to 2000 but in the final display list i sholud not get 1200 to 1300 records it should be hide how is it posible Thanks Basu