Oracle yg digunakan adalah Oracle 9i
   
  Saya sudah coba, tapi tetap gak bisa, masih menghasilkan error yang sama. 
Error yg muncul "ORA-01747: invalid user.table.column, table.column, or columns 
specification."
   
  query saya adalah sbb:
   
  //oracmd.CommandText = "merge into tbtraining t1 " +
  // "using (select * from tbtraining where tbtraining.id='" + idt + "') t2 " +
  // "on (t1.id=t2.id) " +
  // "when matched then " +
  // "update set (t1.tglmulai, t1.tglselesai, t1.judul, t1.penyelenggara, 
t1.lokasi)=" +
  // "(" + "to_date('" + tglmulai.Date.ToString("dd/MM/yyyy") +
  // "', 'DD-MM-RRRR'), to_date('" + tglselesai.Date.ToString("dd/MM/yyyy") +
  // "', 'DD-MM-RRRR'), '" + jdl + "', '" + pny + "', '" + lokasi + "') " + 
  // "when not matched then " + 
  // "insert into t1 (t1.id, t1.tglmulai, t1.tglselesai, t1.judul, 
t1.penyelenggara, t1.lokasi) " +
  // "values ('" + idt + "', to_date('" + tglmulai.Date.ToString("dd/MM/yyyy") +
  // "', 'DD-MM-RRRR'), to_date('" + tglselesai.Date.ToString("dd/MM/yyyy") +
  // "', 'DD-MM-RRRR'), '" + jdl + "', '" + pny + "', '" + lokasi + "')"; 
   
  Saya jelaskan sedikit ttg query diatas, query itu ketikkan dlm program (C#), 
disitu ada beberapa variabel yg rencananya akan direkam ke database (idt, jdl, 
pny, lokasi, tglmulai, tglselesai). Jadi, yg akan diupdate ataupun di insert 
bukan dari tabel, tapi data yang diinput oleh user.
   
  Mohon pencerahannya.
   
  Thx again.
  

indra syafruddin <[EMAIL PROTECTED]> wrote:
          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]



         




Jemmy H. Tecoalu
Personal blog: http://jemmyt.blogspot.com

"The present was affected by the past, and the present will affect the future."


       
---------------------------------
Be a better Heartthrob. Get better relationship answers from someone who knows.
Yahoo! Answers - Check it out. 

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

Kirim email ke