How to move data between two similar tables?

Hi All,
I have two tables with almost the same columns. Table A has 50 columns, Table B has 51 columns, which are defined exactly the same except one more column as LOAD_TIME.
Is there any easy way for me to move the data from Table A to B? the Extra column LOAD_TIME will be set as current system time. All I want is to avoid list all 50 column names. The following SQL has error ORA-00923 error.
INSERT INTO TB_B
SELECT *, sysdate from TB_A;
Thanks,

939569 wrote:
Hi All,
I have two tables with almost the same columns. Table A has 50 columns, Table B has 51 columns, which are defined exactly the same except one more column as LOAD_TIME.
Is there any easy way for me to move the data from Table A to B? the Extra column LOAD_TIME will be set as current system time. All I want is to avoid list all 50 column names. The following SQL has error ORA-00923 error.
INSERT INTO TB_B
SELECT *, sysdate from TB_A;
Thanks,You could create a view based on TB_A.
However i don't understand why you feel the need to avoid specifying the columns. That's a better way to code.
Granted, i also don't understand why you'd have 2 copies of the same data, the only differentiation being when you copied the data from the source to the redundant table.
Cheers,

Similar Messages

  • Cann't move data between two internal table in Unicode program

    Hello expert,
    I import a program from old sap system to new system, but syntax error occurred --- ' L_T_S776[] = T_DATA_RECORDS[]. ',
    it is said ' internal table L_T_S776 and T_DATA_RECORDS are not mutually convertible, in unicode program, two internal tables must have the same structure layout'.
    The coding is:
    DATA: L_T_S776 LIKE S776 OCCURS 0 WITH HEADER LINE.
    DATA: L_T_S777 LIKE S777 OCCURS 0 WITH HEADER LINE.
    FIELD-SYMBOLS: <F_S776> TYPE S776.
    FIELD-SYMBOLS: <F_S777> TYPE S777.
    IF NOT ZCL_USEREXIT=>IS_ACTIVE( PROJN = 11 EXITN = 34 ) IS INITIAL.
      CASE I_RMCP2-SCTYP.
        WHEN 'Z776'.
          L_T_S776[] = T_DATA_RECORDS[].
          LOOP AT L_T_S776 ASSIGNING <F_S776>.
            <F_S776>-ZZCUSER = SY-UNAME.
            <F_S776>-ZZCDATE = SY-DATUM.
            <F_S776>-ZZCTIME = SY-TIMLO.
          ENDLOOP.
         T_DATA_RECORDS[] = L_T_S776[].
        WHEN OTHERS.
      ENDCASE.
    internal table T_DATA_RECORDS is defined to like INDX.
    this program is in function module EXIT_SAPMMCP6_011, it is a user_exit.
    I also confuse the meaning of this part of coding, could anybody help me?
    reward if got useful reply, thank you.
    H.B

    Hi,
    The structure are different thats why you getting this error. But there must be some fields common to which you want to move data. So you change in that way.
    And there will be no impact whatsoever because of such change.
    Regards,
    Atish

  • How to move data from a staging table to three entity tables #2

    Environment: SQL Server 2008 R2
    I have a few questions:
    How would I prevent duplicate records, when/ IF SSIS is executed many times?
    How would I know that all huge volume of data being loaded in the entity tables?
    In reference to "how to move data from a staging table to three entity tables ", since I am loading large volume of data, while using lookup transformation:
    which of the merge components is best suited.
    How to configure merge component correctly. (screen shot is preferred) 
    Please refer to the following link
    http://social.msdn.microsoft.com/Forums/en-US/5f2128c8-3ddd-4455-9076-05fa1902a62a/how-to-move-data-from-a-staging-table-to-three-entity-tables?forum=sqlintegrationservices

    You can use RowCount transformation in the path where you want to capture record details. Then inside rowcount transformation pass a integer variable to get count value inside
    the event handler can be configured as below
    Inside Execute SQL task add INSERT statement to add rowcount to your audit table
    Can you also show me how to Check against destination table using key columns inside a lookup task and insert only non
    matched records (No Match output)
    This is explained clearly in below link which Arthur posted
    http://www.sqlis.com/sqlis/post/Get-all-from-Table-A-that-isnt-in-Table-B.aspx
    For large data I would prefer doing this in T-SQL. So what you could do is dump data to staging table and then apply
    T-SQL MERGE between tables (or even a combination of INSERT/UPDATE statements)
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Intervals, synchronize the data between two oracle tables located in diffe

    Hi Experts,
    Is there any way I can, at set intervals, synchronize the data between two oracle tables located in different servers? What is the software, if there is any? If there are steps I can follow, so much the better.
    Thanks!

    I'm not sure what you want to achieve here...
    I want to synchronize both the Servers , so that it can update HO servers as well as Factory Server with the complete data. Could you please elaborate a little bit more; basing on your description I could also tell you how to setup timesync for those two servers if I understand "complete data" as the current date and time...
    Also a lot of solutions are platform and version specific so it would help if you could indicate OS and Database Versions (4 digit).
    And I still fail to see what this has to do with forms. You might want to post your question to the Database General forum: General Database Discussions
    cheers

  • How to pass data between two internal sessions using ABAP memory?

    Hi,
    How to pass data between two internal sessions using ABAP memory?
    It would be fine if you could explain with an example.
    And also let me clear about the data passing between two main sessions and two external sessions with specific examples.
    Thanks.

    Hi ,
      check the example.
    Reading Data Objects from Memory
    To read data objects from ABAP memory into an ABAP program, use the following statement:
    Syntax
    IMPORT <f1> [TO <g 1>] <f 2> [TO <g 2>] ... FROM MEMORY ID <key>.
    This statement reads the data objects specified in the list from a cluster in memory. If you do not use the TO <g i > option, the data object <f i > in memory is assigned to the data object in the program with the same name. If you do use the option, the data object <f i > is read from memory into the field <g i >. The name <key> identifies the cluster in memory. It may be up to 32 characters long.
    You do not have to read all of the objects stored under a particular name <key>. You can restrict the number of objects by specifying their names. If the memory does not contain any objects under the name <key>, SY-SUBRC is set to 4. If, on the other hand, there is a data cluster in memory with the name <key>, SY-SUBRC is always 0, regardless of whether it contained the data object <f i >. If the cluster does not contain the data object <f i >, the target field remains unchanged.
    In this statement, the system does not check whether the structure of the object in memory is compatible with the structure into which you are reading it. The data is transported bit by bit. If the structures are incompatible, the data in the target field may be incorrect.
    PROGRAM SAPMZTS1.
    DATA TEXT1(10) VALUE 'Exporting'.
    DATA ITAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
    DO 5 TIMES.
      ITAB-BOOKID = 100 + SY-INDEX.
      APPEND ITAB.
    ENDDO.
    EXPORT TEXT1
           TEXT2 FROM 'Literal'
      TO MEMORY ID 'text'.
    EXPORT ITAB
      TO MEMORY ID 'table'.
    SUBMIT SAPMZTS2 AND RETURN.
    SUBMIT SAPMZTS3.
    The first part of this program is the same as the example in the section Saving Data Objects in Memory. In the example, the programs SAPMZTS1 and SAPMZTS2 are called using SUBMIT. You can create and maintain the programs called using the SUBMIT statement by double-clicking their names in the statement. For further information about the SUBMIT statement, refer to Calling Executable Programs (Reports)
    Example for SAPMZTS2:
    PROGRAM SAPMZTS2.
    DATA: TEXT1(10),
          TEXT3 LIKE TEXT1 VALUE 'Initial'.
    IMPORT TEXT3 FROM MEMORY ID 'text'.
    WRITE: / SY-SUBRC, TEXT3.
    IMPORT TEXT2 TO TEXT1 FROM MEMORY ID 'text'.
    WRITE: / SY-SUBRC, TEXT1.
    Example for SAPMZTS3:
    PROGRAM SAPMZTS3.
    DATA JTAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
    IMPORT ITAB TO JTAB FROM MEMORY ID 'table'.
    LOOP AT JTAB.
      WRITE / JTAB-BOOKID.
    ENDLOOP.
    The output is displayed on two successive screens. It looks like this:
    and
    The program SAPMZTS2 attempts to read a data object TEXT3 from the data cluster "text", which does not exist. TEXT3 therefore remains unchanged. The existing data object TEXT2 is placed in TEXT1. In both cases, SY-SUBRC is 0, since the cluster "text" contains data.
    The program SAPMZTS3 reads the internal table ITAB from the cluster "table" into the internal table JTAB. Both tables have the same structure, namely that of the ABAP Dictionary table SBOOK.
    Pls. reward if useful.....

  • How to move data from 2 internal table to 1 internal table

    Can any body send me code that how to move data from 2 internal table into one internal table.
    Moderator message : Read ABAP documentation. Thread locked.
    Edited by: Vinod Kumar on Jun 13, 2011 11:45 AM

    Hi Mohdarif92;
    I don't know your full needs. But general method should be as below code.
    Please check exam below code.
    Best regards.
    data : begin of gt_result.
                ... like mkpf-...
                ... like mkpf-...
                ... like mseg-...
                ... like mseg-...
              end of gt_result
    select *
    into table gt_mkpf
    from mkpf where ...
    select *
    into table mseg
    from mseg where ...
    loop at gt_mkpf.
         loop at gt_mseg where ... = mkpf-...
            move-corresponding gt_mkpf to gt_result.
            move-corresponding gt_mseg to gt_result.
            append gt_result
         endloop.
    endloop.

  • How to separate data between two colons

    Hi,
    how to separate data between two colons?
    ex: 'ABC:1234:1-ss-2:0:0:0:0-DEF:5678:0:0:0:0'
    how to access these 1234, 5678 and 1-ss-2 ?
    there may be any string.
    please help

    Hi,
    The string 'ABC:1234:1-ss-2:0:0:0:0-DEF:5678:0:0:0:0' contains 11 colons, and 10 sub-strings that are between colons. How do you distinguish the ones you want,
    (1) 1234
    (7) 5678
    (2) 1-ss-2
    from the ones you don't want
    (3) 0
    (4) 0
    (5) 0
    (6) 0-DEF
    (8) 0
    (9) 0
    (10) 0
    Anyhow, in Oracle 10 (and up) you can easily get the n-th item from a :-delimited list by saying:
    REGEXP_SUBSTR ( txt
                  , '[^:]+
                  , 1
                  , n
                  )First use REGEXP_REPLACE to remove anything before the first colon and anything after the last one.

  • How to compare data between two tables?

    Hi,
    My team is trying to develop a SAP data migration tool (DMT) using ABAP.
    One of the functionalities in the DMT is to validate the data in the staging area against the loaded SAP data.
    The tables in the stagin area are customer tables (i.e. user-defined tables starting with Y, Z).
    How do I compare the data in the staging area against data that are loaded into SAP tables? Are there some built-in SAP functions to do this? Or, are there some better ways of doing this (e.g. instead of comparing against data in the SAP tables, we compare with some INTERNAL tables)?
    Any help would be greatly appreciated, thanks!

    Hi Kian,
    Use <b>SCMP</b> transaction to compare data between two tables and you can not use this for comparing internal tables.
    Thanks,
    Vinay

  • Oracle-java How to fetch data between two Timestamps

    hai...
    I am using a program where i have to get all the data entered into oracle db between two dates
    (The first date being manually inputted and the second one is inputdate-24hrs) . The code is as follows....
    Connection c = null;
    PreparedStatement pStmt = null;
    ResultSet rs = null;
    try
    //eg  String dt=14/03/2007, hr=03, min=27, ampm=am
         DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
         DateFormat outForm = new SimpleDateFormat("yyyy/MM/dd");
         Calendar cl = Calendar.getInstance();
         Date inDate = new Date();
         inDate = dateFormat.parse(dt);
         cl.setTimeInMillis(inDate.getTime());
         cl.add(Calendar.DAY_OF_MONTH, -1);
         String str1 = outForm.format(new Date(cl.getTimeInMillis()));
         String str2 = outForm.format(dateFormat.parse(dt));
         System.out.println("Changed date = "+str1);
         System.out.println("Original date = "+str2);
         String toStr = str2+" "+hr+":"+min+" "+ampm.toUpperCase();
         String fromStr = str1+" "+hr+":"+min+" "+ampm.toUpperCase();
         System.out.println("From date = "+fromStr);
         System.out.println("To date = "+toStr);
    // For example, if u r confused, From date = 2007/03/14 03:27 AM
    //                            To date = 2007/03/13 03:27 AM
         String sql = "SELECT TRANS_ID, TO_CHAR(CONCAT('Rs.',TRANS_VALUE)) AS TRANS_VALUE, " +
                   "TO_CHAR(TRANS_DATE,'DD/MM/YYYY HH:MM AM') AS TRANS_DATE, ACCOUNT_ID,  " +
                   "TO_CHAR(CREATED_DATE,'DD/MM/YYYY HH:MM AM') AS CREATED_DATE, CREATED_BY, " +
                   "INSTR_D_BANK_CD FROM TRANS_TB WHERE " +
                   "ACCOUNT_ID=? AND TO_CHAR(TRANS_DATE,'YYYY/MM/DD HH:MM AM') " +
                   "BETWEEN ? AND ? ;
         c=ds.getConnection();
         pStmt = c.prepareStatement(sql);
         pStmt.setString(1, accountId);
         pStmt.setString(2, fromStr);
         pStmt.setString(3, toStr);               
         rs = pStmt.executeQuery();     
    }The problem is that i am not getting results as expected
    Can anyone point out if there is something wrong in the logic or in the program....

    But how to make that string to the Timestamp object.
    I tried this way but failed !!!
    // Eg :fromStr = 2007/03/14 03:27 AM
    //       toStr= 2007/03/13 03:27 AM
         SimpleDateFormat sdfOutput = new SimpleDateFormat("yyyy/MM/dd hh:mm a");
         Date fromDate = sdfOutput.parse(fromStr);
         Date toDate = sdfOutput.parse(toStr);
    SELECT TRANS_ID, TO_CHAR(CONCAT('Rs.',TRANS_VALUE)) AS TRANS_VALUE, " +
                   "TO_CHAR(TRANS_DATE,'DD/MM/YYYY HH:MM AM') AS TRANS_DATE, ACCOUNT_ID,  " +
                   "TO_CHAR(CREATED_DATE,'DD/MM/YYYY HH:MM AM') AS CREATED_DATE, CREATED_BY, " +
                   "INSTR_D_BANK_CD FROM TRANS_TB WHERE " +
                   "ACCOUNT_ID=? AND TRANS_DATE BETWEEN ? AND ? ;
    //Eg TRANS_DATE = "11-MAR-07 12.30.59.729000000 PM"(Timestamp)
    c=ds.getConnection();
         pStmt = c.prepareStatement(sql);
         pStmt.setString(1, accountId);
         pStmt.setString(2, fromDate);
         pStmt.setString(3, toDate);               
         rs = pStmt.executeQuery();     
         I think there is problem in both String-Date conversion and in the query.....

  • How to take data between two rising edge

    I would like to take waveform between two rising/falling edeg, I am using NI5102 VB6.0 with two input one is analog signal and the other is trigger input, start to read input signal when first trigger(rising/falling edge) and stop it by second trigger(rising/falling edge). 
    I have try to using counter CWcounter1.MeasurementType=... but the measurement tyep is not support my hardware.
    How to count two trigger to read signal??

    Hi,
    I looked more into your issue. Couple of questions. What are you using the counter for? Are generating sample clock for digitizer using counter?
    I am not sure why you need start trigger your application. But here is a solution I propose.
    Use reference trigger as triggering option and then set reference position as 0% (this will set pre-trigger samples to zero).
    Then perform multiple record acquisition. The advantage of using multi-record acquisition is that for every trigger, digitizer will acquire a record. Then you can fetch this data.
    So, whenever there is a trigger ... you acquire a record which can hold data for 8.3ms.
    If you have number of records greater than memory size of the digitizer, then there is an attribute NISCOPE_ATTR_ALLOW_MORE_RECORDS_THAN_MEMORY, setting this to true will allow you to have number of records greater than the memory size of the digitizer.
    You can specify number of number of records using NISCOPE_ATTR_HORZ_NUM_RECORDS
    Use NISCOPE_ATTR_FETCH_RECORD_NUMBER to acquire current record by linking it to index i of for loop.
    Use NISCOPE_ATTR_FETCH_NUM_RECORDS  to acquire only one record when trigger occurs.
    So,
    1) Set the program for multi-record acquisition
    2) Once trigger occurs, acquire current record using NISCOPE_ATTR_FETCH_RECORD_NUMBER and acquire only one record per trigger using NISCOPE_ATTR_FETCH_NUM_RECORDS.
    If not, you are not sampling at higher rates and you can also use a DAQ card with counter to acquire data using retriggerable acquisition.
    Let me know if this helps you.
    Kalyan
    Kalyanramu Vemishetty
    Automated Test Systems Engineer
    National Instruments

  • How to exchange data between two web application (servlet)

    Hello, all,
    I have two servlets: SerlvetA and ServletB, they are deployed as web appA and appB in the same web container(tomcat)
    How ServletA exchange data with ServletB?
    I have tried follow methods:
    1) appA and appB could not share HttpSession, so I could not transfer data through session
    2) I write a new sigleton java class called AppBroker, servletA get AppBroker's instance, and set some data into the it. ServletB could not get the same instance of the AppBroker, because the appA and appB use different class loader.
    tell me how to?

    thanks reply, but
    1. static class can not solve the problem, it is same
    as my sigleton class method, as different web app use
    different class loaderhmm... at least in tomcat this seems not be true since i can use static classes in one webapp that are available in another web app on the same host/servlet runner.
    Maybe if you build your own classloader than the "scope" of the static class is limited to that classloader (for my understanding this shouldn't be the case since i think it depends on the instance of the jvm and not of the classloader..?!).
    2. rmi and object serialization are too expensive!
    I am working on how to use jndi to solve this problem.
    And I think this maybe a Sevlet specification's
    shortcoming: maybe a Local Method as EJB local
    interface need been introduced into servlet spec.
    could you suggestion other methods?none at the moment. i guess the basic methods are listed.
    Maybe there's just one left, a really ugly one. Depending on what kind of data and how often you have to exchange you could think of building a file-based queue, i.e. a dir where you drop files in an read out from the other web app (maybe based on a file/directory listener). But this would only be an appropriate way to go for kind of email and messaging systems i guess...

  • How to compare data between two worksheet in Excel for applescript

    Hi All,
    How to compare the data from two different worksheet in Excel and set the value into one worksheet according to the same name? Here is the example. Worksheet 1 & 2 current we have, the final worksheet is the result we want and the value can be input in worksheet 1. Much appreciate if you can help on it.
    Worksheet 1:
    Name          Number
    Leo                 25
    Jame               55
    Leo                 30
    Jame               60
    Tim                 44
    Tomas             77
    Lyne                35
    Tonny              66
    Jame               22
    Game              88
    Worksheet  2:
    Name          Number  2
    Leo                60
    Jame             150
    Tim                66
    Tomas            88
    Lyne               55
    Tonny            99
    Game             111
    Rusult in Worksheet 1
    Name          Number        Total Number per name in Worksheet 1         Number 2 in Worksheet 2
    Leo                 25                          55                                                        60
    Jame               55                         137                                                       150
    Leo                 30                           55                                                        60
    Jame               60                         137                                                       150
    Tim                 44                          44                                                         66
    Tomas             77                          77                                                        88
    Lyne                35                          35                                                        55
    Tonny              66                          66                                                        99
    Jame               22                         137                                                       150
    Game              88                          88                                                        111

    I'd probably use a database for this, if there's any quantity of data involved here.  Import from Excel into {SQLite, MySQL, PostgreSQL, FileMaker, maybe Core Data}, or pick your preferred key-value store, keep your data in the database, then export or (via ODBC/JDBC) then access live database data from within the spreadsheets.
    Alternatively and if you're looking at small quantities of data (say, less than 10,000 entries, or less than a thousand depending on the language), then just use whatever passes for a key-value store in your preferred scripting language {Python, bash, Lua, or maybe php, AppleScript or Java} and use that.  Export Excel to CSV {gag} or XML, then load that into Python and process as needed, then write out CSV {gag} or XML.
    AppleScript is a scripting language for GUI applications, and also useful for processing events.  If you're not doing that sort of stuff, then there can be other choices, and other choices can often have extensive frameworks and libraries for common tasks.
    Sooner or later, most everybody runs into a wall when using a spreadsheet...  Various folks have encountered those limits and have migrated from spreadsheets to FileMaker databases, and now use a database as the central store for their operations — and that's the other issue that can arise with spreadsheets... Where's the canonical data?

  • How to compare dates between two items

    Hello all,
    I am trying to compare dates in two items.
    The first item is a computation P45_PAGE_LOADED_TIME
    select sysdate from dual;
    This essentially keeps track of when the user opened the form. They are accessing data that may become obsolete while they are in the form.
    So we have a dynamic action that finds the last_update date from a table. This field is of type date. It is placed in a text field called P45_STATUS.
    We then have a notification which we want to fire when P45_PAGE_LOADED_TIME is before P45_STATUS. We tried the following condition
    declare
    least_date date;
    begin
    SELECT LEAST(TO_DATE(:P45_STATUS),TO_DATE(:P45_PAGE_LOADED_TIME)) into least_date
    from dual;
    if least_date = to_date(:P45_STATUS) then
    return false;
    else
    return true;
    end if;
    end;
    Any guidance would be most appreciated.
    Thanks

    Maybe your better off putting your anonymous block into a plsql function.
    A function that you can test. If it works in plsql then you must call it in APEX.
    I kinda get a headache when I see that least, to_date, to_date query (although I've seen worse :p)
    Make it like:
    create or replace function fun_least_date(in_status in varchar2,
                                                               in_page_loaded_time varchar2) return boolean
    is
      l_status date;
      l_page_loaded_time date;
      least_date date;
      l_return boolean;
    begin
      l_status := to_date(in_status, 'FORMAT MASK!!!');
      l_page_loaded_time := to_date(in_page_loaded_time, 'FORMAT MASK!!!!');
      least_date := least(l_status, l_page_loaded_time);
      if least_date = l_status then
        l_return := false;
      else
        l_return := true;
      end if;
      return l_return
    end fun_least_date;If your sure that your function is correct then use it as a condition for your dynamic action.
    Regards
    Nico
    ps: I haven't tested that function. Be aware that you most correctly enter the format mask you use in APEX. Also before APEX may know about these variables you should set a dynamic action on your items to always submit their value to the server when they change!!!

  • How to transfer data between two tables

    Hi friends i have got a new problem actually i'm a fresher in this SAP so i have a doubt in SAP Smart Forms the problem is like this
    I have a data element common in both of the tables BSEG and KNA1 and the common data element is KUNNR so i want to transfer all the data in the table BSEG to KNA1 of the same data element(KUNNR) in which there is data regarding customer information so i want to transfer the single customer data into another table KNA1 and i want to display the data in the output plz any one can help me.

    hi.
    the below metjhod u can adopt.
    1)
    select data from 1st zable to internal table.
    2)insert data from internal table to 2nd ztable simple.
    data:begin of itab occurs 0.
    include structure ztable_structure1.
    data:end of itab.
    select * from ztable into table itab.
    modify ztable1 FROM TABLE itab.
    3 ) ike that u can catch date from other table.
    4) if any condition is there u can check it in the internal table.
    Rgds
    Anver
    if hlped pls mark points

  • How to copy data between two tables row by row

    Hi All,
    I have three tables TableA and TableB and TableC
    I wanted to write a stored procedure to copy data row by row from TableA to TableB and then update TableC by replacing any record that has the old id (before copying) to the new id after copying the data.
    here is the steps 
    iterate throw all the rows in tableA ( probably with a foreach)
    in each iteration we will do the following:
    Get current ID (identity) for each record in TableA ( will call it @oldID)
    Insert the row in TableB
    Get the new ID for the row from TableB will call it (@NewID)
    find rows in tableC that has the (@oldID)
    replace all ids in tableC with @oldID to @NewID
    Thanks in advance

    0
    TableA and TableB are identical they should have the same columns 
    TableC columns will be ( ID, TableA_ID , Notes)

Maybe you are looking for