Ask for a sql sentence(procedure) for copy data to themselves' table

two tables
order and orderitem,there are relationship table;
order's id is PK
orderitem's id is PK,and parentId is FK.
and all id are created by sequences:order_id_seq and orderitem_id_seq.
order
id name
1 aaa
2 bbb
orderitem
id parentId num
1 1 100
2 1 150
3 2 200
4 2 300
now I want to copy these data to themselves table.how to code the sql or the procedure??the main problem i encoutered is how to update the parentId of the orderitem table?
Message was edited by:
user577067
Message was edited by:
user577067

now i want to copy order table's data to order,and copy data of orderitem table to orderitem.and after that the table data should be
order
id name
1 aaa
2 bbb
3 aaa
4 bbb
orderitem
id parentId num
1 1 100
2 1 150
3 2 200
4 2 300
5 3 100
6 3 150
7 4 200
8 4 300
Message was edited by:
user577067

Similar Messages

  • Special GL  asking for Due Date

    Hi SAP Gurus,
                When I am trying to post the customer invoice with t.code F-22 and put the Special Ledger indicator it is asking for Due Date as a mandatory field but it should not be because of the payment terms.
    Is there any configuration I can use payment terms with special GL indicators for customer and vendor documents.
    Is there an option to get the payment terms from the company view when we are creating invoices in special GL indicators. Because the due date that appears, instead of baseline date, payment terms and days as in a common invoice.
    Regards,
    Sim

    Go to T.Code - OB41 (Field Status for Posting Keys)
    Selct Posting Key - 01 & Go inside
    Go Inside to Group - Payment Transactions
    & Check Out whether Due Date Field is with Required Entry or not. If it is so then make it Optional.
    Similarly, Check out Special GL Reconciliation A/C . Through FS00,Check out the Field Status Group of the same (Mostly, it will be G067- Recon.A/Cs) & make the Due Sate Field Optional there as well in Payment Transactions.
    Regards..
    Ameya....

  • HT1918 how the can you reset your rescue email details when it asks for your date of birth as a primary question (and you hadnt entered it in first place) anyone know ?

    I need to reset my "Rescue email"
    in order to do this you have to answer security questions
    herein lies my problem
    its asks for my date of birth
    i enter it and it is not recognised
    therefore i can't reset my account information
    anybody know what to do next
    have contacted itunes but not received any valid help as of yet

    No one here will be able to help you. We are fellow users.
    You need to contact iTunes support via:
    https://expresslane.apple.com
    It looks like you've already done that - they can take a day or to respond these days I find.
    AC

  • I have wireless router@home now it's asking for cellular data plan enrollment to have access to safari.

    I have a wireless router @ home and IPAD was working fine until it started asking for cellular data plan. I always choose later now will not allow me to use safari unless I pick a data plan.

    Ok turned off cellular data & roaming off. Checked Wifi Networks it displays my correct network. 
    Still I can open safari but most of it is shaded in grey so can't navigate.

  • Podcasts app asks for cellular data even if the podcast is already downloaded

    When playing a podcast without a wifi access, the Podcasts app asks for celluar data access. This is even for podcasts that have already been downloaded and should not require streaming.If I do not provide cellular data access, then the podcast cannot be played.
    Is there a way to play downloaded podcasts without cellular data?
    Thanks in advance.

    I have a similar problem on my iPhone 5, iOS 7.0.4.

  • Urgently Need Code for Copy & Paste from Html Table in JSP to Excel file

    I am creating a html table in JSP file .
    I need code for 'Cut,Copy,Paste' functions ie. if someone wants to copy data from my table to excel file or from excel file to html table he shud be able to do that.
    Can someone give me code for 'Cut,Copy and Paste' i.e. some javascript functions which can do cut, copy and paste which i can put in my jsp file
    Thanks
    Message was edited by:
    javatechguru2007

    package com.chinmayananda
    public class Tetris{
    // complete here
    code]
    public abstract class AbstractTetris {
       public abstract void start();
       public abstract void stop();
    }nearly done

  • I need to copy data from a table in one database (db1) to another table in

    Hi
    I need to copy data from a table in one database (db1) to another table in another database (db2).
    I am not sure if the table exists in db2,,,if it doesnot it needs to be created as well data also needs to be inserted...
    How am I supposed to this using sql statements..?
    I shall be happy if it is explained SQL also...
    Thanking in advance

    How many rows does the table contains? There are manyway you can achieve this.
    1. export and import.
    2. create a dblink between two databases and use create table as select, if structure doesnot exists in other database, if structure exists, use, insert into table select command.
    example:
    create a dblink in db2 database for db1 database.
    create table table1 as select * from table1@db1 -- when there is no structure present
    -- you need to add constraints manually, if any exists.
    insert into table1 select * from table1@db1 -- when there is structure present.
    If the table contains large volume of data, I would suggest you to use export and import.
    Jaffar

  • 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)

  • How do I run a database procedure that inserts data into a table from withi

    How do I run a database procedure that inserts data into a table from within a Crystal report?
    I'm using CR 2008 with an Oracle 10i database containing a number of database tables, procedures and packages that provide the data for the reports I'm developing for my department.  However, I'd like to know when a particular report is run and by whom.  To do this I have created a database table called Report_Log and an associated procedure called prc_Insert_Entry that inserts a new line in the table each time it's called.  The procedure has 2 imput parameters (Report_Name & Username), the report name is just text and I'd like the username to be the account name of the person logged onto the PC.  How can I call this procedure from within a report when it's run and provide it with the 2 parameters?  I know the procedure works, I just can't figure out how to call it from with a report.
    I'd be grateful for any help.
    Colin

    Hi Colin, 
    Just so I'm clear about what you want: 
    You have a Stored procedure in your report.  When the report runs, you want that same procedure to write to a table called Report_Log. 
    If this is what you want the simple answer is cannot be done.  Crystal's fundamental prupose is to read only, not write.  That being said, there are ways around this. 
    One way is to have a trigger in your database that updates the Report_Log table when the Stored Procedure is executed.  This would be the most efficient.
    The other way would be to have an application run the report and manage the entry. 
    Good luck,
    Brian

  • Copying data between two tables with different structures

    I have two tables. second table has three extra fields at the end. How can I copy data from first table to the other? I tried the following but it does not seem to work:
    INSERT INTO second_table ((select * from first_table),'text','text',5)
    Please help. Thanks

    INSERT INTO second_table SELECT col1, col2, col3, .., 'text', 'text', 5 FROM first_table;
    Cheers!
    r@m@

  • Procedure to check data from different tables

    Hi
    I am trying to write a procedure to compare data from a table with another.
    Table 1
    ID Name Dept
    1 ABC Y
    2 DEF Z
    Table 2
    ID Dept
    1 Y
    2 Z
    Table 3
    Name ID
    1 ABC
    2 DEF
    I would like to compare each record data in Table 1 with data from different tables table2,table3 by matching ID,name.... Please help me with how I could start writing a procedure and also spool data that does not match from the table1 with other tables
    thanks
    Edited by: 890563 on Apr 30, 2012 10:34 AM

    Hope below helps you.
    CREATE TABLE TABLE1
    (    ID          VARCHAR2(10),
         FIRST_NAME  VARCHAR2(30),
         LAST_NAME   VARCHAR2(30),
         MIDDLE_NAME VARCHAR2(30)
    INSERT INTO TABLE1 VALUES('123456','testfirst','testlast','testmiddle');
    INSERT INTO TABLE1 VALUES('123457','testfirst1','testlast1','testmiddle1');
    CREATE TABLE TABLE1
    (    ID          VARCHAR2(10),
         FIRST_NAME  VARCHAR2(30),
         LAST_NAME   VARCHAR2(30),
         MIDDLE_NAME VARCHAR2(30)
    INSERT INTO TABLE2 VALUES('123456','testfirst','testlas','testmidd');
    INSERT INTO TABLE2 VALUES('123457','testfirst2','testlast1','testmiddle1');
    SELECT TABLE1.ID,
            -- Match First Name
         CASE WHEN TABLE1.FIRST_NAME != TABLE2.FIRST_NAME THEN TABLE1.FIRST_NAME ELSE NULL END TABLE1_FIRST_NAME,
         CASE WHEN TABLE1.FIRST_NAME != TABLE2.FIRST_NAME THEN TABLE2.FIRST_NAME ELSE NULL END TABLE2_FIRST_NAME,
            -- Match Middle Name
         CASE WHEN TABLE1.MIDDLE_NAME != TABLE2.MIDDLE_NAME THEN TABLE1.MIDDLE_NAME ELSE NULL END TABLE1_MIDDLE_NAME,
            CASE WHEN TABLE1.MIDDLE_NAME != TABLE2.MIDDLE_NAME THEN TABLE2.MIDDLE_NAME ELSE NULL END TABLE2_MIDDLE_NAME,
            -- Match Last Name
         CASE WHEN TABLE1.LAST_NAME != TABLE2.LAST_NAME THEN TABLE1.LAST_NAME ELSE NULL END TABLE1_LAST_NAME,
            CASE WHEN TABLE1.LAST_NAME != TABLE2.LAST_NAME THEN TABLE2.LAST_NAME ELSE NULL END TABLE2_LAST_NAME
    FROM  TABLE1, TABLE2
    WHERE TABLE1.ID = TABLE2.ID
    ID         TABLE1_FIRST_NAME  TABLE2_FIRST_NAME  TABLE1_MIDDLE_NAME TABLE2_MIDDLE_NAME TABLE1_LAST_NAME   TABLE2_LAST_NAME
    123456     NULL               NULL               testmiddle         testmidd           testlast        testlas
    123457     testfirst1         testfirst2         NULL               NULL               NULL            NULL
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • 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....

  • 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>

  • I am unable to sign into icloud.  When asked for my date of birth I receive a message that my dob does match Apple's records.  I don't remember setting a different password for icloud.

    Since I replaced my iPhone 4 with the 5s I have been unable to access icloud.  When asked for my password I receive the message that it is not valid.  wehn using the security questions the system does recognize my date of birth. 

    You can have the password reset sent to the email address associated with your ID, as explained in the second option here: http://support.apple.com/kb/HT5787.  If you don't have access to the email address, you'll have to contact Apple for assistance by going to https://expresslane.apple.com, then click More Products and Services>Apple ID>Other Apple ID Topics>Lost or forgotten Apple ID password, or by contacting the Apple account security team: http://support.apple.com/kb/HT5699.

  • Creative Cloud Login Problem - Repeatedly asked for birth date

    Having purchased CC and trying to login I continuously get asked for my brithdate. After entering the birthdate the screen returns again to ask for my birthdate. Cant get past this screen so that I can download the CC apps. Any suggestions?

    Hi Donatello3,
    Welcome to the Community!
    I checked your account and found that there is a problem with your Adobe ID i.e. e-mail address. Please check this link http://helpx.adobe.com/x-productkb/policy-pricing/account-password-sign-faq.html and if this doesn't help then click on Chat now button to contact our Adobe support team and they will resolve the problem.
    Thanks!
    Ankit

Maybe you are looking for

  • Replacing a key, or a keyboard

    About a month ago, I purchased a macbook pro 15" and one of the keys seem to not work properly, time to time, or one of the key easily comes off by just pushing it up when none of the others do. So if something hit the keyboard a bit hard, it comes o

  • Keyboard: some keys not working

    Some keys not working.  Need help/suggestions.  Not great with computers so PLEASE give details/steps re: how to do what you suggest - thanks! Details: intel based iMac running snow leopard 10.6.8.  Apple wireless/bluetooth keyboard (came with the iM

  • Vedio classes for sap crm 7.0 services modules.

    HI experts, I am looking out of sap crm services vedio classes ( recorded ) or any similar type, Please provide me the link. Thanks in advance Prajith P

  • Why does my 4s weather show "Barlow"

    I noticed after the update that in weather there appears Barlow. I don't know where Barlow is and I can't seem to delete it. For a while, when I typed in my address in maps, it didn't show me as being at my house but in the church lot next door to my

  • User based rate limit

    Hi, Iam looking for a way to Rate Limit - Vlan interfaces, Somting like this .. or do I need to change the service-policy to rate-limit for it to work Interface Vlan2 Description Customer-A service-policy input police-customerA-traffic service-policy