String sql8 = "update TEMP_FACILITY_MITIGATION_INFO f " +
      "set f.MitigationType01=(select xx.TypeAftereRevision from (select m.TypeAftereRevision from MITIGATION_REVISION_RECORD m where (m.FacilityID=f.FaciltyID and m.GuaranteeContractID=f.GuaranteeID01 and m.RecordStatus='10' and m.RefObjectRange='10') order by m.inputtime desc) xx where rownum=1) "+
                  "where id='001'"出错信息:Caused by: java.sql.SQLException: ORA-00904: "F"."GUARANTEEID01": invalid identifier
TEMP_FACILITY_MITIGATION_INFO这个表里是有GUARANTEEID01这个字段的,应该是f的作用范围的问题

解决方案 »

  1.   

    ---我觉得应该是不作用范围的问题,那他为什么不提示找不到f.FaciltyID?
    update TEMP_FACILITY_MITIGATION_INFO f
       set f.MitigationType01 = (select xx.TypeAftereRevision
                                   from (select m.TypeAftereRevision
                                           from MITIGATION_REVISION_RECORD m
                                          where ( m.FacilityID = f.FaciltyID 
                                                and m.GuaranteeContractID =f.GuaranteeID01 
                                                and m.RecordStatus = '10' 
                                                and m.RefObjectRange = '10')
                                          order by m.inputtime desc) xx
                                  where rownum = 1)
     where id = '001'
      

  2.   

    非作用域问题,你可以把该语句取出来在pl/sql developer或sqlplus中执行一下,
    看一下有什么提示。
      

  3.   

    我记得应该是不能这样写UPDATE的,之所以没有提示找不到f.FaciltyID,应该是oracle报异常的顺序问题。
    一般是从后往上的。
      

  4.   

    为什么不用MERGE试一试呢?/* Formatted on 2009/07/27 16:44 (Formatter Plus v4.8.8) */
    MERGE INTO customacc.CUSTMTR_COMPARE a
       USING customacc.CUSTMTR_COMPARE@DB89 b
       ON (a.code = b.code )
       WHEN MATCHED THEN
          UPDATE
             SET a.material = b.material, a.spec = b.spec,
                 a.curr_code = b.curr_code
       WHEN NOT MATCHED THEN
          INSERT (a.code, a.material, a.spec, a.curr_code, a.upddttm, a.upduser,
                  a.POSITION)
          VALUES (b.code, b.material, b.spec, b.curr_code, SYSDATE, USER,
                  b.POSITION)
      

  5.   

    这个SQL不能这样子写吧。update table_name set 后边跟rownum查询的数据,这样子还没用过呢。
      

  6.   


    ----3楼正解,你在oracle中执行下就看出问题所在了
    update TEMP_FACILITY_MITIGATION_INFO f  set f.MitigationType01=(select xx.TypeAftereRevision from (select m.TypeAftereRevision from MITIGATION_REVISION_RECORD m where (m.FacilityID=f.FaciltyID and m.GuaranteeContractID=f.GuaranteeID01 and m.RecordStatus='10' and m.RefObjectRange='10') order by m.inputtime desc) xx where rownum=1) where id='001;
      

  7.   

    f表的字段只能在第最外面一个select中看到