Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2003
    Location
    In your thoughts
    Posts
    195

    Unanswered: Simple Copy Rows Question

    I have the need to be able to take rows in a table, copy them, increment a number and then insert them. Can someone help me out? Basically, if I had this:

    Code:
    SU_NAME     SU_PASS     SU_UID
    Jeremy         nothing         92837
    I want to copy that user's row and create a replica of it with the only thing changing would be it's SU_UID which whould should be the largest SU_UID in the table + 1. Does this make sense? Thanks, Jeremy
    Nothing better than a good ride.

  2. #2
    Join Date
    Jan 2003
    Location
    Woking
    Posts
    107

    Re: Simple Copy Rows Question

    Hi,

    Hope this query help you.
    I am not sure if this is what u r looking for.


    INSERT INTO emp
    SELECT
    New_Emp_No + 1,
    Name||to_char(New_Emp_No + 1)
    FROM (SELECT 'King' Name,
    (SELECT MAX(empno) FROM emp) New_Emp_No FROM emp)
    WHERE ROWNUM < 2

    This works if the emp table has atleast one row.

    FYI,
    I have Oracle 9.2.0.1.0

    Hope it Helps



    Originally posted by JCScoobyRS
    I have the need to be able to take rows in a table, copy them, increment a number and then insert them. Can someone help me out? Basically, if I had this:

    Code:
    SU_NAME     SU_PASS     SU_UID
    Jeremy         nothing         92837
    I want to copy that user's row and create a replica of it with the only thing changing would be it's SU_UID which whould should be the largest SU_UID in the table + 1. Does this make sense? Thanks, Jeremy
    nn

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •