不好意思问题还没提:
编译是通过了,但在执行的时候,程序第三行发生错误:
........"A"."dir_unum",invalid identifier.......
我不明白什么意思,这个字段是存在的,请问什么原因?
merge使用时有什么限制吗?

解决方案 »

  1.   

    我找半天也没有在你的语句里找到a.dir_unum阿
      

  2.   

    不好意思各位:
    是"A"."user_num",在第三行。谢谢提醒,今天比较昏。
      

  3.   

    a.user_num 是主键吗? 另外既然 a.user_num=S.user_num时,是matched,你为什么咳update set呢?
      

  4.   

    TO rolandzhang():
    “a.user_num 是主键吗?”-----------------你的意思是相比较的这个字段必须是主键吗?
    “既然 a.user_num=S.user_num时,是matched,你为什么咳update set呢?“-----------------------这个问题是这样的,我要更新的 是这条记录后面其他的字段,当然这个字段可以不用更新,但应该不影响把?
      

  5.   

    a.user_num=S.user_num时,是matched,update set的时候就不必再多此一举更新了,有时细小的地方也容易引起错误!!
      

  6.   

    “(A.user_num = S.user_num)” 
           when matched then
               update  set “a.user_num=S.user_num”“”这里重复了
      

  7.   

    insert 决少了关键字 ,少了into
    标准语句:
    merge into table1 a
    using(select * from table2 b) 
    on (a.id=b.id) 
    when matched then 
    update set fno='old' 
    when not matched then 
    insert into values(a.id,'new');