Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2012
    Location
    Dallas, Texas
    Posts
    2

    Unanswered: Update 1 table from mulitiple tables

    Please help if you can I am new to Oracle and have been given a heavy task. Based upon table1 date_creation(timestamp) I must update a new created table "dest_table" from multiple tables (table2, table3, table4, etc.). Is a stored procedure the only way to accomplish this? Desc_table must be updated daily.

    Thanks in advance

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Code:
    UPDATE dest_tbl D 
    SET    ( col1, col2, col3 ) = (SELECT A.col4, 
                                          B.col5, 
                                          C.col6 
                                   FROM   tbl_a A, 
                                          tbl_b B, 
                                          tbl_c C 
                                   WHERE  A.id = B.id 
                                          AND B.id = C.id) 
    WHERE  D.id = (SELECT id 
                   FROM   tbl_a);
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Oct 2002
    Location
    Cape Town, South Africa
    Posts
    253
    Code:
    update dest_table t
    set (col2, col3, col4, etc.) = (select t2.col, t3.col, t4.col, etc. 
                                      from table2, table3, table4, etc.
                                     where table2.col1 = t.col1
                                       and joins here)
    where
    exists (select 'x' 
              from table1 
             where table1.col1 = t.col1
               and other filters)

  4. #4
    Join Date
    Jul 2012
    Location
    Dallas, Texas
    Posts
    2
    Thanks guys I will let you know if I have any questions. I truly appreciate the help.

  5. #5
    Join Date
    Oct 2004
    Posts
    60
    You also can use Merge Statement which IMO is ANSI Standard.

Tags for this Thread

Posting Permissions

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