1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Update a table with values assigned from another table

Discussion in 'SQL PL/SQL' started by yashk111, Nov 4, 2009.

  1. yashk111

    yashk111 Active Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    55
    As i wrote in title i have to update a table named DWSODS01.DWT00102_DERV_IMC_MISC
    with values assigned form another table.
    There is also a condition and condition is

    LAST_SPON_DT_KEY_NO =DWT00002_IMC_DMS_MAIN.INMKT_LAST_SPON_DT_KEY_NO
    FIRST_SPON_DT_KEY_NO =CASE WHEN (DWT00102_DERV_IMC_MISC.INMKT_FIRST_SPON_DT_KEY_NO = 19000101 or (DWT00102_DERV_IMC_MISC.INMKT_FIRST_SPON_DT_KEY_NO is null)) then DWT00002_IMC_DMS_MAIN.INMKT_FIRST_SPON_DT_KEY_NO else DWT00102_DERV_IMC_MISC.INMKT_FIRST_SPON_DT_KEY_NO END

    So i have to update those two columns with values from another table. This is my code just check and say if anything is wrong ( i dont know how to test, if anyone is willing please give me a suggestion how to test)

    Code (SQL):
    UPDATE DWSODS01.DWT00102_DERV_IMC_MISC
    SET  LAST_SPON_DT_KEY_NO =DWT00002_IMC_DMS_MAIN.INMKT_LAST_SPON_DT_KEY_NO
    FIRST_SPON_DT_KEY_NO =CASE WHEN (DWT00102_DERV_IMC_MISC.
          INMKT_FIRST_SPON_DT_KEY_NO = 19000101 OR (DWT00102_DERV_IMC_MISC.
          INMKT_FIRST_SPON_DT_KEY_NO IS NULL))
          THEN DWT00002_IMC_DMS_MAIN.INMKT_FIRST_SPON_DT_KEY_NO
          ELSE DWT00102_DERV_IMC_MISC.INMKT_FIRST_SPON_DT_KEY_NO
          END
     
  2. debasisdas

    debasisdas Active Member

    Messages:
    46
    Likes Received:
    3
    Trophy Points:
    90
    Location:
    Bangalore, India
    That should work for you. Are you facing any problem with that. Would mind posting the structure of both the tables with sample data.