MERGE INTO smsapp.TABLE_TUJUAN d
      using smsapp2.TABLE_AWAL s on (d.KEY_FIELD = s.KEY_FIELD)

      WHEN NOT MATCHED then
         insert
         values (s.KEY_FIELD,s.FIELD_2,s.FIELD_3)

      WHEN MATCHED then
         update set
         d.FIELD_1 = s.FIELD_1,
         d.FIELD_2 = s.FIELD_2

di bagian update, key_field nya jangan ikutan

On 7/4/07, Jemmy <[EMAIL PROTECTED]> wrote:
>
>   Halo...
> Numpang tanya, bagaimana caranya kalo di Oracle saya ingin mengeksekusi
> query dengan logika sebagai berikut:
>
> If exist then
> update
> else
> insert new
> end if
>
> Jadi, kalo data yang akan disave sudah ada, maka secara otomatis akan
> diupdate, kalo tidak ada baru insert new.
>
> Hasil googling ketemu pake statement MERGE, tapi setelah saya coba gak
> berhasil, bahkan error.
>
> Thx b4.
>
> Jemmy H. Tecoalu
> Personal blog: http://jemmyt.blogspot.com
>
> "The present was affected by the past, and the present will affect the
> future."
>
> ---------------------------------
> Sucker-punch spam with award-winning protection.
> Try the free Yahoo! Mail Beta.
>
> [Non-text portions of this message have been removed]
>
>  
>


[Non-text portions of this message have been removed]

Kirim email ke