DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Insert record in table using select statemet...

  1. #1
    Join Date
    May 2008
    Posts
    1

    Insert record in table using select statemet...

    I want to insert a record as like a same record already exists in table only a couple of field values different.
    The following insert works fine in SQL server2k5.
    ----
    Insert into pmuser
    (HGROUP, UNAME, DTPASS, SCODE, SSOURCE, sEmail, bCollapseSideMenu)
    Select HGROUP, 'Veer11', DTPASS, 'Veer11', SSOURCE, sEmail, bCollapseSideMenu
    From pmuser
    Where UniqueID = '99'
    ----
    Kindly help to make this Insert work with ORACLE.

    Many Thanks,

  2. #2
    Join Date
    Jul 2002
    Location
    Lake Worth, FL
    Posts
    1,492

    Talking

    Should work 'as is' in Oracle

    Except maybe the table name from the query is not the same as for the insert?
    Otherwise as it is written it may cause duplicate key exception on UniqueID = '99'.
    Last edited by LKBrwn_DBA; 05-07-2008 at 10:20 AM.
    "The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb

  3. #3
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Assuming you are referencing all columns in your table you can do...
    Code:
    insert 
    into    pmuser
    select  HGROUP, 'Veer11', DTPASS, 'Veer11', SSOURCE, sEmail, bCollapseSideMenu 
    from    pmuser 
    where   UniqueID = '99'
    ;
    You can also research Oracle documentation, it's free!
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

Posting Permissions

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


Click Here to Expand Forum to Full Width