How to copy data from one table to another (in other database)

Hi. I would like to copy all rows from one table to another (and not use BC4J). Tables can be in various databases. I have already 2 connections and I am able to browse source table using
ResultSet rset = stmt.executeQuery("select ...");
But I would not like to create special insert statement for every row . There will be problems with date formats etc and it will be slow. Can I use retrieved ResultSet somehow ? Maybe with method insertRow, but how, if ResultSet is based on select statement and want to insert into target table? Please point me in the right direction. Thanks.

No tools please, it must be common solution. We suceeded in converting our BC4J aplication to PostgreSQL, the MSSQL will be next. So we want to write simple aplication, which could transfer data from our tables between these 3 servers.

Similar Messages

  • T code to Copy Data from one table to another table

    Hi,
    I want copy all data of one table to its copy table. Anyone knows transaction code to copy data from one table to another table.
    Regards,
    Jigar Thakkar.

    Hi
    Create a small program.
    Extract data from T1 - database table and put it in one internal table - itab1.
    loop the itab1 data .............
        insert itab1 into tab2.   (tab2 - second database table)
    endloop.
    try this....
    hope it works....

  • Copy data from one Table to another Table

    How can I copy data from one Oracle Table to another Oracle Table on a different server? Question 2: How can I clear all of the data in one Table with a single SQL script?
    Thanks...

    Question 1:
    I assume you have the privileges. If you don't, ask the DBA to give them to you. Then
    1. Login to database_source (It could be either the source or the target. Let's assume it's the source.)
    2. Create a database link to database_target: CREATE DATABASE LINK link_to_database_target CONNECT TO myuserid IDENTIFIED BY mypassword USING 'database_target'; Note the single quotes.
    3. Copy the table data: INSERT INTO targetowner.mytable@link_to_database_target SELECT * FROM sourceowner.mytable; COMMIT;
    Question 2:
    You have two options, but you may not have privileges for both.
    Option 1:
    DELETE FROM tableowner.tablename; COMMIT;
    Advantage: Since this is a DML (Data Manipulation Language) statement, you have to commit the transaction. Also, the data will be gone but the table size is NOT changed, so it's ready for accepting replacement data. DML statements can simply be executed not only from SQL scripts, but from PL/SQL scripts as well.
    Disadvantage: Slow, because all record deletion is logged, so you can recover from it by issuing a ROLLBACK; instead of the COMMIT; above. The table size is NOT changed, so if you are short of disk space or tablespace space, you have not resolved the issue.
    Option 2:
    TRUNCATE TABLE tableowner.tablename;
    Advantage: Since this is a DDL (Data Definition Language) command, you do NOT have to commit the transaction. (DDL commands automatically commit both before and after their execution.) The table size will be changed back to the initial extent size which is the minimum size a table can have and can only be set when the table is created. If it needs to be changed, the table has to be dropped and recreated with a different initial extent size. The statement execution of this command is not logged, therefore it's much faster then the DELETE.
    Disadvantage: No rollback. Being a DDL, this command cannot be executed straight from PL/SQL. If you need to issue this within PL/SQL, you will have to use dynamic SQL.

  • Copying data from one table to another table thru java

    Hi
    I have to copy data from table emp in Database A to table emp in Database B. My input would be table name and number of rows to be fetched. these rows i need to insert in table B.
    The problem over here is I won't be having any info. of table emp i.e the number of columns it has and their type.
    So is their any way i can copy the data from one table to other without having the info abt the number of cols and their type.
    TIA

    Cross post - http://forum.java.sun.com/thread.jspa?threadID=5169293&messageID=9649839#9649839

  • How to copy file from one table to another table at another database

    I need to transfer my tables from one workspace and schema to another workspace and schema. Basically I need to create again all the tables at this new schema. How could I transfer data from tha table at old schema to the table at new schema when this table has files stored in it? (data type is blob)
    thank you so much,
    Silver

    Hello Silver,
    Depending which database you're using (if it's available) I would recommend to use datapump.
    Datapump allows you to copy an entire schema to another database, it's the "new" export/import you might now.
    Regards,
    Dimitri
    http://dgielis.blogspot.com/
    http://www.apex-evangelists.com/
    http://www.apexblogs.info/
    REWARDS: Please remember to mark helpful or correct posts on the forum

  • Copy data from one table to another

    Hello everyone,
    I have a student table with fields sno, sname. I created another table student1 with same fields sno, sname and with one new field class.
    Now i want to copy data from sno, sname of student table to sno, sname of student1 table when the class field in styudent1 has no data i.e., its null.
    Could any one let me know how to do this?
    Thanks,
    Prathima

    i want to copy data from sno, sname of student table to sno, sname
    of student1 table when the class field in styudent1 has no dataSo what is the join condition? What column in STUDENT1 tells us what row in STUDENT to copy?
    Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/

  • How give a data from one table to another table

    Oracle forms6i
    Hai All
    I had two table in table data base and from one table the data has to move to another table using forms
    The two tables are
    First table name temp_att from this the data has to move and the data are
    BARCODE BARDATE BARTIME Row_number
    0000000009949296 08-NOV-09 0800 1
    0000000009949296 08-NOV-09 1230 2
    0000000009949296 08-NOV-09 1245 3
    0000000009949296 08-NOV-09 1645 4
    0000000009949297 08-NOV-09 0815 1
    0000000009949297 08-NOV-09 1230 2
    0000000009949297 08-NOV-09 1300 3
    0000000009949297 08-NOV-09 1650 4
    Another table dail_att and the fields are
    barcode,bardate,intime(mintime),outtime(maxtime),intrin(nextmintime)intr,(nextmaxtime)
    Pls give some solutions to solve this problem.
    Thanks & Regards
    Srikkanth.M

    Hai
    Could pls explain me little bit clear
    I have explained my problem clearly in the last Post
    This is the requirement
    I had two table in table data base and from one table the data has to move to another table using forms
    The two tables are
    First table name temp_att from this the data has to move and the data are
    BARCODE BARDATE BARTIME Row_number
    0000000009949296 08-NOV-09 0800 1
    0000000009949296 08-NOV-09 1230 2
    0000000009949296 08-NOV-09 1245 3
    0000000009949296 08-NOV-09 1645 4
    0000000009949297 08-NOV-09 0815 1
    0000000009949297 08-NOV-09 1230 2
    0000000009949297 08-NOV-09 1300 3
    0000000009949297 08-NOV-09 1650 4
    Another table dail_att and the fields are
    barcode,bardate,intime(mintime),outtime(maxtime),intrin(nextmintime)intr,(nextmaxtime)
    Pls give some solutions to solve this problem.
    Thanks & Regards
    Srikkanth.M

  • How to copy data from one BB to another via Desktop Manager

    I've got two BBs (8900 and 9300), both actively in use and with different data (contacts, memos, etc.) on them.
    I need to copy my tasks, memos and contacts from 8900 to 9300. I tried "switch phones" option, but it substitutes data, while I need to syncronize it, so that data from 8900 is added to what is currently is on the 9300. 
    Is it possible to do it via Desktop Manager? It seems there was somewhere an option "copy data from another BB", but I can't find it in the latest Desktop Manager version.

    You would need to use Desktop Mangaer to sync BB1 with a local PIM program (such as Outlook or Lotus Notes) to get the information off BB1. Then use Desktop Manager to sync BB2 with the same PIM program. 

  • How to copy data from one node to another or fromone table to another table

    Hi,
    I have a two tables.I am populating data in first table and on the click of first table ,selected row data should be copied to the second table.
    How do i achieve this requirement and what should be the cardinality of the second table
    Thanks
    Bala Duvvuri

    Hi,
    For this u have to fetch the selected row.
    For fetching the selected row go to the events of first table and select "OnLeadselect".
    Create a new method for this.
    Now in this method read the value of the selected row with method get_static_attributes.
    with this u will have the selected row in the element.
    not just bind this elemnt with the second table.
    Second node will also have the cardinality 0:n, because this is also binded with the table.
    Coding part for this is as below:
    method ONACTIONSELECT .
        DATA lo_nd_cn_mara TYPE REF TO if_wd_context_node.
        DATA lo_el_cn_mara TYPE REF TO if_wd_context_element.
        DATA ls_cn_mara TYPE wd_this->element_cn_mara.
        DATA ls_cn_mara1 TYPE wd_this->elements_cn_mara.
      navigate from <CONTEXT> to <CN_MARA> via lead selection
        lo_nd_cn_mara = wd_context->get_child_node( name = wd_this->wdctx_cn_mara ).
      @TODO handle not set lead selection
        IF lo_nd_cn_mara IS INITIAL.
        ENDIF.
      get element via lead selection
        lo_el_cn_mara = lo_nd_cn_mara->get_element(  ).
      @TODO handle not set lead selection
        IF lo_el_cn_mara IS INITIAL.
        ENDIF.
      alternative access  via index
      lo_el_cn_mara = lo_nd_cn_mara->get_element( index = 1 ).
      @TODO handle non existant child
      IF lo_el_cn_mara IS INITIAL.
      ENDIF.
      get all declared attributes
        lo_el_cn_mara->get_static_attributes(
          IMPORTING
            static_attributes = ls_cn_mara ).       " here u are getting the selected row of the table.
    APPEND ls_cn_mara to ls_cn_mara1.      " append the row in the table so that can be binded with the second node
      DATA lo_nd_cn_maraout TYPE REF TO if_wd_context_node.
      DATA lo_el_cn_maraout TYPE REF TO if_wd_context_element.
      DATA ls_cn_maraout TYPE wd_this->element_cn_maraout.
    navigate from <CONTEXT> to <CN_MARAOUT> via lead selection
      lo_nd_cn_maraout = wd_context->get_child_node( name = wd_this->wdctx_cn_maraout ).
    Bind the table with the second node
    lo_nd_cn_maraout->bind_table( ls_cn_mara1 ).
    endmethod.
    ->cn_mara  is the first node.
    ->cn_mara1  is the second node
    Thanks,
    Pankaj Aggarwal
    Edited by: Pankaj Aggarwal on Nov 19, 2008 7:40 AM

  • Copying data from one table to another, but not duplicate

    Good afternoon!
    I am new to Oracle SQL, I have a difficulty.
    I have a script that copies or add another table with data from another table.
    If the table already has 01 "Registry 01" when you make a copy of the data in table 02, can not duplicate the "Registry 01" again.
    As the table already exists since the beginning of the year before last and duplicate information, I can not apply the UNIQUE constraint because of the error. I have to make this change from now.
    How to perform this validation so that no duplicate data?
    DECLARE
    w_cont NUMBER;
    CURSOR c_simpro IS
    SELECT sc.cd_simpro,
    sc.ds_produto,
    sp.qt_embalagem,
    MAX(sp.dt_vigencia)
    FROM simpro_cadastro sc,
    simpro_preco sp
    WHERE sc.cd_simpro = sp.cd_simpro
    GROUP BY sc.cd_simpro,
    sc.ds_produto,
    sp.qt_embalagem;
    BEGIN
    FOR r_simpro IN c_simpro LOOP
    w_cont := 0;
    SELECT COUNT(1)
    INTO w_cont
    FROM pls_material pm
    WHERE pm.cd_material_ops = r_simpro.cd_simpro;
    IF w_cont = 0 THEN
    INSERT INTO pls_material(nr_sequencia,
    dt_atualizacao,
    nm_usuario,
    dt_atualizacao_nrec,
    nm_usuario_nrec,
    ie_tipo_despesa,
    cd_estabelecimento,
    nr_seq_estrut_mat,
    cd_simpro,
    ds_material,
    ie_situacao,
    ds_material_sem_acento,
    dt_inclusao,
    cd_material_ops_orig,
    cd_unidade_medida,
    cd_material_ops,
    qt_conversao_simpro)
    VALUES(pls_material_seq.nextval,
    SYSDATE,
    'ES-SIMPRO',
    SYSDATE,
    'ES-SIMPRO',
    3,
    1,
    3,
    r_simpro.cd_simpro,
    r_simpro.ds_PRODUTO,
    'A',
    r_simpro.ds_PRODUTO,
    SYSDATE,
    r_simpro.cd_simpro,
    'un',
    TRIM(to_char(r_simpro.cd_simpro,'0000099999')),
    r_simpro.qt_embalagem);
    COMMIT;
    END IF;
    IF w_cont > 0 THEN
    UPDATE pls_material p
    SET p.qt_conversao_simpro = r_simpro.qt_embalagem,
    p.dt_atualizacao = SYSDATE
    WHERE p.cd_simpro = r_simpro.cd_simpro;
    COMMIT;
    END IF;
    END LOOP;
    END;
    Edited by: 983464 on 22/01/2013 10:30

    Hi,
    in addition to what Marwin has already said, I suggest you to post CREATE TABLE and INSERT statements (as mentioned in the FAQ).
    The error you are getting from MERGE command is because you need a way to uniquely identify within the table. So it's is important to know also if your table has a primary key/unique index so the keys could to be used in the MERGE command.
    Additionally when you put some code or output please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Copying data from one table to another

    Hello!
    I have a table (TABLE1) and I want to copy part of TABLE1's data to an another table (TABLE2).This proccess is made by an application in PROC Language with ORACLE 8.1 in UNIX environment.
    1) I've tried to make the copy with a cursor:
    void search() {
    char alias[ALIASTAM];
    struct tpNoticia noticia;
    printf("Introduzca el nombre del autor: ");
    scanf("%s",alias);
    EXEC SQL DECLARE AUX CURSOR FOR
    SELECT idNoticia,titulo,texto,TO_CHAR(publicacion,'HH24:MI:SS DD-MM-YYYY'),
                        URLimagen,numVisitas,sumaVal,totalVal,esBorrador,alias,nombreT
    FROM TABLE1
         WHERE alias=:alias;
    EXEC SQL OPEN AUX;
    EXEC SQL WHENEVER NOT FOUND DO break;
    for (;;) {
    EXEC SQL FETCH AUX INTO :noticia;
    printf("%d %s \n", noticia.idNoticia,noticia.titulo);
    EXEC SQL INSERT INTO TABLE2 (idNoticia,titulo,texto,publicacion,URLimagen,numVisitas,sumaVal,totalVal,esBorrador,alias,nombreT)
    VALUES (:(noticia.idNoticia),:(noticia.titulo),:(noticia.texto), TO_DATE('00:00:00 01-01-1900','HH24:MI:SS DD-MM-YYYY'),:(noticia.URLimagen),:(noticia.numVisitas),
         :(noticia.sumaVal),:(noticia.totalVal),:(noticia.esBorrador),:(noticia.alias),:(noticia.nombreT));
    EXEC SQL CLOSE AUX;     
    IN THIS CURSOR printf SHOWS CORRECTLY THE DATA BUT IT ISN'T INSERTED INTO TABLE 2;
    2) I've tried to define TABLE2 from TABLE1:
    EXEC SQL CREATE TABLE TABLE2 AS
    SELECT * FROM TABLE1 WHERE alias=:alias
    BUT MY COMPILER SAYS: PCC-S-02206, Host variables are not permitted within a DDL statement
    ANY IDEA???
    Thanks

    If you want to create the table dynamically, then you have to use dynamic Sql. Didn't you like my above suggestion ? If you want I can post a small example of a similar stored procedure.
    See also http://www.mcs.csuhayward.edu/support/oracle/doc/8.1.7/appdev.817/a76942/pc_07pls.htm#2778

  • How to transfer data from one table to another without duplicates

    This is what I use to quote bathroom remodels. The first thing I do is completely fill in the Master Item List with every Product or Service we can think of to do the project. The Type column has a pop-up menu which includes Combo because some Contractors don't separate the Product from Labor. The Category Totals Table is useful but since some Contractors provide Product and Service at the same time on one invoice I don't get accurate breakdowns for generating my invoices.
    What I would like is to transfer all Vendor names included in the project to the Vendor Totals Table but without any duplicates. Some Contractors might perform services in several categories. I've read many listings in the forum and am just not seeing the answer.
    I have a sample file ready to send. I don't see a way to send it with this message. First Post! Sorry!
    Thank You
    Jeff

    jwoods007 wrote:
    What I would like is to transfer all Vendor names included in the project to the Vendor Totals Table but without any duplicates.
    Hi Jeff,
    Welcome to Apple Discussions and the Numbers '09 forum.
    If your Vendor names (including duplicates) are all in the same column of the source table, it shouldn't be difficult to transfer them to a second table using the technique described below.
    For the example, the source table is named Main and has one header row, the Vendors are listed in column C (starting at C2), and column B is used as an index column. Note that to use VLOOKUP, the index column must be to the left of the Vendor column.
    The index is generated using the following formula in B2, and filled down to the end of the column:
    =IF(COUNTIF(C$1:C2,C)=1,MAX($B$1:B1)+1,"")
    On the second table, Vendor List, the following formula is used in Column A (starting at A2) to collect the indexed vendors from the Main table"
    =IFERROR(VLOOKUP(ROW()-1,Main :: B:C,2,FALSE),"")
    IFERROR is used to trap the "couldn't find" error in the 'empty' rows of Vendor List.
    'FALSE' displays as "exact-match" in the formula, and prevents the rpeated listing of the last vendor that would be created by 'close-match'.
    Regards,
    Barry

  • Insert old missing data from one table to another(databaase trigger)

    Hello,
    i want to do two things
    1)I want to insert old missing data from one table to another through a database trigger but it can't be executed that way i don't know what should i do in case of replacing old data in table_1 into table_2
    2)what should i use :NEW. OR :OLD. instead.
    3) what should i do if i have records exising between the two dates
    i want to surpress the existing records.
    the following code is what i have but no effect occured.
    CREATE OR REPLACE TRIGGER ATTENDANCEE_FOLLOWS
    AFTER INSERT ON ACCESSLOG
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    V_COUNT       NUMBER(2);
    V_TIME_OUT    DATE;
    V_DATE_IN     DATE;
    V_DATE_OUT    DATE;
    V_TIME_IN     DATE;
    V_ATT_FLAG    VARCHAR2(3);
    V_EMP_ID      NUMBER(11);
    CURSOR EMP_FOLLOWS IS
    SELECT   EMPLOYEEID , LOGDATE , LOGTIME , INOUT
    FROM     ACCESSLOG
    WHERE    LOGDATE
    BETWEEN  TO_DATE('18/12/2008','dd/mm/rrrr') 
    AND      TO_DATE('19/12/2008','dd/mm/rrrr');
    BEGIN
    FOR EMP IN EMP_FOLLOWS LOOP
    SELECT COUNT(*)
    INTO  V_COUNT
    FROM  EMP_ATTENDANCEE
    WHERE EMP_ID    =  EMP.EMPLOYEEID
    AND    DATE_IN   =  EMP.LOGDATE
    AND    ATT_FLAG = 'I';
    IF V_COUNT = 0  THEN
    INSERT INTO EMP_ATTENDANCEE (EMP_ID, DATE_IN ,DATE_OUT
                                ,TIME_IN ,TIME_OUT,ATT_FLAG)
         VALUES (TO_NUMBER(TO_CHAR(:NEW.employeeid,99999)),
                 TO_DATE(:NEW.LOGDATE,'dd/mm/rrrr'),       -- DATE_IN
                 NULL,
                 TO_DATE(:NEW.LOGTIME,'HH24:MI:SS'),      -- TIME_IN
                 NULL ,'I');
    ELSIF   V_COUNT > 0 THEN
    UPDATE  EMP_ATTENDANCEE
        SET DATE_OUT       =  TO_DATE(:NEW.LOGDATE,'dd/mm/rrrr'), -- DATE_OUT,
            TIME_OUT       =   TO_DATE(:NEW.LOGTIME,'HH24:MI:SS'), -- TIME_OUT
            ATT_FLAG       =   'O'
            WHERE EMP_ID   =   TO_NUMBER(TO_CHAR(:NEW.employeeid,99999))
            AND   DATE_IN <=  (SELECT MAX (DATE_IN )
                               FROM EMP_ATTENDANCEE
                               WHERE EMP_ID = TO_NUMBER(TO_CHAR(:NEW.employeeid,99999))
                               AND   DATE_OUT IS NULL
                               AND   TIME_OUT IS NULL )
    AND   DATE_OUT  IS NULL
    AND   TIME_OUT IS NULL  ;
    END IF;
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN RAISE;
    END ATTENDANCEE_FOLLOWS ;
                            Regards,
    Abdetu..

    INSERT INTO SALES_MASTER
       ( NO
       , Name
       , PINCODE )
       SELECT SALESMANNO
            , SALESMANNAME
            , PINCODE
         FROM SALESMAN_MASTER;Regards,
    Christian Balz

  • How to copy data from transparent table to our own ceated z table?

    How to copy data from transparent table to our own ceated z table?
    Plz tell me different methods and which one is best?
    Is get data from sflight into table z* is correct?

    Hi Ajay,
    let us consider you have to copy EKKO table to ZEKKO table
    1. In ABAP program define internal table based on EKKO
    <b>     eg: i_ekko</b>
    2. Select the data from EKKO to i_ekko
    <b>     eg: select * from ekko into table i_ekko.</b>
    3. insert into Z-TABLE from the internal table
    <b>     eg: INSERT EKKO FROM TABLE I_EKKO.
               COMMIT WORK.</b>
    <u>To insert in internal table you can use the following:</u>
    1. INSERT [wa INTO|INITIAL LINE INTO] itab [INDEX idx].
    2. INSERT [wa INTO|INITIAL LINE INTO] TABLE itab.
    3. INSERT LINES OF itab1 [FROM idx1] [TO idx2] INTO itab2 [INDEX idx3].
    4. INSERT LINES OF itab1 [FROM idx1] [TO idx2] INTO TABLE itab2.
    <u>To inert in database table, use the following:</u>
    1. INSERT INTO <dbtabname> [CLIENT SPECIFIED] VALUES wa.
    2. INSERT <dbtabname> [CLIENT SPECIFIED] FROM TABLE itab.
    3. INSERT <dbtab> [CLIENT SPECIFIED]. oder
    4. INSERT <dbtabname> [CLIENT SPECIFIED] ... .
    <b>Reward points.. if helpful.
    Cheers !
    Moqeeth.</b>

  • Adding Data From One Table to Another

    Now, this doesn't strike me as a particularly complex problem, but I've either strayed outside the domain of Numbers or I'm just not looking at the problem from the right angle. In any case, I'm sure you guys can offer some insight.
    What I'm trying to do is, essentially, move data from one table to another. One table is a calendar, a simple two column 'date/task to be completed' affair, the other is a schedule of jogging workouts, i.e, times, distances. Basically, I'm trying to create a formula that copies data from the second table onto the first but only for odd days of the week, excepting Sundays (and assuming Monday as the start of the week). Now, this isn't the hard part, I can do that. The problem comes when I replicate the formula down the calendar. Even on the days when the 'if' statement identifies it as an 'even day', the cell reference to the appropriate workout on the second table is incremented, so when it comes to the next 'odd day', it has skipped a workout.
    I can't seem to see any way of getting it to specifically copy the NEXT line in the second table, and not the corresponding line.
    This began as a distraction to try and organise my running so I could see at a glance what I had to do that day and track my progress, but now it's turned into an obsession. SURELY there's a solution?
    Cheers.

    Hi Sealatron,
    Welcome to Apple Discussions and the Numbers '09 forum.
    Several possible ways to move the data occur to me, but the devil's in the details of how the data is currently arranged.
    Is it
    • a list of three workouts, one for each of Monday, Wednesday and Friday, then the same three repeated the following week?
    • an open-ended list that does not repeat?
    • something else?
    Regards,
    Barry

Maybe you are looking for