Comparing data in different resultsets

Hi everybody!
I am working on an web application involving some EAI, as a requirement i need to compare data from two different sources (databases to be precise) and fill a XML based on certain rules. I wish to know if there is a way to compare two ResultSet objects (with almost similar data) directly, or the only way to do is compare each value seperately.
Also please suggest from efficiency point of view if its viable to store data from resultSet to a certain struc kind of object and then comparing, as it would involve lots of overhead compared to directly comparing the two resultsets.
TIA
Abhishek

i have to compare various columns of each row and assign flags in output xml as to note if data is inconsistant, though i am taking measures so as to get the rows in the same order in both result sets, but the primary purpose of this comparison is indeed to check data integrity between both the sources.

Similar Messages

  • Compare date from snapshot tables

    I have mothly snapshot tables in oracle database 10gR2 that I loaded in discoverer 10gR2 as it as business users want to query monthly data. Fine.
    Now business users want to compare two months data something like:
    'snap_date jan-2009' 'site_id for jan-2009' 'site_status for jan-2009' 'snap_date feb-2009' 'site_id for feb-2009' 'site_status for feb-2009'
    01/31/2009 a0001P active 02/28/2009 a0001P inactive
    01/31/2009 b0001P active 02/28/2009 deleted -
    01/31/2009 c0001L active 02/28/2009 c0001L active
    01/31/2009 - - 02/28/2009 z0001P active
    They want to see it like:
    'site_id' 'site_status for jan-2009' 'site_status for feb-2009'
    a0001P active inactive
    b0001P active site deleted
    c0001L active active
    z0001P no site found active
    Please suggest, how can I achieve this in discoverer?
    Two snap_dates can be any dates from last five years on which already snap_shot has been taken and added to the snapshot table.
    Thanks.
    Edited by: vkumar on Mar 17, 2009 2:17 PM

    Hi Rod,
    Actually this is just one table having snapshot data for different months like:
    'snap_date'              'site_id'               'site_status'
    01/31/2009           a0001P           active
    01/31/2009           b0001P           active
    01/31/2009           c0001L           active
    02/28/2009           a0001P           inactive
    02/28/2009           c0001L           active
    02/28/2009           z0001P           active
    From this table I want to compare data for different dates with respect to site_id?
    Thanks.
    Edited by: vkumar on Mar 19, 2009 10:44 AM
    Edited by: vkumar on Mar 19, 2009 10:44 AM

  • Best way to compare data of 2 tables present on 2 different servers

    Hi,
    We are doing data migration and I wil like to compare data between 2 tables which are present on 2 different server. I know to find the difference i can go for minus or full outer join and by creating the database link.
    But my problem is the volume of the data. The tables under consideration has approximately 40-60 columns and number of rows in each tables are around 60-70 million. Also both the tables are on 2 diffferent servers.
    I would like to know
    1] What will be the best way to compare the data and print the difference from performance perepective? I know that if I am going for DB links then its will definitely impact the performance as the tables are across 2 different servers.
    2] Is it advisable to go for using SQL - PL/SQL for this kind of senario or dump the data in flat files and use C or C++ code to find the difference.
    Regards,
    Amol

    Check this at asktom.oracle.com. Search for "Marco Stefanetti" and follow the few posts between Marco and Tom. As far as your tables being on separate servers, you could consider dumping the data to file and using external table or using CTAS ( create table as select ) to get both tables locally.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2151582681236

  • How to compare data from 2 different time periods

    Hi folks,
    I have a question on approach to a problem. I want to be able to compare data from a common db, but for 2 different time periods. For example I want to see the number of occurences of an instance in my data for today and compare it against occurences a week ago today. What's the best approach for this kind of problem? Is this done with 2 separate queries from 2 sub reports and then compared some how? Any comments on this approach or an other are appreciated.
    TIA bvd

    Follow these steps:
    1) Bring your first time period in your main report.  This will be your first query.
    2) Bring your second time period in a subreport.  This will be your second query.
    3) Bring the values from your subreport into your main report using shared variables.
    4) Lastly, compare the results using formulas in your main report.
    I hope this information proves useful.
    Regards,
    Zack H.

  • Comparing data from two tables

    My PL/SQL is very limited, however, I need to write some code that compares data stored in two different Oracle tables and then writes the differences to a third table. Both tables have primary keys that I will use to ensure I am comparing like for like. These tables could be large.
    Any help on the best way to do this, or any code examples would be very appreciated.

    One fairly efficient way of doing this is with set operators. The following code is untested - but looks right ;). It also assumes you want to know the provenance of the rows; if not, just zap the literal from each SELECT statement.
    INSERT INTO diff_tab SELECT * FROM
      ( (SELECT 'tab1nottab2' AS provenance, t1.col1, t1.col2 FROM tab1 t1
         MINUS
         SELECT 'tab1nottab2', t2.col_a, t2.col_b FROM tab2 t2)
         UNION ALL
         (SELECT 'tab2nottab1', t2.col_a, t2.col_b FROM tab2 t2
          MINUS
          SELECT 'tab2nottab1', t1.col1, t1.col2 FROM tab1 t1)
    /Cheers, APC

  • How to compare dates using javascript?

    Hi,
    I have to compare dates using javascript. The dates are in format "mm/dd/yy" for eg "10/09/06".
    I have written a script to compare the dates but the problem I 'm facing is with the year.
    For example if I compare "10/09/06" with "10/04/98", then "10/04/98" is coming out to be greater than "10/09/06" because it is considering year "98" to be greater than "06".
    Please advice/suggest.
    Thanks in advance...

    Dude, you're here in a Java forum, not in a Javascript forum. Those are two entirely different languages.
    The answer in Java is to use java.text.SimpleDateFormat to convert String to Date and use java.util.Date and/or java.util.Calendar to compare dates.

  • Problem with Comparing Dates in MS Access

    Hai Friends
    I am using MS ACCESS 2000 Database
    I am using the following sqlString in AWT Frame class to fetch the date from MS ACcess Database
    I heard that while comparing with >= or <= we need to include # symbol between the date.
    I was tried by using #. But i am not able to get the results.
    please see the sql query and give me the solution.
    Thanksinadvance
    Yours
    Rajesh
    if(Enddate.getText().trim().equals(""))
    sqlString = "select * from data_comm_err where log_date >= '" + Startdate.getText() + "'";
    if(Startdate.getText().trim().equals(""))
    sqlString = "select * from data_comm_err where log_date <= '" + Enddate.getText() + "'";
    }

    non-proprietary query(portable):
    PreparedStatement ps = con.prepareStatement("select * from data_comm_err where log_date <= ? ");
    ps.setDate(1,new java.sql.Date(Startdate.getTime()));
    ResultSet r  = ps.executeQuery();
    ....note: for clarity and good programming style, don't capitalize the first letter of a variable(Startdate)
    Jamie

  • Compare date in SQL statement

    yup.. how can i compare date in SQL statement??
    pls give me a completed example.

    I'd think this is a formatting problem. Why not try:
    PreparedStatement ps = myConnection.prepareStatement(
    "SELECT * FROM Receipt WHERE to_date(Date) > ? ");
    ps.setDate(1,TodayDate);
    ResultSet rs = ps.executeQuery();
    HTH,
    Ken

  • Date format in Resultset

    Hi ,
    I have a resultset which fetches data from different tables. The tables include
    columns incolving DATE format. The resultset fetches the date column in the
    MM-DD-YYYY HH:MM:SS format. But I need the Date format should be in the
    DD-MM-YYYY format.
    The problem is the column of Date format is unknown. Is there any way to set this format for the Resultset or at the time of Connection.
    Thanks,
    Arun

    I'm not really sure what you mean, but you can change the date format in sql level:
    select to_char(sysdate,'DD-MM-YYYY') from dual
    or a better approach is to convert the java.sql.Date in Java.
    http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Date.html

  • Function module for comparing dates and times

    Hi,
    I have a date and time stamp in one filed for example as below:
    20070125183045
    (the first 8 are date in YYYYMMDD format, the next 6 is time in HHMMSS format). Now I want to compare this value to another such value in terms of date and time. First I want to compare dates and then times. Do you know any function module that can serve this purpose?
    Thanks very much!

    You can compare these using the function module DURATION_DETERMINE.  This fuction will give you the difference, and it can be in a view different units, such as the difference in days, months, etc.
    Funciton module takes in Start date and time and end date and time.
    Regards,
    RIch HEilman

  • How to compare Date/time string

    I read from datalog file including Date/time string ,and want to query the special Date/time string span ,how to compare the data/time string ?

    Hello Joshua,
    To compare date/time you have to extract the different components (day, month, year, hour, minute, second) anyway. Why not "convert to seconds"? I think it's easier to compare one number (where you also can do other math, like calc the difference and so on) than to compare seven (?) parameters with some exceptions... If the dates are read from excel (there was a similar thread some days ago), why not convert to seconds in excel (just a format change)?
    Best regards,
    GerdW
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • To compare Table in different Database

    Hi
    Is possible to compare tables in Different Database ?
    They are same tables , but data can to be different
    TIA

    May be you can try with DBMS_RECTIFIER_DIFF.DIFFERENCES

  • Compare date

    hi all, the below code has one error in compare date : today >= expiredate. In this program, i want to compare if today is greater than expiredate, then status = overdue write to table named totalday. thanks
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
               Connection con = DriverManager.getConnection("jdbc:odbc:booking");
            PreparedStatement ps1 = con.prepareStatement("select date from totalpay");
            PreparedStatement ps2 = con.prepareStatement("update totalpay set status = 'overdue'");
            GregorianCalendar calendar= new GregorianCalenda();
               SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
               String today = df.format(calendar.getTime());
               calendar.add(Calendar.DATE, 30);
               String expiredate = df.format(calendar.getTime());
               ResultSet rs = ps1.executeQuery();
               while (rs.next()){
    //int today1 = Integer.parseInt(today);
    //int expiredate1 = Integer.parseInt(expiredate);
                   if (today >= expiredate)
              ps2.setString(3,status);
                    ps2.executeUpdate();
                   rs.close();
                   ps1.close();
                   ps2.close();
                   con.close();
    [\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Thanks for your reply. it got no error, but the code changed status to 'overdue' at all fields of status include the date '30/04/2004. is the code something wrong??Thanks
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
               Connection con = DriverManager.getConnection("jdbc:odbc:booking");
            PreparedStatement ps1 = con.prepareStatement("select date from totalpay");
            PreparedStatement ps2 = con.prepareStatement("update totalpay set status = 'overdue'");
            // milliseconds in a day.
            final long DAY = 24L * 60 * 60 * 1000;
            // date format of the SQL field.
            final SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
            // today as a date.
            final long today = System.currentTimeMillis() / DAY;
            // assuming the expiry is 30 days from today.
            final long expiryDay = today + 30;
                    final ResultSet rs = ps1.executeQuery();
                    while (rs.next()) {
                final String recDateString = rs.getString("date");
                final long recDate = df.parse(recDateString).getTime() / DAY;
                if (recDate >= expiryDay)
                    ps2.setString(3, status);
                ps2.executeUpdate();
                   rs.close();
                   ps1.close();
                   ps2.close();
                   con.close();
                JOptionPane.showMessageDialog(this,"Status updated.");
                   MainMenu mm = new MainMenu();
                    this.setVisible(false);  //close frame
                    mm.setVisible(true);
    [\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to read data with different XML schemas within the single connection?

    I have Oracle 11g database
    I access it through jdbc:oracle:thin, version 11.2.0.3, same as xdb.
    I have several tables, each has one XMLType column, all schema-based.
    There are three different XML schemata registered in the DB
    I may need to read the XML data from several tables.
    If all the XMLTypes have the same XML schema ,there is no problem,
    If the schemata are different, the second read throws BindXMLException.
    If I reset the connection between the reads of the XMLType column with different schemata, it works.
    The question is: how can I configure the driver, or the connection to be able to read the data with different XML schemata without resetting the connection (which is expensive).
    The code to get the XMLType data is textbook implementation:
    1   ResultSet resultSet = statement.executeQuery( sql ) ;
    2   String result = null ;
    3    while(resultSet.next()) {
    4   SQLXML sqlxml = resultSet.getSQLXML(1) ;
    5   result = sqlxml.getString() ;
    6   sqlxml.free();
    7   }
    8   resultSet.close();
    9    return result ;

    It turns out, that I needed to serialize the XML on the server and read it as Blob. Like this:
    1    final Statement statement = connection.createStatement() ;
    2    final String sql = String.format("select xmlserialize(content xml_content_column as blob encoding 'UTF-8') from %s where key='%s'", table, key ) ;
    3   ResultSet resultSet = statement.executeQuery( sql ) ;
    4   String result = null ;
    5    while(resultSet.next()) {
    6   Blob blob = resultSet.getBlob( 1 );
    7   InputStream inputStream = blob.getBinaryStream();
    8   result = new Scanner( inputStream ).useDelimiter( "\\A" ).next();
    9   inputStream.close();
    10   blob.free();
    11   }
    12   resultSet.close();
    13   statement.close();
    14
    15   System.out.println( result );
    16    return result ;
    17
    Then it works. Still, can't get it work with XMLType in resultset.On the client unwrapping XML blows up when trying to switch to different XML schema. JDBC/XDB problem?

  • [BPC 7.5] or [BPC 10] Validate data from different periods

    Hi,
    is it possible to use the standard validation business rule to validate data in different periods? I need a rule that validates the total in my flow dimension from last year end to the value in the opening flow in the current period. Is that possible?
    Thanks,
    Arnold

    Hi Arnold,
    I do not think this is possible. You can only compare accounts and flows in the detailed rules. In the Header rules you can specify specific dimensions and time periods.
    You can maybe use script logic to write data to the current month into a validation test account from the last year into the current period and then run the validation rules.
    Thanks,
    John

Maybe you are looking for