Insert values into a table from another table without duplicates

Hello

I have a table with a field called ID; This field has duplicate values of ID.

Then I have an empty table B (with the same fields of the table A) and I want to insert the values of the ID (on the table) without duplicates.

Can you help me?


Thank you much in advance.

Hello

If your table has duplicate values, then you cannot add a UNIQUE constraint. In this case, you will need to use a roundabout way or remove duplicates before imposing the constraint. Hope it answers your question.

see you soon

VT

Tags: Database

Similar Questions

  • Gears - error when you try to insert values into a table with multiple columns

    Hello

    I started playing with the gears and SQlLite today and I get an error when I try to insert values into a table with multiple columns.

    I have:

    var db = google.gears.factory.create('beta.database');
        db.open('developerSet');
        db.execute('create table if not exists Developers (DeveloperName text, DeveloperAge int)');
    
        var devName = "Davy"
        var devAge = 32;
    
        try {
            db.execute('insert into Developers values (?, ?)', [devName, devAge]);
            alert('success');
        }
        catch (e) {
            alert(e);
        }
    

    I get the error:

    net.rim.device.api.database.DatabaseException; insert into developers values (?,?): SQL logic error or missing database.

    I use this reference: http://code.google.com/apis/gears/api_database.html

    Everything works if I have only one field as:

    var db = google.gears.factory.create('beta.database');
        db.open('developerSet');
        db.execute('create table if not exists Developers (DeveloperName text)');
    
        var devName = "Davy"
        var devAge = 32;
    
        try {
            db.execute('insert into Developers values (?)', [devName]);
            alert('success');
        }
        catch (e) {
            alert(e);
        }
    

    I use the plug-in Visual Studio 2.0 for 2008 that are running Windows XP SP and Simulator 2.13.0.56

    Thank you

    Davy

    Yes, a SQLite database will persist between battery pulls.  The database is registered either to internal MEM or removable media (not the device memory), depending on which is available on your device.

    In general, its not considered a best practice to remove your table as soon as it is empty and re - create it again when you want to add data.  This adds extra overhead fresh for the final, delete and insert first for a given table.  Instead, define and finalize your drawing before you create your table.  Once created, review the static schema.

    That being said, for development purposes, it may be easier to provide an easy way to drop your tables while you develop your schema.

    See you soon,.

    Adam

  • table name not valid error when inserting values into a table

    I use the following statement to insert values into a table:

    curs. Execute ("INSERT INTO _ * '%s' * _ VALUES ((SELECT MAX (REC_ID) + 1 OF GSAP_MSG_IN), (SELECT MAX (gsap_msg_id) + 1 OF GSAP_MSG_IN), 'SHELLSAP', sysdate, '%s', EMPTY_BLOB(), 1, SYSDATE, EMPTY_BLOB (), SYSDATE)" %(*table_name*,file_extension)) ")

    whence table_name the following statement

    table_name = ' config.staging_db_tablesNames ['in_msgs]

    as I created a configuration file for all parameters that can change. The value of the table in the audit using a print command is correctly, but when put in the query above to run the insert statement gives an error. The following is the summary of comprehensive performance where you can see the table name as

    $ python gsapscnr.py
    Vote for the data files in/home/mh/inbox /...

    GSAP_MSG_IN
    Traceback (most recent call changed):
    File "gsapscnr.py", line 147, in it?
    poll_for_data()
    File "gsapscnr.py", line 86, in poll_for_data
    Sorter = load_details_first)
    File "gsapscnr.py", line 42, survey
    curs. Execute ("INSERT INTO '%s' VALUES ((SELECT MAX (REC_ID) + 1 OF GSAP_MSG_IN), (SELECT MAX (gsap_msg_id) + 1 OF GSAP_MSG_IN), 'SHELLSAP', sysdate, '%s', EMPTY_BLOB(), 1, SYSDATE, EMPTY_BLOB (), SYSDATE)" %(table_name,file_extension)) ")
    cx_Oracle.DatabaseError: ORA-00903: invalid table name

    Can anyone help with this problem please. I'm passing the value of the table in a bad way. Also if anyone can suggest a good tutorial for paythong programming using cx_Oracle.

    Concerning

    Print the SQL string that you establish, cut and paste it this output in SQL * more and see if it runs. This may show you that you should remove the single quotes around the name of the table %s in the Python file.

  • Problem inserting values into a table

    Hi all

    I'm newbe and I'm stack.
    I have a human tasks (model begun), which contains 4 input fields (all channels).
    I have a complex data type called Test, which is defined as 2 channel fileds (Description and result) and a registered number (test).
    I have a Test table, insiemiDiTest.
    What I want to do is to create 2 test object in the input fields and insert in the insiemiDiTest table, to then be able to use the loop to insert into the DB.
    Assume that the user insert the following information in the filed entry:
    INPUT1 descrTest1
    ResultTest1-INPUT2
    INPUT3 descrTest2
    INPUT4 resultTest2
    I want to play in the process of the insiemiDiTest variable of length 2 and the following content:
    insiemiDiTest [1] .testNumber = 1
    insiemiDiTest [1] .description = descrTest1
    insiemiDiTest [1] property = resultTest1
    insiemiDiTest [2] .testNumber = 2
    insiemiDiTest [2] .description = descrTest2
    insiemiDiTest [2] property = resultTest2

    If I use data binding and I have a link
    INPUT1 with .description insiemiDiTest [1]
    INPUT2 with property insiemiDiTest [1]
    Number('1') with .testNumber insiemiDiTest [1]
    I get an error saying that the insiemiDiTest [1] .description is empty and cannot be copied.

    Unfortunaly I can't directly use the table in the task of the user, because later I have to use the conversation when the calling process and we found I have limitation.
    I can get an indication on how to do it.
    I'm approccing in the right way or am I completely wrong?
    Thanks in advance and Merry Christmas.

    Because your input is coming from a few strings and not a table, you can just add a Script activity to your process and to define table of your target XSD using XML.

    To do this, you must add a Script to the activity-> click on "Data Associations"-> drag the icon above your target expression builder object on the right side (not the table but the table parent)-> open the XPath expression box in the Middle-> click 'XPath Exp' in the drop-down list at the top.

    I don't know what your XSD, but in the text below, I tried to show you the XML you need for this XPath expression using the values you provided.

    oraext:parseXML(concat('
    
      
        ','1','
        ',bpmn:getDataObject('descTest1'),'
        ',bpmn:getDataObject('resultTest1'),'
      
    
      
        ','2','
        ',bpmn:getDataObject('descTest2'),'
        ',bpmn:getDataObject('resultTest2'),'
      
    
    '))
    

    When I 'bpmn:getDataObject('...')', you should rather to insert your data object variables four your process chain.

    Hope this helps,
    Dan

  • API to insert values into the table of apps

    Hello

    I created a table with front end applications. Creating columns and rows. Now, I want to insert values in different columns of the corresponding lines.
    Can you get it someone please let me know the API that I can use here to insert the column values?

    Kind regards!

    If you want to insert data in the standard table oracle, then you must use the api instead, then apply the insert statement, this api oracle used to check the validation of the company etc.

    Regarding the concern with regard to insert the date as you said, this is why you should use this api 'PAY_USER_COLUMN_INSTANCE_API' to insert data in pl/sql script.

  • Insert data into the table without using the insert or select the command

    Hello

    Is there anyway to insert data from one table to another table, without using insert, and then select the command in the same pattern.
    Note: the two tables have the same structure.

    ALTER table... Swap partition...

  • How to insert values into a table

    Hello Experts,

    I would like to know if its possible to fill data in one table by performing a loop.

    I have the following table:
    Draw)
    NUMBER OF NUM,
    START_DATE DATE NOT NULL,
    END_DATE DATE NOT NULL,
    CHAR DEFAULT ACTIVE (1 BYTE) 'Y')

    Now my table must contain the foll:
    NUM start_date end_date active
    1 2010-01-23 21:00 30/01/2010 19:00 Y
    2 2010-01-30 21:00 02/06/2010 19:00 Y

    I have an initial date and the end_date is always (start_date + 7) and the beginning of the next by the previous end_date but time varies from 19:00 to 21:00.


    This is what I have at the moment, but I'm stuck out of
    CREATE SEQUENCE num_seq
    MINVALUE 1
    START WITH 1
    INCREMENT BY 1
    CACHE 10
    
    CREATE OR REPLACE procedure draw_date IS
    
    
    begin
    
    INSERT INTO draws
    (num,
    start_date ,
    end_date,
    active )
    VALUES
    (num_seq.nextval,
    ?,
    ?+7 days,
    Y);
    COMMIT;
    end;
    but I'm kind of stuck a bit for the date

    Thank you

    Hello

    You can try something like:

    INSERT INTO draws
    (num,
    start_date,
    end_date,
    active)
    with last_date as (select trunc(max(end_date)) dt from draws)
    select
    num_seq.nextval,
    last_date.dt + 21/24,
    last_date.dt +7 +19/24,
    'Y'
    from last_date;
    COMMIT;
    

    Untested code because I don't have the create table and insert orders... and I'm feeling lazy today.
    ;)

  • SQL script to insert values into a table based on the type of user

    Hello

    I have a requirement where I need to insert (username, groupname) in a table based on the user name.

    We have two types of user accounts:

    (1) user name, which starts with "DV" example: "DVPATM."

    regular user 2) example: 'PATM '.

    If the user name begins with "DV" under instruction insert should kick in

    insert into < tablename > (username, groupname) VALUES (< username > ' < groupname1 >).

    otherwise below insert statement should kick in

    insert into < tablename > (username, groupname) VALUES (< username > ' < groupname2 >).

    I need to use SQL or stored only procedure.

    Please suggest

    Thanks in advance

    All things being constant, you could use decode/case just for groupname by examining the first character t the user name, for example

    insert into (username, groupname) VALUES (, (substr ( , 1, 2) the case when "DV" then else end));

    Fixed edit: value for OTHERS, as noted by Frank

  • How to insert records into a table from a button?

    Hey,.

    I use Oracle form and I have a trigger button when button pressed.

    I have a project being given for one of my classes. Basically, I have a Customers table and they hit the news. When they press submit, it must insert it into the table.

    And here is the code I wrote to be inserted inside the button

    declare


    v_cust_id customer_detail.customer_id%type;

    v_f_name customer_detail.fname%type;

    v_l_name customer_detail.lname%type;

    v_destination customer_detail.destination%type;

    v_travel_date customer_detail.travel_date%type;

    v_address customer_detail.address%type;

    v_telephone customer_detail.telephone%type;


    Start

    insert into customer_detail

    values (v_customer_id, v_fname, v_l_name, v_destination, v_travel_date, v_address, v_telephone);

    end;

    /


    But its gives me an error. Is a PLsql Oracle form different syntax?

    Why do you need to insert in the command, when applications oracle has this native features?

    Make a form based on the table and just use

    COMMIT_FORM; on your BUTTON.

    Hope this helps

    Hamid

  • Doubt about inserting data into a table

    Hi all, when I try to insert data into a table through an anonymous block, the pl/sql block runs successfully, but the data are not get inserted. Can someone please tell me where I am doing wrong?
    SQL> DECLARE
      2
      3  V_A NUMBER;
      4
      5  V_B NUMBER;
      6
      7  v_message varchar2(25);
      8
      9
     10  BEGIN
     11
     12
     13  select regal.regal_inv_landed_cost_seq.NEXTVAL into V_A from dual ;
     14
     15  select regal.regal_inv_landed_cost_seq.currval into V_B from dual ;
     16
     17  INSERT INTO rcv_transactions_interface
     18  (
     19               INTERFACE_TRANSACTION_ID,
     20               HEADER_INTERFACE_ID,
     21               GROUP_ID,
     22               TRANSACTION_TYPE,
     23               TRANSACTION_DATE,
     24               PROCESSING_STATUS_CODE,
     25               PROCESSING_MODE_CODE,
     26               TRANSACTION_STATUS_CODE,
     27               QUANTITY,
     28               LAST_UPDATE_DATE,
     29               LAST_UPDATED_BY,
     30               CREATION_DATE,
     31               CREATED_BY,
     32               RECEIPT_SOURCE_CODE,
     33               DESTINATION_TYPE_CODE,
     34               AUTO_TRANSACT_CODE,
     35               SOURCE_DOCUMENT_CODE,
     36               UNIT_OF_MEASURE,
     37               ITEM_ID,
     38               UOM_CODE,
     39               EMPLOYEE_ID,
     40               SHIPMENT_HEADER_ID,
     41               SHIPMENT_LINE_ID,
     42               TO_ORGANIZATION_ID,
     43               SUBINVENTORY,
     44               FROM_ORGANIZATION_ID,
     45               FROM_SUBINVENTORY
     46  )
     47
     48  SELECT
     49       regal.regal_inv_landed_cost_seq.nextval,      --Interface_transaction_
    id
     50       V_A,                                          --Header Interface ID
     51       V_B,                                          --Group ID
     52       'Ship',                                       --Transaction Type
     53       sysdate,                                      --Transaction Date
     54       'PENDING',                                    --Processing Status Code
    
     55       'BATCH',                                      --Processing Mode Code
     56       'PENDING',                                    --Transaction Status Cod
    e
     57       lc.quantity_received,                          --Quantity
     58       lc.last_update_date,                          --last update date
     59       lc.last_updated_by,                           --last updated by
     60       sysdate,                                      --creation date
     61       lc.created_by,                                --created by
     62       'INVENTORY',                                  --Receipt source Code
     63       'INVENTORY',                                  --Destination Type Code
     64       'DELIVER' ,                                    --AUT Transact Code
     65       'INVENTORY',                                  --Source Document Code
     66        msi.primary_uom_code ,                       --Unit Of Measure
     67        msi.inventory_item_id,                        --Item ID
     68        msi.primary_unit_of_measure,                  --UOM COde
     69        fnd.user_id,
     70        V_A,                                         --Shipment Header ID
     71        V_B,                                         --SHipment Line ID
     72        82,                                           --To Organization ID
     73        'Brooklyn',                                     --Sub Inventory ID
     74        81,                                            --From Organization
     75        'Vessel'                                       --From Subinventory
     76
     77    FROM
     78       regal.regal_inv_landed_cost_tab lc,
     79       fnd_user fnd,
     80       mtl_system_items msi
     81
     82    WHERE
     83       lc.organization_id = msi.organization_id
     84       AND  lc.inventory_item_id = msi.inventory_item_id
     85       AND  lc.created_by = fnd.created_by;
     86
     87  commit;
     88  v_message := SQL%ROWCOUNT;
     89  dbms_output.put_line('v_message');
     90  END;
     91  /
    v_message
    
    PL/SQL procedure successfully completed.
    SQL> select * from rcv_transactions_interface;
    
    no rows selected
    Thanks in advance!

    There is no problem with inserting data!
    Only there is no data! This means that your select statement retrieves no rows.
    You can see the output of your program (0). This means that there where no line in the result set.

    Please check the output of your tax return independently:

    SELECT
    --        regal.regal_inv_landed_cost_seq.nextval,      --Interface_transaction_id
     --       V_A,                                          --Header Interface ID
    --        V_B,                                          --Group ID
            'Ship',                                       --Transaction Type
            sysdate,                                      --Transaction Date
            'PENDING',                                    --Processing Status Code
            'BATCH',                                      --Processing Mode Code
            'PENDING',                                    --Transaction Status Code
            lc.quantity_received,                          --Quantity
            lc.last_update_date,                          --last update date
            lc.last_updated_by,                           --last updated by
            sysdate,                                      --creation date
            lc.created_by,                                --created by
            'INVENTORY',                                  --Receipt source Code
            'INVENTORY',                                  --Destination Type Code
            'DELIVER' ,                                    --AUT Transact Code
            'INVENTORY',                                  --Source Document Code
             msi.primary_uom_code ,                       --Unit Of Measure
             msi.inventory_item_id,                        --Item ID
             msi.primary_unit_of_measure,                  --UOM COde
             fnd.user_id,
      --       V_A,                                         --Shipment Header ID
    --         V_B,                                         --SHipment Line ID
             82,                                           --To Organization ID
             'Brooklyn',                                     --Sub Inventory ID
             81,                                            --From Organization
             'Vessel'                                       --From Subinventory
         FROM
            regal.regal_inv_landed_cost_tab lc,
            fnd_user fnd,
            mtl_system_items msi
         WHERE
            lc.organization_id = msi.organization_id
            AND  lc.inventory_item_id = msi.inventory_item_id
            AND  lc.created_by = fnd.created_by;
    

    Published by: hm on 13.10.2011 23:19

    I removed the references of the sequence and the variables V_A and YaeUb.
    BTW: Why do you want to include V_A and YaeUb in two different columns?

    The use of sequences in your code seems a bit strange to me. But this has nothing to do with your question.

  • How to load the values into a table?

    In my jspx page, I have a combo and a table... Based on the values of the drop-down list, when I click on a button, I want to load the values into a table... The data in the table are from 5 database tables. I created a viewObject readonly... What to do to load the values from the table, I click on a button?

    Ensure that you have defined a variable to bind your view object.

    Read-only or not, this is what would make the Execute with action of parameters available.

    John

  • What trigger to use to insert data into the table db forms

    Hello

    My form is current having a block of database with the table reference. When you enter data into the form field and click Save. Automatically record is inserted in the database table.
    I want to do this under manual insert. I changed the block of data to a data non-base. Where should I write the insert statement to insert data into the table.
    Is - shutter release key of the form-level validation?

    Please notify.

    Thank you
    Didi.

    You can guide me how to remove the message FRM-40401 no changes to save and instead, I wanted to put 1 transaction record successful... some like it like that.

    Hi didi.
    And this is my last post I'll sleep. ;)
    Take form level trigger named preform
    and write on it

    :SYSTEM.MESSAGE_LEVEL := 5;
    

    I hope this works...

    Hamid

    Mark correct/good to help others to get the right answers. *

  • How to insert data into the table by using the expression builder in the assign activity

    How to insert data into the table by using the expression builder in affect business in BPEl, I use SOA Suite 11.1.1.5
    Can someone help me please

    Hello

    I don't think that oraext:query-database() can insert data into the table.

    What are your needs?
    Can not you plan to use the DB adapter with the insert operation?

    Kind regards
    Neeraj Sehgal

  • Insert data into Oracle DB from MS Access Forms

    Dear professionals,
    How to insert data into the table that reside in the Oracle DB through MS Access forms?
    We have already created ODBC link tables Oracle allows you to select data, and it works.
    Unfortunately, we can select only the data, but insert, delete and update are not available via MS Access form, even if the user has all permissions on the oracle DB (grant select, insert, update, delete on oracle_table to access_user).


    driver: Microsoft ODBC for Oracle
    MS Access 2003
    Oracle DB 10.2

    THX in advance,
    Adnan

    One would need to know what means "not available". You get a specific error? As far as I know your statement is simply incorrect.
    There are perhaps incompatibilties between DLLs Microsoft and Oracle, I would avoid the Microsoft ODBC for Oracle driver like the plague!

    ---------
    Sybrand Bakker
    Senior Oracle DBA

  • a table are in the other table without duplicate

    How to check the records in a table are in the other table without duplicate.

    for example, in the tables below, the records from the Table A are in Table B1. But the B2 table has duplicate and one record is missing.
    I want to know which records are not in table B, records that have two copies.
    as A and B2, 1 2 is not in B2, 1 1 a 2 folders in B2

    A and B1, nothing should be returned.

    Table A
    -----------
    A1 A2
    -----------
    1 1
    1 2
    1 3
    -----------

    Table B1
    -----------
    A1 A2
    -----------
    1 1
    1 4
    1 2
    1 3
    2 2
    -----------


    Table B2
    -----------
    A1 A2
    -----------
    1 1
    1 4
    1 3
    2 3
    1 1
    -----------

    version is the database of Oracle 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production

    Thank you!!

    Two standard methods to compare the tables are either to use DEFINED such as UNION, UNION operations or LESS.
    Or use a FULL OUTER JOIN.

    If the structure of the table is the same and that you want to compare all the columns, then set them operators are the best way.

    If you want to compare only on one or more columns and want to see the other columns, then a FULL OUTER JOIN is the best way.

    Here is an example

    select A1, A2,
          count(distinct sourcetable) cnt_tables,
          count(sourcetable) cnt_records,
          count(case when sourcetable = 'A'  then 1 end) record_is_in_A,
          count(case when sourcetable = 'B1'  then 1 end) record_is_in_B1,
          count(case when sourcetable = 'B2'  then 1 end) record_is_in_B2
       (select 'A' sourceTable, a.* from tableA a
        union all
        select 'B1' sourceTable, b1.* from tableB1 b1
        union all
        select 'B2' sourceTable, b2.* from tableB2 b2
       )
    group by A1, A2
    having  count(distinct sourcetable) < count(sourcetable) ;
    

    It is an example. It will show you the records that have duplicate data in the following tables.
    If you want to display all records that are in A but not in B1, you can add a few other checks.

    Published by: Sven w. on August 13, 2010 17:23

Maybe you are looking for

  • How can I sort the items in the toolbar of my favorites with a sort from A to Z order?

    I want to put the items in the toolbar of my favorites in order from a to z. When I click on "views" and "out", I select the sort order and then go to the bookmarks toolbar, which is not sorted by a - z - it's a jumble of names without order, a - z o

  • Passing array of large piles of CLN fails

    Hello I am trying to pass an array of clusters to a DLL, but it is not passed correctly. I spent a few similar to this (although smaller) clusters without any problems before, but somehow it doesn't line up properly or something. What I'm trying to d

  • Stuck at the screen of the POST - R500

    I have a R500 that one of my users has me just. It is stuck on the screen of the POST (ThinkPad splash) and does not respond to any keys pressed. I tried holding down the blue button "ThinkVantage" while turning on and still no response. I pulled the

  • HP Photosmart Premium C309a: uninstalled the driver, but can't re install even on HP C309a

    My device cannot scan and there is an error (could not insert the screenshot error). As recommended, I did uninstall the driver and appeared to be successful. But re - install is the problem here, first I downloaded the race online, saved, driver (PS

  • I try to see the photos sent to my email

    original title: see photos I'm seeing photos sent to my email.  They are just coming up with a little red box in the left corner and the name of the file (jpeg format).  How can I do so I can see these photos?