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

Thread: How to achive this using sql

  1. #1
    Join Date
    Jun 2000
    Posts
    315

    How to achive this using sql

    I am trying to insert data from vmap_temp to vmap table. Since vmap table does not have any constraints, but I want rpo_key, vehicle_key pair to be unique. So I have to check the data in vmap_temp table before they get inserted into vmap table. How could I accomplish this? How about the following scripts? Can this scripts guarantee the uniquess of rpo_key, vehicle_key pair?

    Insert /*+ parallel */ into vmap
    (select * from vmap_temp
    where (rpo_key, vehicle_key) not in (select rpo_key, vehicle_key from vmap));
    commit;


    Thanks!

  2. #2
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    Your SQL will work.

    Did you check (rpo_key, vehicle_key) uniqueness in the temp table?

    Tamil

  3. #3
    Join Date
    Jun 2000
    Posts
    315
    Tamil, thank you! I was afraid of it would check rpo_key, vehicle_key one by one or any of them instead of checking the pair! I need to guarantee the pair of rpo_key, vehicle_key to be unique.
    Is there a way to verify the script would check the pair of rpo_key, vehicle_key not in vmap table before the new data get into vmap_temp table?

    No, I didn't check (rpo_key, vehicle_key) uniqueness in the temp table?

    Thanks again!

  4. #4
    Join Date
    Apr 2003
    Posts
    353
    Create a table with the subquery
    Create unique index --use exceptions into clause.

    You get it.

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