PL/SQL-find out extra rows present in  table by comparing 2 similar tables

Hi, can any one give me an idea to find out the extra rows present in table by comparing 2 similar tables using pl/sql.
REQUIREMENT::i am working on the upgrade environment.my previous database has some tables and having data.Now functional folks are adding some new data to the existing tables for the upgrade database.I need to identify that new rows which are added by them.
for this , i created name table with 2 columns n,n1 which contains the table names.
Table Name:Name
columns:n n1
a ax
b bx
c cx
a,b c........are the table names which are in the previous database environment.(approx >1500 tables)These tables having data.
ax,bx,cx..........table names which are in the upgrade environment contains the extra data which is added by the functional folks.
a&ax,b&bx.................(approx 1500 tables) are having same structure except some of them.
Now i want to write a pl/sql program that reads both table names a&ax from name table and then by comparing the rows of a&ax ,i need to find out the extra rows present in the ax table to store that in different place.
Example:
a table
id name
1 co
2 wi
3 il
ax table
id name
1 co
2 wi
3 il
4 va
5 ca
Here i need to find out the difference b/n the 2 tables ,the extra rows id 4,5 and place it some where.

this is just for demo, is this you mean?
SQL> ed
Wrote file afiedt.buf
  1  SELECT empno,ename,e.DEPTNO emp_deptno, d.deptno dept_deptno,d.DNAME
  2  FROM EMP e full outer join DEPT d
  3* on d.DEPTNO= e.DEPTNO
SQL> /
     EMPNO ENAME      EMP_DEPTNO DEPT_DEPTNO DNAME
      7934 MILLER             10          10 ACCOUNTING
      7839 KING               10          10 ACCOUNTING
      7782 CLARK              10          10 ACCOUNTING
    snipp........
      7521 WARD               30          30 SALES
      7499 ALLEN              30          30 SALES
      156 1
12 1
40 OPERATIONS
90 LOGISTIC
18 rows selected.
SQL> ed
Wrote file afiedt.buf
  1  SELECT empno,ename,e.DEPTNO emp_deptno, d.deptno dept_deptno,d.DNAME
  2  FROM EMP e left outer join DEPT d
  3* on d.DEPTNO= e.DEPTNO
SQL> /
     EMPNO ENAME      EMP_DEPTNO DEPT_DEPTNO DNAME
      7934 MILLER             10          10 ACCOUNTING
      7839 KING               10          10 ACCOUNTING
      7782 CLARK              10          10 ACCOUNTING
      7902 FORD               20          20 RESEARCH
    snipp..................
      7654 MARTIN             30          30 SALES
      7521 WARD               30          30 SALES
      7499 ALLEN              30          30 SALES
       156 1
12 1
16 rows selected.
SQL> ed
Wrote file afiedt.buf
  1  SELECT empno,ename,e.DEPTNO emp_deptno, d.deptno dept_deptno,d.DNAME
  2  FROM EMP e[b] right outer join  DEPT d
  3* on d.DEPTNO= e.DEPTNO
SQL> /
     EMPNO ENAME      EMP_DEPTNO DEPT_DEPTNO DNAME
      7369 SMITH              20          20 RESEARCH
      7499 ALLEN              30          30 SALES
      7521 WARD               30          30 SALES
      7566 JONES              20          20 RESEARCH
      snipp......................
      7902 FORD               20          20 RESEARCH
      7934 MILLER             10          10 ACCOUNTING
                                         40 OPERATIONS
90 LOGISTIC
16 rows selected.

