BUG? BRIDGE statement to compare two tables

Hello,
I tried to compare two tables in different dbs and remembered a post about Cross Connectin Queries
http://barrymcgillin.blogspot.com/2010/11/cross-connection-queries.html
BRIDGE temparb AS "EB05 01"
(SELECT * FROM arb)
(SELECT * FROM temparb
MINUS
SELECT * FROM arb
UNION ALL
(SELECT * FROM arb
MINUS
SELECT * FROM temparb
);I would expect to get the differences between the table arb in my current schema and the table arb alias temparb in the other db. Yet it seems, that in this case only the table in my current schema is read.
I materialize the BRIDGE table with
BRIDGE temparb AS "EB05 01"
(SELECT * FROM arb)and select the value I know to be only in the remote schema
SELECT id FROM temparb WHERE id = 2562;
SELECT id FROM arb WHERE id = 2562;Both times I get no result. I even tried to use aliases on the table, same result. Tested in 3.0 and 3.1 EA3.
Has anyone tried this before?
Regards
Marcus

Hi Marcus,
Have you tried it without the double quotes around the connection name?
I have a connection called
system_local
which I run the following command in
drop table testbridge_remote;
drop table testdbrige;
create table testbridge(col1 int);
insert into testbridge values (1);
insert into testbridge values (2);
insert into testbridge values (3);
commit;
I have a connection called
Connection Name With Space
which I run the following in
drop table testdbrige;
create table testbridge(col1 int);
insert into testbridge values (4);
insert into testbridge values (5);
insert into testbridge values (3);
commit;
Then in the system_local connection/worksheet I can run the following statement
BRIDGE testbridge_remote as Connection Name With Space(select * from testbridge)
+(SELECT * FROM testbridge_remote+
MINUS
SELECT * FROM testbridge
+)+
UNION ALL
+(SELECT * FROM testbridge+
MINUS
SELECT * FROM testbridge_remote
+);+
It works ok.
Returning rows in the remote table not in the local table , and rows in the local table not in the remote table .
Regards,
Dermot
SQL Developer Team.

Similar Messages

  • Comparing Two tables with 300k records and update one table

    Could you let me know how to compare two tables having 300k records and update one table.below is the scenario.
    Table Tabl_1 has columns A,B and Tabl_2 has columns B,new_column.
    Column B has same data in both the tables.
    I need to update Tabl_2 in new_column with Tabl_1 A column data by comparing B column in both tables.
    I m trying to do using PLSQL Tables.
    Any suggestion?
    Thanks.

    Hi,
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved, so that the people who want to help you can re-create the problem and test their ideas.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    If you're asking about a DML statement, such as UPDATE, the CREATE TABLE and INSERT statements should re-create the tables as they are before the DML, and the results  will be the contents of the changed table(s) when everything is finished.
    Always say which version of Oracle you're using (for example, 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    ef2019c7-080c-4475-9cf4-2cf1b1057a41 wrote:
    Could you let me know how to compare two tables having 300k records and update one table.below is the scenario.
    Table Tabl_1 has columns A,B and Tabl_2 has columns B,new_column.
    Column B has same data in both the tables.
    I need to update Tabl_2 in new_column with Tabl_1 A column data by comparing B column in both tables.
    I m trying to do using PLSQL Tables.
    Any suggestion?
    Thanks.
    Why are you trying to use PL/SQL tables?  If tabl_1 and tabl_2 are regular database tables, it will be much simpler and faster just to use them.
    Depending on your requirements, you can do an UPDATE or MERGE, either in SQL or in PL/SQL.

  • Compare two tables and log the difference

    Hi,
    I want to compare two tables and log the difference in new table with the fields as (old value,new value, column name). The column name should be the changes value column

    Can you show an example?
    SELECT Foo.*, Bar.*
       FROM Foo
            FULL OUTER JOIN
            Bar
            ON Foo.c1 = Bar.c1
               AND Foo.c2 = Bar.c2
               AND Foo.cn = Bar.cn
     WHERE Foo.key IS NULL 
        OR Bar.key IS NULL; 
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Compare two table columns

    hi all,
    i am using db10g.
    my task is to compare two table's data for example
    table1 is having
    col1 col2 col3
    a b c
    e f g
    table2 is
    col4 col5 col6
    a e c
    e f g
    so i have to compare col1 first record and col4 first record.
    in otherwords first table first column first item with second table first table first value and so on.
    for ex: a= a
    b= e
    c= c etc
    how can i acheive this?
    both are database tables.
    i cannot use minus function because data types are different for the corresponding column
    how can i compare it?
    Thanks..
    Edited by: user13329002 on Jan 13, 2011 1:09 AM

    Hi,
    Try this
    select
        case
            when a.col1 = b.col1 then 'EQUAL' else 'NOT EQUAL' end column1,
        case
            when a.col2 = b.col2 then 'EQUAL' else 'NOT EQUAL' end column2,
        case
            when a.col3 = b.col3 then 'EQUAL' else 'NOT EQUAL' end column3 
    from (select col1,col2,col3,rownum rn from table1) a,
                                (select col1,col2,col3,rownum rn from table2) b where a.rn = b.rn Try to see how you order the rows of the two tables.
    cheers
    VT

  • Comparing two tables

    how to compare two tables between two systems ?

    hi sravan, u can go to t/c OY19 to compare the two tables.
    Choose Manual selection
    Enter the name of the table that you want to compare
    Choose Execute
    in the next screen you have to give the description and RFC connection name which will make the link between two clients.
    Regards...
    Arun.
    Reward points if useful.

  • COMPARE TWO TABLES

    HI,
    How to compare two tables in ODI.I want to extract UNMATCHED data in the two tables without using procedures,views.

    Hi,
    these tables has the exactly same ddl or the comparacion will be based on PK (or UK)?

  • How to compare two tables in SSIS?

    I am creating an SSIS package that will compare two tables and then insert data in another table.
    Which tool shall I use for that? I tried to use "Conditional Split" but it looks like it only takes one table as input and not two.
    These are my tables:
    TABLE1
    ID
    Status
    TABLE2
    ID
    Status
    TABLE3
    ID
    STatus
    I want to compare STATUS field in both tables. If Status in TABLE1 is "Pending" and in TABLE2 is "Open" then insert this record in TABLE3.

    You can use MERGE command , Sorry cannot test it right now.
    MERGE INTO tbl3
    USING (SELECT tbl2.ID, tbl2.status,tbl1.status as st1  FROM tbl1 JOIN tbl2 ON tbl1.ID=tbl2.ID) AS t ON T.ID=tbl3.ID 
    AND t.status='OPEN' AND t.st1='pending'
    WHEN NOT MATCHED 
    INSERT (status) VALUES (t.status)
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • To compare two tables

    Hi
    There are two tables. One at source side and other at target side. The data first goes from source to some intermediate table and then from that intermediate table to the target table.Both the source and the target tables have same set of data.Both are partitioned on same fields Now I want to compare both tables on some fields for every record.
    Can any one suggest me that what would be the best approach to do so taking care that both source and target tables have large amount of data approx. 95M rows?

    However, if you are using a SELECT MINUS (or similar), please consider these
    issues:
    1. The database does 2 full table scans for each
    table. A client can do just one per table.Really?
    SQL> select * from a
      2  minus
      3  select * from b
      4  ;
    Execution Plan
    Plan hash value: 1035326697
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |      |  1000 | 26000 |     8  (63)| 00:00:01 |
    |   1 |  MINUS              |      |       |       |            |          |
    |   2 |   SORT UNIQUE       |      |  1000 | 13000 |     4  (25)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL| A    |  1000 | 13000 |     3   (0)| 00:00:01 |
    |   4 |   SORT UNIQUE       |      |  1000 | 13000 |     4  (25)| 00:00:01 |
    |   5 |    TABLE ACCESS FULL| B    |  1000 | 13000 |     3   (0)| 00:00:01 |
    ----------------------------------------------------------------------------Looks like one FTS of each table to me.
    2. The SELECT MINUS (and other techniques) doesn't
    cover LOBs.LOB's can easily be dealt with by e.g. obtaining the HASH value during the comparison and then comparing HASH values. A client application would only have to do something similar or do a byte by byte or chr by chr comparison.
    3. With the database, you have to wait for the end of
    the query to see ANY results. A client tool can show
    you diffs as it finds them.If I'm comparing the differences between tables, I'm likely to want to obtain the whole set of data anyway and store it rather than 'see' it as it comes out. I also don't want to have to wait whilst all 95 million rows of data from two tables is transported over the network to my client so that it can do a comparison on it in memory (assuming it has the memory to do it and doesn't have to use swap space). Far better that the database server does the comparison at it's end.
    ;)

  • How to compare two tables data...need sql report or utility to find differe

    Hi,
    We have a requirement where we are asked to find data differences between two tables and one of the tables reside on remote database. The database version is same ( 10g ) and datatypes for the tables are similar.
    The client is looking for a sql report or kind of utility to display the data differences for each column ( if possible count differences ) with some meaningful error messages.
    Could anyone let me know the best possible way of doing it..?
    Thanks
    Hitarth

    Hi,
    I found something for tables comparison but getting one error...can you check this please and let me know what is wrong
    Here is the function:
    CREATE OR REPLACE FUNCTION compare_query_results (
    p_query1 IN VARCHAR2
    , p_query2 IN VARCHAR2
    , p_raise_error_if_not_equal IN BOOLEAN DEFAULT FALSE
    , p_raise_error_if_no_rows IN BOOLEAN DEFAULT FALSE
    RETURN NUMBER
    IS
    -- Constants
    c_query_results_equal CONSTANT PLS_INTEGER := 0;
    c_query_results_not_equal CONSTANT PLS_INTEGER := 1;
    oracr CONSTANT VARCHAR2 (1) := CHR (10);
    -- Variable Declaration
    v_sql_stmt VARCHAR2 (32767);
    v_record_count PLS_INTEGER;
    v_return_code PLS_INTEGER;
    v_record DUAL.dummy%TYPE;
    v_result_set_has_rows BOOLEAN;
    -- Ref Cursors
    v_cursor sys_refcursor;
    -- Custom Defined-Exceptions
    result_sets_do_not_match EXCEPTION;
    query_returns_no_rows EXCEPTION;
    BEGIN
    -- Get the count of differing records between p_query1 and p_query2
    dbms_output.put_line('Start-1');
    v_sql_stmt :=
    ' (SELECT /*+ materialize */'
    || SUBSTR (p_query1, INSTR (UPPER (p_query1)
    , 'SELECT'
    , 1
    , 1
    ) + 6)
    || ')
    , (SELECT /*+ materialize */'
    || SUBSTR (p_query2, INSTR (UPPER (p_query2)
    , 'SELECT'
    , 1
    , 1
    ) + 6)
    || ')
    SELECT ''X''
    FROM (
    (SELECT * FROM test1 MINUS SELECT * FROM test2)
    UNION ALL
    (SELECT * FROM test2 MINUS SELECT * FROM test1)
    dbms_output.put_line('Start-2');
    OPEN v_cursor
    FOR v_sql_stmt;
    dbms_output.put_line('Start-3');
    FETCH v_cursor
    INTO v_record;
    dbms_output.put_line('Start-4');
    v_result_set_has_rows := v_cursor%FOUND;
    dbms_output.put_line('Start-5');
    CLOSE v_cursor;
    dbms_output.put_line('Start-6');
    -- If there are rows - the result sets do NOT match...
    IF v_result_set_has_rows
    THEN
    v_return_code := c_query_results_not_equal;
    IF p_raise_error_if_not_equal
    THEN
    RAISE result_sets_do_not_match;
    END IF;
    -- If there are no rows - the result sets do match...
    ELSIF NOT v_result_set_has_rows
    THEN
    IF p_raise_error_if_no_rows
    THEN
    -- Check to make sure that the queries contain rows if desired...
    v_sql_stmt := 'SELECT ''X''
    FROM (' || oracr || p_query1 || oracr || ')';
    OPEN v_cursor
    FOR v_sql_stmt;
    FETCH v_cursor
    INTO v_record;
    IF v_cursor%NOTFOUND
    THEN
    CLOSE v_cursor;
    RAISE query_returns_no_rows;
    END IF;
    CLOSE v_cursor;
    END IF;
    v_return_code := c_query_results_equal;
    END IF;
    RETURN v_return_code;
    EXCEPTION
    WHEN result_sets_do_not_match
    THEN
    raise_application_error (-20101, 'The Queries'' result sets do NOT match. Error returned
    as requested.');
    WHEN query_returns_no_rows
    THEN
    raise_application_error (-20102, 'The Queries'' result sets match, however they contain no
    rows. Error returned as requested.');
    WHEN OTHERS
    THEN
    -- Raise the error
    raise_application_error (-20103
    , 'There is a syntax or semantical error in one or both queries
    preventing comparison.'
    || oracr
    || 'Error Stack :'
    || oracr
    || DBMS_UTILITY.format_error_stack ()
    || oracr
    || 'Error_Backtrace:'
    || oracr
    || DBMS_UTILITY.format_error_backtrace ());
    END compare_query_results;
    I have created two tables ( test1 and test2 ) with few columns and with the same datatypes and executed the above function...I am getting error as folliowing:
    DECLARE
    ERROR at line 1:
    ORA-20103: There is a syntax or semantical error in one or both queries
    preventing comparison.
    Error Stack :
    ORA-00900: invalid SQL statement
    Error_Backtrace:
    ORA-06512: at "ORAOWNER.COMPARE_QUERY_RESULTS", line 53
    ORA-06512: at "ORAOWNER.COMPARE_QUERY_RESULTS", line 121
    ORA-06512: at line 12
    Could someone please help me fixing this error..It would be really appreciated
    Thanks
    Hitarth

  • Compare two tables in SAP

    Hello!
    I have one table in ERP6.0 system, let's say T082G that is different in DEV and in PRD system after the Upgrade. The difference is the one table has more activated radio buttons than the other one.
    How can I compare the two tables and fix the problem?
    Which tcode can be applied here?
    Thank you very much!
    regards
    Thom

    Hi,
    Compare a contents of a table between clients.
    and also, The contents of a table between two systems can be checked through the transaction OY19
    Regards

  • Compare Two Table

    Dear All,
    I have two tables.
    I want to compare them as one is having 5 crore records and other is having 12 lack records and table name is P and Q respectively.
    I want to know that, how many records not in the table P by comparing table Q.
    For that i have created a query like below:-
    select distinct a from P where b is null and c not in (select a from Q).Is it correct or i should use something other.
    Thanks
    Edited by: BluShadow on 05-Dec-2011 11:28
    removed unnecessary {noformat}{noformat} tags and put them around just the query                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Please post more details, including some example tables and data, and tell us your database version.
    p.s. please only use {noformat}{noformat} tags when you're posting code/data, not for your text.                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Stored Procedure to compare two tables data

    Hello,
    I want to have a Stored Procedure which will compare data (only a single column) of two tables and delete the row which is not present in the second table.
    For eg.,
    I have got 2 tables called Table1 and Table2, which have the same column called ID(PK).
    The data in Table1 is 1,2,3 and data in Table2 is 1,3. When the stored procedure runs, it has to compare the ID column in Table1 to ID column in Table2 and since '2' is not there in Table2, I want to delete this row from Table1.
    Thanks in advance.

    user11281601 wrote:
    Hello,
    I want to have a Stored Procedure which will compare data (only a single column) of two tables and delete the row which is not present in the second table.
    For eg.,
    I have got 2 tables called Table1 and Table2, which have the same column called ID(PK).
    The data in Table1 is 1,2,3 and data in Table2 is 1,3. When the stored procedure runs, it has to compare the ID column in Table1 to ID column in Table2 and since '2' is not there in Table2, I want to delete this row from Table1.
    Thanks in advance.
    delete from table1 where id_column in
    (select id_column from table1
    minus
    select id_column from table2);

  • Comparing two tables and picking the records

    I have two tables A and B.  I have to compare a column ID in both table A and table B  A.ID=B.ID  And based on the above comparison if the match is found I need to pick the records from table A and if no match then need to pick the records from table B  My problem is if I join then I will have table A and table B as one record and will be difficult to separate out.  Please let me know how this can be acheived.  Thnx.

    I have two tables A and B.  I have to compare a column ID in both table A and table B  A.ID=B.ID  And based on the above comparison if the match is found I need to pick the records from table A and if no match then need to pick the records from table B  My problem is if I join then I will have table A and table B as one record and will be difficult to separate out.  Please let me know how this can be acheived.  Thnx.

  • Compares  two tables S780 and S720 by material , Print the Difference value

    Hi abapers,
    Report  which compares the two tables S780 and S720 by material
    the Statistic currency value of these two tables if show the differences
    the report should display only Diffrece value:
    The selection should be by
    Revenue country, Salesorganisation , month and version
    output like this
    Material  Value S720  / Value S780 /   currency difference should be print out.
    Regards
    Raj

    Hi
    Use join or for all entries
    then move the records into a final table
    loop at itab
    then get the difference.
    modify the itab by transporting the difference.
    Regards
    Shiva

  • Compare two tables having different number of rows based on 2 columns

    Hi,
    I am having two tables table a having field1, field2 and table b having fields field1 and field2.
    I want those records from table a in which field1 of table a is not matching to field1 of table b and field2 of table b not matching to field2 of table b, but i also want the bifurcation of records as whether field 1 is not matching, field 2 is not matching or both fields 1 & 2 are not matching.
    e.g.
    table a table b
    field1 field2 field1 field2
    1 6 12 5
    2 5 1 9
    13 51 13 51
    45 31 99 121
    33 45
    In this case my output should be
    table a
    field1 field2 Mtchng_Field
    1 6 Field 2 not mtchng
    2 5 Field 1 not mtchng
    45 31 Feild1 and Field2 both not matching
    How would i get my result in the required format.

    sql>select * from t1;
    N1 N2 
    1   6 
    2   5 
    13  51 
    45  31 
    33  45 
    sql>select * from t2;
    N1 N2 
    12  5 
    1   9 
    13  51 
    99  121
    sql>
    select n1,n2,decode(nvl(p1,0)+nvl(p2,0),0,'No match',1,'F2 not match',2,'F1 not match','Match') status
    from(
      select n1,n2,(select 1
                   from t2 where n1=t1.n1) p1,(select 2
                                           from t2 where n2=t1.n2) p2
    from t1);
    N1 N2 STATUS 
    1   6   F2 not match 
    2   5   F1 not match 
    13  51  Match 
    45  31  No match 
    33  45  No match
    Message was edited by:
            jeneesh
    Message was edited by:
            jeneesh
    Some problems...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • Selecting from Multiple Tables but requiring data to match from a 3rd table

    Hello Everyone, I'm having alot of trouble with this select I have three tables: prod_poured, conc_test, and cyl_breakTo put together my report, I need to grab this data: cyl_break.pour_no "Pour Number", cyl_break.cyl_id "Cylinder ID", cyl_break.pour

  • SPUtility.GetPrincipalsInGroup method throws Thread was being aborted error when SPGroup Name is passed

    Hello, I am getting 'Thread was being aborted - Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack' error when I use 'SPUtility.GetPrincipalsInGroup' method. bool bReachedMaxCount = false; SPPrin

  • Compatibility question UCCX with CCM V5. ???

    like the above info ! Dears good day, i just need a help to know if there is a compatibility for the integration between newest UCCX and CUCM V 5.x or not ? and also need t ask about how much maximum CTI ports for IPCC premium licences till now we ha

  • Module FS-CD, Topic- Refund rules

    In the way we perform write off (item level write-off : FP04 and mass write-off: FP04M), wherein we can put certain parameters (like contract account range, dollar range etc.) do we have anything in refund by which we can set parameters (for e.g. for

  • Adope acrobat 9 - font problem

    Hallo all of you out there. I get this error when trying to edit a pdf document using adope acrobat 9. I use the Touchup tool, mark the text and when trying to delete or write anything i get the error below (dropbox link, Danish) Dropbox - adope acro