Comparing 2 result sets

Hello
I have to compare 2 result sets and determine if they are the same.
The queries are:
SELECT CARRIER_ID,ROUTE_POSITION
FROM ROUTE_WG_PHASE4
SELECT CARRIER_ID,ROUTE_POSITION
FROM ROUTE_WG_PHASE3
I tried using minus but it does not work when the first result set has less records than the second.
Oracle 10g
Thanks

I tend to go with Tom's suggestion in the "Comparing the Contents of Two Tables" section of http://www.oracle.com/technology/oramag/oracle/05-jan/o15asktom.html. It has the advantage of showing up missing duplicate rows (eg. where one table has 2 identical rows but the other has only 1).
In your case, using Tom's method would give you a query of:
SELECT carrier_id, route_position, COUNT(src1) count1, COUNT(src2) count2
FROM   (SELECT a.*, 1 src1, TO_NUMBER(NULL) src2
        FROM   route_wg_phase4 a
        UNION ALL
        SELECT b.*, TO_NUMBER(NULL) src1, 2 src2
        FROM   route_wg_phase3 b)
GROUP BY carrier_id, route_position
HAVING COUNT(src1) <> COUNT(src2);

Similar Messages

  • Compare 2 result sets

    Hi,
    I have two queries which count the number of lines of the tables
    of the same schema in two databases .
    How can I compare the two result set.
    Thanks in advance

    Are you looking for something like this :
    Suppose First resultset is like this :
    SQL> select * from tab1;
    TABLE_NAME                          COUNT
    SALGRADE                                5
    PROD                                   32
    EMP                                    14
    DEPT                                    4
    CUST                                    7
    BONUS                                   0
    TEST                                   10
    7 rows selected.
    and Second resultset like this :
    SQL> select * from tab2;
    TABLE_NAME      COUNT
    TAB_NEW            20
    SALGRADE            5
    EMP                14
    DEPT                6
    Now Comparision :
    select a.table_name,
    a.count,
    b.table_name,
    b.count
    from tab1 a
    full join tab2 b
    on a.table_name=b.table_name
    WHERE A.COUNT <> B.COUNT
    OR A.TABLE_NAME IS NULL
    OR B.TABLE_NAME IS NULL
    TABLE_NAME                          COUNT TABLE_NAME      COUNT
    PROD                                   32
    DEPT                                    4 DEPT                6
    CUST                                    7
    BONUS                                   0
    TEST                                   10
                                              TAB_NEW            20
    6 rows selected.
    Regards
    Girish Sharma

  • Need help in comparing values to display correct result set

    I have a View Object and Entity I created that point to a View on my database. This view contains a complex custom query that recovers and totals all charges and fees for all properties. However, when this result set is returned I only want to display on the initial screen the Row which contains the information for the current Property selected. However, in trying to implement this I am unsure how to:
    A) Somehow get the Property Id value of the Property currently in the JSP.
    B) Get the value of the Property Id column off each Row to compare to the value obtained in A.
    (I created an exact copy of the RowSetBrowser bean named SRIRowSetBrowser and am trying to add code to control which Rows get sent off to be added to the HTML Table)
    I can not find any documentation or source for the Row class and thus have no way to know if any methods are provided that would help me.
    Any ideas?
    Thanks

    Thats a mistake while modifying the XML.
    The Element is OpenOrder:
    so the XML goes like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <BOOK_PURCHASE_SR xsi:schemaLocation="http://www.mobily.com/blackberry/request request.xsd"
    xmlns="http://www.mobily.com/blackberry/request"
    xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance">
    <SR_HEADER>
    <Name>Java</Name>
    <Book>0000</Book>
    <Price>100</Price>
    <Purchase>Y</Purchase>
    <PurchaseDate>20070902153930</PurchaseDate>
    <Requestorname>Rashmi</Requestorname>
    <RequestorLanguage>E</RequestorLanguage>
    <OpenOrder>N</OpenOrder>
    <Chargeable>Y</Chargeable>
    <ChargeAmount>99</ChargeAmount>
    </SR_HEADER>
    <PhoneNumber>1234567890</PhoneNumber>
    <Service>shop</Service>
    <Operation>purchase</Operation>
    <CustomerType>2</CustomerType>
    </BOOK_PURCHASE_SR>

  • Newbie: compare 2 result sets in procedure

    I have two queries. One selects 5 values (all number datatypes), the second query selects 2 values (both number datatypes).
    If a value from query 2 exists in the resultset of query 1 - go make table updates using the second value in the select statment of query 2. If there is not a match, update a table with values from query 1.
    Currently, I have two cursor for loops, which are nested. This works but of course is horribly slow. What is a better way to process this data?
    The number of rows varies between the two resultsets.
    Oracle 11.2.0.3.2

    Query one sample resultset (normally approximately 25K rows returned):
    1701553486214000     104574     6200     9888     55
    1701553486102000     104573     6445     9817     54
    1701553486046000     104572     6072     10740     46
    1701553485230000     104567     5800     10811     47
    1701553485153000     104566     6475     10172     42
    1701553485055000     104565     5873     10882     48
    1701553485033000     104564     6420     9462     49
    1701553484067000     104559     6008     10030     41
    Query two sample result set (this resultset will always be a sub-set of query one - based on the second column value)
    104566     1701524076315000
    23321     1701524076315000
    23279     1701524077350000
    23278     1701524077350000
    104574     1701524109347000
    23320     1701524109347000
    23317     1701524113720000
    23318     1701524113720000
    23287     1701524118000000
    83219     1701524118000000
    104601     1701524118000000
    23327     1701524118000000
    83059     1701524118000000
    23329     1701524128827000
    if the value of colum 1 (c1) in query 2 (q2) exists in colum 2 (q2) of query 1 (q1)
    then
    update table
    set value = sysdate-c2;
    else
    update table
    set value = sysdate;
    Does that help clarify?

  • Stored function not returning result set unless recompiled

    Hi,
    I have a strange situation going on with a basic Java (1.6.0.17) application talking to an Oracle 11g (11.2.0.1.0) database. Basically what is happening is that sometimes a stored function's return value (a result set) is not making it as far as JDBC/Java, unless I recompile the stored function (with absolutely no changes to the application or function's code). I am always able to successfully see the result set if I call the function directly from within SQL Developer, just not on the Java app/JDBC side.
    I've tried running with 3 different physical Oracle 11g servers and tried running the app on a couple of machines. I'm wondering if this is either some kind of caching issue or perhaps a JDBC bug/misconfiguration.
    Any help would be greatly appreciated. Attached to this message:
    1. stored function code
    2. snippet of Java app code
    3. ODBC trace output when returned a empty result set (ie failure scenario)
    4. ODBC trace out when returned the correct result set (ie success scenario)
    * it's helpful if you compare the texts of 3 & 4 with Vim diff or WinMerge etc.
    ** as they're large I've just extracted the sections that had differences. Leave a message here and I can send you the full ones if necessary.
    1. stored function code
    ===============
    FUNCTION getRecordSet (
    ActionId Number
    RETURN CallingList.ref_cursor
    IS
    myDataCursor CallingList.ref_cursor;
    ActionId_ Number;
    BEGIN
    ActionId_ := ActionId;
    IF isActionExpired(ActionId) <= 0 THEN
    ActionId_ := 0;
    END IF;
    OPEN myDataCursor FOR
    SELECT
    C.ID,
    C.CUSTOMER_ID,
    C.CAMPAIGN_ID,
    c.phone,
    C.TRANSFERDN,
    (SELECT
    TTS_MESSAGE
    FROM CAMPAIGN CMP
    WHERE CMP.CAMPAIGN_ID = C.CAMPAIGN_ID) "TTS"
    FROM
    CALLING_LIST C
    WHERE
    C.ACTION_ID = ActionId_
    AND
    C.CALL_STATUS = 1
    AND
    C.CALLCOUNT > 0
    And rownum <=5;
    RETURN myDataCursor;
    EXCEPTION
    WHEN CURSOR_ALREADY_OPEN THEN
    RETURN NULL;
    WHEN INVALID_CURSOR THEN
    RETURN NULL;
    WHEN NO_DATA_FOUND THEN
    RETURN NULL;
    END getRecordSet;
    ....and the isActionExpired function that is called from within getResultSet is (but for all my testing it's been returning 1 with no problems)
    FUNCTION isActionExpired (
    ActionId number
    ) RETURN number
    AS
    Today varchar2(12);
    myCount number(6);
    BEGIN
    myCount := 0;
    today := to_char(sysdate, 'dd.mm.yyyy');
    SELECT
    count(*)
    INTO
    myCount
    FROM
    ACTION A
    where
    ACTION_ID = ActionId
    AND
    SYSDATE BETWEEN ACTION_STARTDATETIME
    AND
    ACTION_STOPDATETIME
    and
    SYSDATE BETWEEN to_date(today || ' ' || A.STARTTIME, 'dd.mm.yyyy HH24:MI:SS') and to_date(today || ' ' || A.ENDTIME, 'dd.mm.yyyy HH24:MI:SS')
    AND
    ACTION_STATUS = 1;
    return myCount;
    END isActionExpired;
    2. snippet of Java app code
    =================
    ... db connect logic...
    javax.management.MBeanServer mbs = null;
    javax.management.ObjectName name = null;
    try {
    String loader = Thread.currentThread().getContextClassLoader().toString().replaceAll("[,=:\"]+", "");
    name = new javax.management.ObjectName("com.oracle.jdbc:type=diagnosability,name="+loader);
    mbs = java.lang.management.ManagementFactory.getPlatformMBeanServer();
    mbs.setAttribute(name, new javax.management.Attribute("LoggingEnabled", true));
    } catch (Exception e) {
    System.out.println("ORACLE TRACE ERROR: " + e.getStackTrace());
    try {
    String query = "begin ? := CALLINGLIST.getRecordSet(?); end;";
    CallableStatement stmt = conn.prepareCall(query);
    stmt.registerOutParameter(1, OracleTypes.CURSOR);
    stmt.setInt(2, actionId);
    stmt.execute();
    ResultSet rs = (ResultSet) stmt.getObject(1); // So, here it works.
    // print the results
    int count=0;
    while (rs.next()) {
    count++;
    stmt.close();
    System.out.println("rs count was: " + count);
    } catch (SQLException e) {
    System.out.println("Exception occurred: " + e.getMessage());
    3. ODBC trace output when returned a empty result set (ie failure scenario)
    ===============================================
    Jul 1, 2010 3:30:47 PM oracle.net.ns.Packet receive
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.net.ns.Packet receive
    TRACE_20: Debug: type=6, length=121, flags=0
    00 79 00 00 06 00 00 00 |.y......|
    00 00 06 22 01 06 00 01 |..."....|
    0A 00 00 00 07 03 C2 04 |........|
    0E 04 C3 5E 22 03 02 C1 |...^"...|
    2A 04 33 30 30 32 03 37 |*.3002.7|
    37 37 05 48 65 6C 6C 6F |77.Hello|
    08 01 06 00 00 01 02 00 |........|
    00 00 00 00 00 04 01 05 |........|
    01 01 02 05 7B 00 00 01 |....{...|
    02 00 03 00 00 00 00 00 |........|
    00 00 00 00 00 00 00 00 |........|
    00 01 01 00 00 00 00 19 |........|
    4F 52 41 2D 30 31 34 30 |ORA-0140|
    33 3A 20 6E 6F 20 64 61 |3:.no.da|
    74 61 20 66 6F 75 6E 64 |ta.found|
    0A |. |
    Jul 1, 2010 3:30:47 PM oracle.net.ns.Packet receive
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 1, [I@1315d34, 20
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 1, 871, [I@1315d34, 20, oracle-character-set-830, oracle-character-set-2000, oracle-character-set-871, false
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 1, [I@1315d34, true, 20
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: return: 4
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: return: 4
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: return: 4
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 211, [I@1de256f, 10
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 211, 871, [I@1de256f, 10, oracle-character-set-830, oracle-character-set-2000, oracle-character-set-871, false
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 211, [I@1de256f, true, 10
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: return: 3
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: return: 3
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: return: 3
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 321, [I@16bd8ea, 2000
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 321, 871, [I@16bd8ea, 2000, oracle-character-set-830, oracle-character-set-2000, oracle-character-set-871, false
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 321, [I@16bd8ea, true, 2000
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: return: 5
    Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: return: 5
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: return: 5
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CConnection updateSessionProperties
    TRACE_16: Enter: [Loracle.jdbc.internal.KeywordValue;@16e1fb1
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CConnection updateSessionProperties
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CStatement fetch
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement checkValidRowsStatus
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement checkValidRowsStatus
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl <init>
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CResultSetAccessor getCursor
    TRACE_16: return: oracle.jdbc.driver.OracleResultSetImpl@e2cb55
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CResultSetAccessor getCursor
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.ResultSetAccessor getObject
    TRACE_16: return: oracle.jdbc.driver.OracleResultSetImpl@e2cb55
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.ResultSetAccessor getObject
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleCallableStatement getObject
    TRACE_1: return: oracle.jdbc.driver.OracleResultSetImpl@e2cb55
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleCallableStatement getObject
    TRACE_1: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleCallableStatementWrapper getObject
    TRACE_30: return: oracle.jdbc.driver.OracleResultSetImpl@e2cb55
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleCallableStatementWrapper getObject
    TRACE_30: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_1: Public Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_20: Debug: closed=false, statement.currentRow=-1, statement.totalRowsVisited=0, statement.maxRows=0, statement.validRows=1, statement.gotLastBatch=true
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_1: return: true
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_1: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_1: Public Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_20: Debug: closed=false, statement.currentRow=0, statement.totalRowsVisited=1, statement.maxRows=0, statement.validRows=1, statement.gotLastBatch=true
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
    TRACE_16: Enter: false
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BaseResultSet close
    TRACE_16: Public Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BaseResultSet close
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection registerHeartbeat
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection registerHeartbeat
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection needLine
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection needLine
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CStatement closeQuery
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CConnection assertLoggedOn
    TRACE_16: Enter: "oracle.jdbc.driver.T4CStatement.closeQuery"
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CConnection assertLoggedOn
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CStatement closeQuery
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement endOfResultSet
    TRACE_16: Enter: false
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement prepareForNewResults
    TRACE_16: Enter: false, false
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement clearWarnings
    TRACE_16: Public Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement clearWarnings
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
    TRACE_16: Enter: true
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
    TRACE_16: return:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement prepareForNewResults
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CStatement clearDefines
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement clearDefines
    TRACE_16: Public Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement freeLine
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement freeLine
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement cleanupDefines
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
    TRACE_16: Enter: [B@8e32e7
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BufferCache put
    TRACE_16: Enter: [B@8e32e7
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BufferCache put
    TRACE_30: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
    TRACE_16: Enter: [C@1b000e7
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BufferCache put
    TRACE_16: Enter: [C@1b000e7
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BufferCache put
    TRACE_30: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement cleanupDefines
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement clearDefines
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CStatement clearDefines
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement endOfResultSet
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
    TRACE_16: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_1: return: false
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_1: Exit
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleCallableStatementWrapper close
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OraclePreparedStatementWrapper close
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatementWrapper close
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement close
    TRACE_1: Public Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement closeOrCache
    TRACE_16: Enter: null
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection isStatementCacheInitialized
    TRACE_16: Enter:
    Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection isStatementCacheInitialized
    4. ODBC trace out when returned the correct result set (ie success scenario)
    ===============================================
    TRACE_16: Enter:
    Jul 1, 2010 3:30:07 PM oracle.net.ns.Packet receive
    TRACE_20: Debug: type=6, length=82, flags=0
    00 52 00 00 06 00 00 00    |.R......|
    00 00 08 01 06 00 00 01    |........|
    02 00 00 00 00 00 00 04    |........|
    01 05 00 02 05 7B 00 00    |.....{..|
    01 02 00 03 00 00 00 00    |........|
    00 00 00 00 00 00 00 00    |........|
    00 00 01 01 00 00 00 00    |........|
    19 4F 52 41 2D 30 31 34    |.ORA-014|
    30 33 3A 20 6E 6F 20 64    |03:.no.d|
    61 74 61 20 66 6F 75 6E    |ata.foun|
    64 0A                      |d.      |
    Jul 1, 2010 3:30:07 PM oracle.net.ns.Packet receive
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CConnection updateSessionProperties
    TRACE_16: Enter: [Loracle.jdbc.internal.KeywordValue;@1fa1bb6
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CConnection updateSessionProperties
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CStatement fetch
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
    TRACE_16: Enter: false
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BaseResultSet close
    TRACE_16: Public Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BaseResultSet close
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection registerHeartbeat
    TRACE_16: Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection registerHeartbeat
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection needLine
    TRACE_16: Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
    TRACE_16: Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection needLine
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CStatement closeQuery
    TRACE_16: Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CConnection assertLoggedOn
    TRACE_16: Enter: "oracle.jdbc.driver.T4CStatement.closeQuery"
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CConnection assertLoggedOn
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CStatement closeQuery
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement endOfResultSet
    TRACE_16: Enter: false
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement prepareForNewResults
    TRACE_16: Enter: false, false
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement clearWarnings
    TRACE_16: Public Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement clearWarnings
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement prepareForNewResults
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CStatement clearDefines
    TRACE_16: Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement clearDefines
    TRACE_16: Public Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement freeLine
    TRACE_16: Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement freeLine
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement cleanupDefines
    TRACE_16: Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
    TRACE_16: Enter: [B@8e32e7
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BufferCache put
    TRACE_16: Enter: [B@8e32e7
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BufferCache put
    TRACE_30: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
    TRACE_16: Enter: [C@1b000e7
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BufferCache put
    TRACE_16: Enter: [C@1b000e7
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BufferCache put
    TRACE_30: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement cleanupDefines
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement clearDefines
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CStatement clearDefines
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement endOfResultSet
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl <init>
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CResultSetAccessor getCursor
    TRACE_16: return: oracle.jdbc.driver.OracleResultSetImpl@1315d34
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CResultSetAccessor getCursor
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.ResultSetAccessor getObject
    TRACE_16: return: oracle.jdbc.driver.OracleResultSetImpl@1315d34
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.ResultSetAccessor getObject
    TRACE_16: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleCallableStatement getObject
    TRACE_1: return: oracle.jdbc.driver.OracleResultSetImpl@1315d34
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleCallableStatement getObject
    TRACE_1: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleCallableStatementWrapper getObject
    TRACE_30: return: oracle.jdbc.driver.OracleResultSetImpl@1315d34
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleCallableStatementWrapper getObject
    TRACE_30: Exit
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_1: Public Enter:
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl next
    TRACE_20: Debug: closed=true, statement.currentRow=-1, statement.totalRowsVisited=0, statement.maxRows=0, statement.validRows=0, statement.gotLastBatch=false
    Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl next
    Edited by: user9376621 on Jul 1, 2010 1:07 AM
    Edited by: user9376621 on Jul 1, 2010 1:13 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         

    Please ignore this, it was a non-issue in the end.

  • Sql statement not showing right result set

    Hi everyone,
    I have a statement :
    select to_date(extract (day from to_date(begin_datum,'yyyy-mm-dd'))||'-'||extract (month from to_date(begin_datum,'yyyy-mm-dd'))||'-'||
    extract(year from sysdate),'dd-mm-yyyy') from fus_medewerkers;
    which returns following result:
    12-FEB-09
    07-DEC-09
    22-NOV-09
    21-MAY-09
    26-FEB-09
    17-DEC-09
    01-SEP-09
    17-DEC-09
    04-APR-09
    07-JUN-09
    23-MAY-09
    29-MAY-09
    13-AUG-09
    18-MAR-09
    01-NOV-09
    12-AUG-09
    06-JAN-09
    01-MAR-09
    02-AUG-09
    16-AUG-09
    06-NOV-09
    23-MAR-09
    06-MAY-09
    01-NOV-09
    01-MAR-09
    16-AUG-09
    01-JAN-09
    01-DEC-09
    01-OCT-09
    01-OCT-09
    01-OCT-09
    01-APR-09
    01-APR-09
    08-DEC-09
    01-APR-09
    01-AUG-09
    14-JUN-09
    02-JUL-09
    01-APR-09
    10-JAN-09
    15-MAR-09
    07-APR-09
    29-JAN-09
    16-JUN-09
    21-OCT-09
    I now put a condition in my original statement as follow:
    select to_date(extract (day from to_date(begin_datum,'yyyy-mm-dd'))||'-'||extract (month from to_date(begin_datum,'yyyy-mm-dd'))||'-'||
    extract(year from sysdate),'dd-mm-yyyy') from fus_medewerkers
    where sysdate <= to_date(extract (day from to_date(begin_datum,'yyyy-mm-dd'))||'-'||extract (month from to_date(begin_datum,'yyyy-mm-dd'))||'-'||
    extract(year from sysdate),'dd-mm-yyyy');
    The result is:
    07-DEC-09
    22-NOV-09
    17-DEC-09
    01-SEP-09
    17-DEC-09
    13-AUG-09
    01-NOV-09
    16-AUG-09
    06-NOV-09
    01-NOV-09
    16-AUG-09
    01-DEC-09
    01-OCT-09
    01-OCT-09
    01-OCT-09
    08-DEC-09
    21-OCT-09
    As you can see the row with sysdate (12-AUG-09 ) in my first result is not shown in the second result set.
    Can someone please tell me why this is so and how I could solve this problem?
    Regards,
    Diana

    sysdate contains time even if it's not shown. e.g. at 14:43:22 on Aug 12th 2009, sysdate would have a value of 12-AUG 2009 14:43:22, but unless you have changed your NLS_DATE_FORMAT setting you would only see the date portion of it.
    When comparing a date value to sysdate you may need to truncate one or both values depending on the results you are looking for.
    e.g.
    the only difference between these two queries is that I truncate sysdate in one of them:
    with t1 as (select 1 id, to_date('12-AUG-2009','dd-mon-yyyy') dt from dual
      union all select 2, to_date('12-AUG-2009 14:23','dd-mon-yyyy hh24:mi') from dual
    select sysdate, t1.* from t1 where sysdate <= dt
    SYSDATE                   ID                     DT                       
    12-AUG-2009 11:38:21      2                      12-AUG-2009 14:23:00     
    1 rows selected
    with t1 as (select 1 id, to_date('12-AUG-2009','dd-mon-yyyy') dt from dual
      union all select 2, to_date('12-AUG-2009 14:23','dd-mon-yyyy hh24:mi') from dual
    select trunc(sysdate), t1.* from t1 where trunc(sysdate) <= dt
    TRUNC(SYSDATE)            ID                     DT                       
    12-AUG-2009 00:00:00      1                      12-AUG-2009 00:00:00     
    12-AUG-2009 00:00:00      2                      12-AUG-2009 14:23:00     
    2 rows selected

  • Doing set operations on Result Sets

    Hi all
    I am trying to make a table synchronization application.As far as specs go, There can be two similar tables in two different databases I will run a query on both the databases which will fetch me two separate resultsets, now I want to try doing set operations on this result sets like union, intersection etc. Is it at all possible? Is there a way to compare two resultsets efficiently? Can I some how tell my two resultsets to get the records which are not the same in both?

    Not efficiently, no.

  • Result set problems

    I am trying to comparing two tables(assuming they both have the same columns) records by records in two differnet schemas and print out their discrepancy.
    I am using jdbc oracle connection to my database. In main, I'm creating two new tables object and call getTableRecords(schema, tableName)
    and then do the comparsion: table1.compare(table2)
    public Table getTableRecordss(DatabaseInfo dbInfo, Table table)
    String sql = ("Select * from " + table.getName() ");
    try
    Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = stmt.executeQuery(sql);
    rs.setFetchSize(1000);
    String tempString;
    while (rs.next())
    Record record = new Record();
    tempString = rs.getString(i+1);
    if(tempString == null)
    tempString = "";
    record.addValue(tempString);
    table.addRecord(record);
    stmt.close();
    }catch (Exception e)
    e.printStackTrace();
    System.exit(1);
    closeConnection();
    This proram ran okay if the row sizes of a table is less than 200,000, but it will get heap space size Outof Memory error if it is more than that.
    I did try to increase the heap size by -Xmx1024m and still didn't work. Is there any other ways to get this to work? Thanks in advance.

    simcha wrote:
    I need this because I wanted to make sure the table from db1 get streams over to db2What are you doing? Specifically? Are you trying replicate or implement your own RAID? Java is not the way to go for that.
    Is there a way i can get result set by batches?Sure, but nobody can tell you how to do that. You need to figure that out for yourself because we have no idea what your data looks like. But for example, if your data contained a bunch of cars, you could do it in batches like Toyota first, then Ford, then Yugo (probably a small batch)

  • Looping through 2 Result Sets - Not working-HELP!!

    This code loops through my first result set fine.....so I take the first part number from the result set, do a second result set to bring back all part conditions associated with that part number and compare them to see if they are all the same. When it hits the second loop with the second result set, it only loops once. I know this because of my system.out.println only print once.....can someone see where I'm going wrong....thanks in advance....
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    DataSource ds = this.getDataSource();
    HttpSession sess = req.getSession();
    if (sess == null)
    res.sendRedirect(/error.html");
    else
    synchronized(sess)
    UtilParts part = (UtilParts)sess.getValue("UtilParts.PARTS");
    String[] partNumbers = new String[10];
    for(int index=0; index < partNumbers.length; index ++)
    partNumbers[index] = req.getParameterValues("partNumber"+index)[0];
    partNumbers[index] = partNumbers[index].trim();
    String partDesc = req.getParameterValues("partdesc")[0].toUpperCase();
    partDesc = partDesc.trim();
    int rowsCounted = 0;
    for(int index = 0 ; index < partNumbers.length; index ++)
    if(partNumbers[index].equals(""))
    rowsCounted ++;
    Connection conn = null;
    ResultSet resultSet = null;
    ResultSet resultSetMultCond = null;
    PreparedStatement getPartInfo = null;
    Statement getMultPartCond = null;
    String sqlMultCond = null;
    String sql = null;
    try
    conn = ds.getConnection(id,pass);
    conn.setReadOnly(true);
    if(partDesc.equals(""))
    sql = "SELECT #PART,#PDESC,#CONDS,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE '";
    boolean first = true;
    for (int i=0; i < partNumbers.length; i++)
    if (!partNumbers.equals(""))
    if (!first)
    sql += "%' OR #PART LIKE '";
    sql += partNumbers;
    first = false;
    sql += "%' AND #RECDT BETWEEN 20010816 AND 20020816 GROUP BY #PART,#PDESC,#CONDS ORDER BY #PART";
    getPartInfo=conn.prepareStatement(sql);
    resultSet = getPartInfo.executeQuery();
    if(!partDesc.equals(""))
    String sqlDesc = "SELECT #PART,#PDESC,#CONDS,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PDESC LIKE ? AND #RECDT BETWEEN 20010816 AND 20020816 GROUP BY #PART,#PDESC ORDER BY #PART";
    getPartInfo = conn.prepareStatement(sqlDesc);
    getPartInfo.setString(1,partDesc + "%");
    resultSet = getPartInfo.executeQuery();
    Vector enum = new Vector();
    int rowsadded = 0;
    while (resultSet.next())
    rowsadded += 1;
    UtilParts utilityPart = new UtilParts();
    String s = (String)resultSet.getString("#PART");
    s = s.trim();
    utilityPart.setPartNumber(s);
    String t = (String)resultSet.getString("#PDESC");
    t = t.trim();
    utilityPart.setPartDesc(t);
    int resultCount = 0;
    int sameCond = 0;
    String storeName = null;
    String holdName = "No";
    int i = resultSet.getInt("PCOUNT");
    String cond;
    if(i == 1)
    String c = (String)resultSet.getString("#CONDS");
    c = c.trim();
    if(c.equals(""))
    cond = "N/A";
    else
    cond = c;
    utilityPart.setPartCondition(cond);
    utilityPart.setPartCount(i);
    else
    sqlMultCond = "SELECT #PART,#CONDS,COUNT(*) AS MCOUNT FROM MYLIB WHERE #PART = '" + s + "' AND #RECDT BETWEEN 20010816 AND 20020816 GROUP BY #PART,#CONDS ORDER BY #PART";
    getMultPartCond = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_SENSITIVE,java.sql.ResultSet.CONCUR_UPDATABLE);
    resultSetMultCond = getMultPartCond.executeQuery(sqlMultCond);
    int row =0;
    while(resultSetMultCond.next())
    row += 1;
    System.out.println("Row: " + row);
    resultCount = resultSetMultCond.getInt("MCOUNT");
    System.out.println("MCount: " + resultCount);
    if(holdName.equals("No"))
    System.out.println("You are in the no loop");
    storeName = (String)resultSetMultCond.getString("#CONDS");
    holdName = storeName;
    sameCond += 1;
    System.out.println("Same condition: " + sameCond);
    System.out.println("StoreName: " + storeName);
    System.out.println("HoldName: " + holdName);
    else
    storeName = (String)resultSetMultCond.getString("#CONDS");
    if(holdName.equals(storeName))
    sameCond += 1;
    System.out.println("Same condition: " + sameCond);
    System.out.println("StoreName: " + storeName);
    System.out.println("HoldName: " + holdName);
    resultSetMultCond.close();
    getMultPartCond.close();
    if(resultCount == sameCond)
    System.out.println("resultcount equals samecount");
    utilityPart.setPartCount(1);
    utilityPart.setPartCondition("same conditions everywhree");
    else
    System.out.println("resultcount not equal samecount");
    utilityPart.setPartCount(i);
    utilityPart.setPartCondition("");
    enum.addElement(utilityPart);
    }//end of first while
    if (rowsadded == 0 )
    res.sendRedirect("/PartNotFound.html");
    sess.putValue("PARTS",enum);
    resultSet.close();
    conn.close();
    getServletConfig().getServletContext().getRequestDispatcher("/NextQuery.jsp").forward(req,res);
    return;
    catch (SQLException e1)
    System.out.println(e1.getMessage());
    e1.printStackTrace();
    res.sendRedirect("/FindPartSQLError.htm");
    }//end of synchronized session
    }//end of else
    }//end of method

    Got the answer...changed my select statement in my second loop, did a group by CONDS which of course if they are all the same....the result set would only have one value therefore the loop will only execute once...took out the group by CONDS and ran fine....

  • SSIS and Update-Insert(Upsert) based on a SQL Server Result Set

    So on a weekly basis, I have to sweep a sub-set of our Member data. So my query is built to produce this result set. I then have to take that result set and compare it to a data table which contains all that same information that I have provided to a 3rd
    party vendor. So I need to take into account the following scenarios...
    Obviously, if the Member is new, then I have to Insert its row to what we'll call table 3rdPartyMember and create a row out on a 3rdPartyMemberAuditTrail Table
    Individually, I also have to manage if any of the following data fields have changed: Name, Birth Date, Addressing Information, Member Plan, Member Termination...and by Individually what I mean is that if the Last Name has changed, then update its row in
    3rdPartyMember and Insert a row to 3rdPartyMemberAuditTrail indicating "Last Name Change"...and similarly if Address Line 1 has changed..."Address Line 1 Change"
    So I guess my question is this. Should this be done in one whole Stored Procedure invoked by my SSIS Package or should it be done in pieces?
    Create the Temporary Table to house our weekly Member subset extract and result set
    Determine if the row exists on 3rdPartyMember Table and if it does not, Insert it
    If the row exists, determine if there is a First Name Change...Last Name Change...BirthDate change...Address Line 1 change...etc... If there is a change, Update 3rdPartyMember Table and also Insert a row to 3rdPartyMemberAuditTrail indicating the change
    Based on all this, I'm just not sure the right way to approach this...meaning should we create one big Stored Procedure to handle everything or each individual data point in my SSIS as an UpSert based on its lookup. I am new to the SSIS World and don't really
    know what the generally accepted practice is per se of creating and running an SSIS Package with multiple data point update steps or doing so in one big Stored Procedure.
    Also....if anyone know of some good YouTubes or web sites that would instruct me as to how to go about doing this, I'd GREATLY appreciate it.
    Thanks for your review and am hopeful for a reply.

    In my opinion using SSIS is quite a pain for Upsert-functionality, especially with your requirement of maintaining an audit trail.  With Google you can probably find 20 different variants all of which are quite complex.  I would go for the procedure
    version just to keep my sanity.  It is so easy to test and verify.
    I have been using an excellent Uppsert add on from Pragmatic Works Task Factory, but that would not help with the audit trail, though...
    http://pragmaticworks.com/Products/Features?Feature=UpsertDestination(BatchUpdateOrInsert)
    I recently discovered the CHECKSUM-function in Transact-SQL, it might simplify your code and certainly improve performance, if you have lot's of rows.
    Here is an example:
    create table member
    (id int primary key,
    name char(10) not null,
    address char(20) not null,
    checks int not null);
    create table member3p
    (id int primary key,
    name char(10) not null,
    address char(20) not null,
    checks int not null);
    create index xmember3p on member3p(id,checks);
    --create member3p_audit (...);
    insert into member values(1,'tom','new york',0);
    insert into member values(2,'mary','dallas',0);
    insert into member values(3,'marvin','durham',0);
    update member
    set checks = checksum(name,address);
    insert into member3p values(1,'tom','new york',0);
    insert into member3p values(2,'mary','chicago',0);
    update member3p
    set checks = checksum(name,address);
    insert into member3p
    select *
    from member m
    where not exists
    ( select *
    from member3p m3p
    where m3p.id = m.id );
    -- insert into audit...
    select m.*,
    case
    when m.name <> m3p1.name then 'x'
    else ' '
    end as name_change,
    case
    when m.address <> m3p1.address then 'x'
    else ' '
    end as adr_change
    from member m,
    member3p m3p1
    where m.id = m3p1.id and
    exists
    ( select *
    from member3p m3p2
    where m3p2.id = m.id and
    m3p2.checks <> m.checks );
    -- loop and update member3p and member_audit-- It's OK to update columns that were not changedupdate member3p set name = @new_name, address = @new_address;

  • BW Web Report Issue - Result set too large

    Hi,
    When I execute a BEx Query on Web I am getting “Result set too large ; data retrieval restricted by configuration (maximum = 500000 cells)”.
    Following to my search in SDN I understood we can remove this restriction either across the BW system globally or for a specific query at WAD template.
    In my 7x Web template I am trying to increase default max no of rows parameters, As per the below inputs from SAP Note: 1127156.
    But I can’t find parameter “Size Restriction for Result Sets” for any of the web items (Analysis/Web Template properties/Data Provider properties)….in the WAD Web template
    Please advise where/how can I locate the properites
    Instructions provided in SAP Note…
    The following steps describe how to change the "safety belt" for Query Views:
    1. Use the context menu Properties / Data Provider in a BEx Web Application to maintain the "safety belt" for a Query View.
    2. Choose the register "Size Restriction for Result Sets".
    3. Choose an entry from the dropdown box to specify the maximum number of cells for the result set.
                  The following values are available:
    o Maximum Number
    o Default Number
    o Custom-Defined Number
                  Behind "Maximum Number" and "Default Number" you can find the current numbers defined in the customizing table RSADMIN (see below).
    4. Save the Query View and use it in another Web Template.
    Thanks in advance

    Hi Yasemin,
    Thanks for all help...i was off couple of days.
    To activate it I can suggest to create a dummy template, add your query in it, add a menu bar component add an action to save the query view. Then you run the template and change the size restriction for result set then you can save it by the menu.
    Can you please elaborate on the solution provided,I created dummy template with analysis and Menu bar item...i couldn't able to configure menu bar item...
    Thanks in advance

  • How can I use ONE Text search iView to event/affect mutliple Result Sets?

    hello everyone,
    i have a special situation in which i have 6 flat tables in my repository which all have a common field called Location ID (which is a lookup flat to the Locations table).
    i am trying to build a page with a free-form text search iView on Table #1 (search field = Location ID).  when I execute the search, the result set for Table #1 is properly updated, but how do I also get Result Set iViews for Tables #2-6 to also react to the event from Text Search for Table #1 so that they are updated?
    i don't want to have to build 6 different text search iViews (one for each table).  i just want to use ONE text search iView for all the different result set tables.  but, in the documentation and iView properties, the text search iView doesn't have any eventing.
    if you have any suggestions, please help.
    many thanks in advance,
    mm

    hello Donna,
    that should not be a problem, since you are detailw with result sets and detail iviews because custom eventing can be defined for those iviews.
    Yes, it says "no records" found because an active search and record selection havent' been performed for it (only your main table does).
    So, yes, define a custom event, and pass the appropriate parameters and you should be fine.
    Creating a custom event between a Result Set iView and an Item Details iView is easy and works. I have done it.
    See page 35 of the Portal Content Development Guide for a step-by-step example, which is what I used.
    For my particular situation, the problem I'm having is that I want the Search Text iView's event (i.e., when the Submit button is pressed) to be published to multiple iViews, all with different tables.  Those tables all share some common fields, which is what the Search iView has, so I'd like to pass the search critera to all of the iViews.
    -mm

  • Access Subform - Can the Subforms Source Object be defined by an SQL SP result set?

    Hi Guys,
    I can't clearly answer this question with a yes or no.
    I have an Access Sub Form that I am populating with a record set from a Store Procedure. Fairly early on I discovered that for this to work correctly the Source Object for the Sub Form Control must be set first, and most examples (including a working version
    of my own) achieve this by defining an Access Query and setting the Source Object to this.
    What I would really like to do is define the Source Object using the results of a SQL Store Procedure using ONLY code within VBA.
    Now before anyone starts providing alternatives "why don't you just..."  I'm noting now that I have a semi complex solution that makes most non-VBA based approaches ineffective. While it does work at present with an Access Query I'm needing
    to make the result set more dynamic meaning in future I will not know how many columns will be returned or the name of them, only the SP will have this information.
    Thanks in advance!

    Well after much trial and error I've got something which does what I want, although I'm not thrilled that I couldn't do this via my existing ADODB connections, in any case example provided below;
        Dim db As DAO.Database
        Dim qdf As New DAO.QueryDef
        Set db = CurrentDb()
       'qryMyTest refers to a dummy Access query (non pass through). 
        With db.QueryDefs("qryMyTest")
            .Connect = CurrentDb.TableDefs("tblSomeTestSQLTable").Connect
            .SQL = "exec sp_MyTestSP"
            Me.subfrmTest1.SourceObject = "Query.qryMyTest"
        End With   
        Set qdf = Nothing
    I've also marked your response Alphonse as an answer as it lead me onto the right path.

  • SCROLL_SENSITIVE result set can't see the data inserted.

    hi all ,
    I am trying to display all the latest data available in the table through SCROLL_SENSITIVE and UPDATABLE result set after inserting a new record in the table.
    But the result set obtained after executing the query initially is not able to see the newly inserted record in the table and hence same result is getting printed out in both the cases.
    Can u explain me what's happening in this case ?? And how can i get the updated record also without executing the statement query twice to get the latest result set.
    My full code is given below.
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class Misc3 {
    public static void main(String[] args) {
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    try {
    int empid;
    String lname;
    String fname;
    int deptno;
    int mngrid;
    con = JDBCUtil.getOracleConnection();
    stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    String query = "select employee_id , last_name , first_name , department_number , manager_id from employees ";
    rs = stmt.executeQuery(query);
    System.out.println("Before inserting the new record.....");
    while (rs.next()) {
    empid = rs.getInt(1);
    lname = rs.getString(2);
    fname = rs.getString(3);
    deptno = rs.getInt(4);
    mngrid = rs.getInt(5);
    System.out.println(empid + "\t" + lname + "\t" + fname + "\t" + deptno + "\t" + mngrid);
    System.out.println("Going to insert the new record.....");
    rs.moveToInsertRow();
    rs.updateInt(1, 10);
    rs.updateString(2, "Clark");
    rs.updateString(3, "John");
    rs.updateInt(4, 2);
    rs.updateInt(5, 2);
    rs.insertRow();
    System.out.println("New record inserted successfully.....");
    System.out.println("After inserting the new record.....");
    rs.beforeFirst();
    while (rs.next()) {
    empid = rs.getInt(1);
    lname = rs.getString(2);
    fname = rs.getString(3);
    deptno = rs.getInt(4);
    mngrid = rs.getInt(5);
    System.out.println(empid + "\t" + lname + "\t" + fname + "\t" + deptno + "\t" + mngrid);
    } catch (SQLException ex) {
    System.out.println("error code : " + ex.getErrorCode());
    System.out.println("error message : " + ex.getMessage());
    } finally {
    JDBCUtil.cleanUp(con, stmt);
    *** JDBCUtil Class ****
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;
    public class JDBCUtil {
    public static Connection getOracleConnection(){
    Connection con = null;
    try{
    // Load the driver
    Class.forName("oracle.jdbc.driver.OracleDriver");
    //Establish Connection
    con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","ex","ex");
    }catch(Exception ex){
    ex.printStackTrace();
    return con;
    public static void cleanUp (Connection con , Statement stmt){
    // Release the resource
    try{
    if(con != null){
    con.close();
    if(stmt != null){
    stmt.close();
    }catch(Exception ex){
    ex.printStackTrace();
    Edited by: user12848632 on Aug 13, 2012 2:06 PM

    >
    Can u explain me what's happening in this case ?? And how can i get the updated record also without executing the statement query twice to get the latest result set.
    >
    Sure - but you could have answered your own question if you had read the doc link I gave you in your other thread and next time you post code use \ tags on the lines before and after the code - see the FAQ for info
    17076 : Invalid operation for read only resultset
    {quote}
    •Internal INSERT operations are never visible, regardless of the result set type.
    {quote}
    See •Seeing Database Changes Made Internally and Externally in the JDBC Dev doc I pointed you to
    http://docs.oracle.com/cd/B28359_01/java.111/b31224/resltset.htm#i1024720
    Did you notice the words 'never visible'? You won't see them as part of the result set unless you requery.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to Create a new column from two different result sets

    How to Create a new column from two different result sets, both the result set uses the different date dimensions.

    i got solutions for this is apply filters in column formula it self, based on the requirement.

Maybe you are looking for