Similar Messages

  • ADF table: How to find out which rows were modified by the user

    Hi,
    I am using ADF table to display data that can be modified by the user (ReadOnly = false in the input text). I need to find out which rows were modified by the user, and only update (persist) those rows in the database.
    Is there an easy way to find out which rows were modified by the user.
    I am NOT particularly concerned with which columns were modified as I would update the entire row (if any data in that row is modified).
    I am using Oracle JDeveloper version 11.1.1.3.
    Thanks,
    Ash K

    Thanks Timo.
    I am using ADF Data Control (which are created from Web Service proxy) to display/update the data.
    In the backing bean, the operation that is invoked at the time persisting data is as follows:
    public void commitOperation {
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("operationA");
    DCIteratorBinding dciter = (DCIteratorBinding)bindings.get("someIterator");
    for(int i=0; i<dciter.getViewObject().getEstimatedRowCount(); i++)
    Row row=dciter.getRowAtRangeIndex(i);
    SomeObject someObject= new SomeObject ();
    someObject.setAttr1(row.getAttribute("Attrbute1").toString());
    someObject.setAttr2(row.getAttribute("Attribute2").toString());
    objectList.add(someObject);
    operationBinding.getParamsMap().put("param1", objectList);
    ResultObject result = (ResultObject) operationBinding.execute();
    Inside the for loop (or any other place in the backing bean), I would like to figure out if the row was modified by the user. Please let me know if how to get that. If ADF provides this automatically, that would be GREAT.
    Thanks,
    Ash K

  • How to find out the rows inserted between a time period.

    Hi,
    Please help me to solve this.
    Table - emp.
    Colmns - empno(Primary Key),ename, mgr
    How to find out the rows inserted between a time period.
    For eg:- Between 02-Oct-2006 1 PM and 03-Oct-2006 2 PM.
    regards,
    Mathew.

    Hi,
    Maybe work:
    For each row, ORA_ROWSCN returns the conservative upper bound system change number (SCN) of the most recent change to the row. This pseudocolumn is useful for determining approximately when a row was last updated. It is not absolutely precise, because Oracle tracks SCNs by transaction committed for the block in which the row resides
    e.g.:
    SGMS@ORACLE10> create table test(cod number);
    Table created.
    SGMS@ORACLE10> insert into test values (1);
    1 row created.
    SGMS@ORACLE10> insert into test values (2);
    1 row created.
    SGMS@ORACLE10> commit;
    Commit complete.
    SGMS@ORACLE10> insert into test values (3);
    1 row created.
    SGMS@ORACLE10> commit;
    Commit complete.
    SGMS@ORACLE10> select SCN_TO_TIMESTAMP(ora_rowscn),ora_rowscn,cod from test;
    SCN_TO_TIMESTAMP(ORA_ROWSCN)       ORA_ROWSCN        COD
    06/11/06 08:56:56,000000000         727707205          1
    06/11/06 08:56:56,000000000         727707205          2
    06/11/06 08:57:05,000000000         727707210          3Cheers

  • ALV event ON_CLICK - find out selected row?

    I have an ALV table and in one of the columns I display a linkToAction in each cell.
    When the link is clicked, i go to the ON_CLICK event handler and try to find out, which row is selected.
    For this, I can take the attribute "INDEX" of the parameter "R_PARAM", and read the context with the given index.
    METHOD alv_event_on_click .
       DATA lo_nd_my_node    TYPE REF TO if_wd_context_node.
       DATA lt_my_table          TYPE wd_this->elements_my_table.
       DATA ls_my_structure    TYPE wd_this->element_my_struture.
    *  click on prduct standard name link
       IF r_param->attribute = 'NAME_OF_THE_COLUMN'.
           lo_nd_my_node = wd_context->get_child_node( name = wd_this->wdctx_my_node ).
           lo_nd_my_node->get_static_attributes_table( IMPORTING table = lt_my_table ). "this is not sorted!!!!
           lo_nd_my_node->set_lead_selection_index( index = r_param->index ).
           READ TABLE lt_my_table INTO ls_my_structure INDEX r_param->index. "lt_my_table table might be sorted differently!!!!
           IF sy-subrc = 0.
             wd_this->do_something_with( ls_my_strcture ).
           ENDIF.
       ENDIF.
    ENDMETHOD.
    However, this does not work when I sort the ALV before!
    For a strange reason, the table that I get from the context is not sorted the same way as the data in the ALV.
    What can I do?

    Hi Daniel,
    I don't know if the external mapping messes things up.
    Perhaps you could try the following:
    lo_nd_my_node->get_static_attributes(
      EXPORTING
        index                = r_param->index
      IMPORTING
        static_attributes = ls_my_structure ).
    It could be that passing the data towards your internal table doesn't take over the sort.
    If you try debugging and check out the contents of the node, are they sorted correctly or not?
    Regards and good luck.
    Jos

  • How to find out the script for the table using SQL

    Hi,
    Could any one tell me that how to find out the script for the table using SQL.
    Thanks,
    kamal

    Kamal,
    You can find the SQL query in Advanced tab of Answers
    Thanks,
    Balaa...

  • Check 2 tables(Table A and Table B) and figure out new columns present in Table A and add these new columns to Table B

    How to check 2 tables(Table A and Table B) and figure out new columns present in Table A and add these new columns to Table b.
    DDL-
    Create table A
    ( A INT,
    B INT,C VARCHAR(2)
    Create table B
    A INT,
    B INT
    Any advice on the best approach or method to achieve this.
    I understand that I need to check the schema of the columns and then do a match between 2 tables and find new columns and then alter my target table
    Mudassar

    Can you try this..
    CREATE TABLE A ( A INT, B INT, C VARCHAR(2) )
    CREATE TABLE B ( A INT, B INT )
    Declare @ColumnVar nvarchar(128),@DatatypeVar nvarchar(128)
    SELECT @ColumnVar=x.COLUMN_NAME, @DatatypeVar=x.DATA_TYPE
    FROM INFORMATION_SCHEMA.COLUMNS AS x
    WHERE TABLE_NAME = 'A'
    AND NOT EXISTS ( SELECT *
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_NAME = 'B'
    AND COLUMN_NAME = x.COLUMN_NAME )
    Declare @SQL VarChar(1000)
    SELECT @SQL = 'ALTER TABLE B ADD ' + @ColumnVar + ' '+ @DatatypeVar
    Exec (@SQL)
    select * from B
    Please Mark This As Answer if it helps to solve the issue
    http://stackoverflow.com/questions/2614101/alter-table-my-table-add-column-int

  • How to find out the selected column in Table Control

    Hi all,
          How to find out the selected column in Table Control?
    Thanks & Regards,
    YJR

    Hi,
    Let your table control name in Screen painter be TC1.
    READ TABLE TC1-COLS INTO WA_COLS (some wok area)
                 WITH KEY SELECTED = 'X'.
            IF SY-SUBRC = 0.
              CLEAR: W_DUMMY, W_COL_NAME.
              SPLIT WA_COLS-SCREEN-NAME AT '-' INTO W_DUMMY
                                                   W_COL_NAME.
            endif.
    W_COL_NAME gives you the column name.
    Hope it helps.
    cheers
    sharmistha

  • How to find out the name of a table?

    Hi
    How can I find out the name of a table which doesn't have a record history?
    Regards
    Rahman

    No direct way to know the tables. What you will find on the ABout this page link are the View Object (similar to record sets), Entity objects, controller and Application module. Generally EO is based on a table or the VO can be based on the query which you can find the corresponding xml file. But a button action might be calling a method in AM or CO which in turn call some wrapper method to interact with database. So nothing straight forward. You will have to analyze the all page related code objects.
    They are specific to OA framework and if you are not aware about them, better go through the initial chapters of OAF dev guide.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to find out the link for the tables for sub contract PO

    Dear All,
    How to find out the link for the tables for sub contract PO, I am looking for the fields Material, Unit, Batch no., quantity.
    Please provide the solution for the Table related to ABAP.
    Thanks,
    V.V.

    Hi,
       Make use of the table EKKO, EKPO...
    For subcontract please select the option in EKPO-PSTYP.
    Regards
    GK.

  • How can I find out when was a particular table last updated?

    How can I find out when was a particular table last updated? I need to find out the usage of this table - when was it last updated, etc. Thanks in advance. The version I am using is Oracle 9i.

    If you don't have any application level logging, and auditing is not enabled, there's not much hope.
    You could, if you have archive logs available, go trawling through archive logs via logminer, but that's likely to prove painful and not very fruitful, unless you're very meticulous and patient...
    -Mark

  • How to find out what is populating a table using sql

    I would like to find out what is populating a particular tabe. I used
    select name,type from dba_source where text like upper('%some_table%'). I know this will give me procedure,function package etc, If this table is being populated by a form how will i get the form name. I am using window XP oracle 10G database

    IF you to check what is running at a precisly momemmt you need to Join :
    v$transaction a, Gives you current Transaction going On
    v$session b, Gives You info about session User
    v$sql c Gives you info about SQL Running at Precisly momment
    With these Condition you are able to Find what's is Runnimg
    where a.SES_ADDR= b.SADDR (+) and
    b.SQL_HASH_VALUE = c.HASH_VALUE(+)
    I Hope This May help.
    Rgds

  • How to find out the rows inserted in the last n minutes ?

    Hi all,
    I have a log table where, every time a warning is issued, a new row is added. The table has a field with the sysdate when the warning was issued.
    I'd need to collect all warnings in the last (supposing) 30 minutes and send a mail to the administrator. Looking at some faqs I have elaborated this:
    select * from PROCEDURE_LOGS p where ((p.DATE_LOG - sysdate)*-1440) < 30
    However this does not produce anything.
    Can anybody help me to correct this statement ?
    Thanks a lot
    Frank

    Hi, Frank,
    That looks okay to me. Are you sure you have rows in the table with a date_log in the last 30 minutes? Post some sample data (CREATE TABLE and INSERT statements), and the results you expect from that data for a given value of SYSDATE.
    By the way, you can make the WHERE clause clearer like this:
    select     *
    from      PROCEDURE_LOGS     p
    where      ( (sysdate - p.DATE_LOG)
         * 1440           -- = 24 * 60
         ) < 30but this won't change the results.
    Edited by: Frank Kulash on Dec 1, 2010 9:51 AM
    I just saw Toon's reply:
    where     p.DATE_LOG > sysdate - (30 / 1440)as Toon suggested, is clearer still, and potentially more efficient if ther's an index on date_log.

  • How to find latest updated row in a table

    Hi
    Here I have command that display updated time.But I Need which row was lastly updated (show particular row) in that table.
    select scn_to_timestamp(max(ora_rowscn))
    from employee;

    First of all, SCN to timestamp mapping exists for a short period of time, so if change is relatively old you'll get ORA-08181:
    SQL> select max(ora_rowscn) from emp;
    MAX(ORA_ROWSCN)
           22622685
    SQL> select scn_to_timestamp(max(ora_rowscn)) from emp;
    select scn_to_timestamp(max(ora_rowscn)) from emp
    ERROR at line 1:
    ORA-08181: specified number is not a valid system change number
    ORA-06512: at "SYS.SCN_TO_TIMESTAMP", line 1
    SQL> Anyway, based on SCN we can find out which BATCH of table row modifications was committed last. But you can't find out which modification withing that BATCH was made last.
    SY.

  • How to find out the aligning Data dictionary table for a structure.

    Hi
    As the table controls are associated with strucures, the data input goes to the data dictionary table aligned to that structure. Is there any way we can find out the table related to that particular structure ?
    Thanks,
    Dhareppa

    Hi,
    The structure and its fields may be associated with multiple database tables.
    You can try by where-used list of the structure/field and then you can look and determine the table by hit and try method.
    Also as suggested above you can try get the SQL trace and then ypu can look for table associated behind the structure/fields I believe this is the best way to find the DB table.
    Thanks,
    Ravi

  • How to find out the locks in the table

    Any query anybody have to find out locks in any table.

    Here is a version with SID and serial# data:
    set linesize 150;
    set head on;
    col sid_serial form a13
    col ora_user for a15;
    col object_name for a35;
    col object_type for a10;
    col lock_mode for a15;
    col last_ddl for a8;
    col status for a10;
    break on sid_serial;
    SELECT l.session_id||','||v.serial# sid_serial,
           l.ORACLE_USERNAME ora_user,
           o.object_name,
           o.object_type,
           DECODE(l.locked_mode,
              0, 'None',
              1, 'Null',
              2, 'Row-S (SS)',
              3, 'Row-X (SX)',
              4, 'Share',
              5, 'S/Row-X (SSX)',
              6, 'Exclusive',
              TO_CHAR(l.locked_mode)
           ) lock_mode,
           o.status,
           to_char(o.last_ddl_time,'dd.mm.yy') last_ddl
    FROM dba_objects o, gv$locked_object l, v$session v
    WHERE o.object_id = l.object_id
          and l.SESSION_ID=v.sid
    order by 2,3;

Maybe you are looking for