update  a 
set a.gldkj = b.rydmtj
from  ptdta.f03b13 b , ptdta.f0911  a  
where a.glco=b.ryco and a.gldct=b.rydctg and a.gldoc=b.rydocg and a.glfy=b.ryfy and a.glpn =b.rypn and glco ='02000' and glctry = 20 and glfy=8 and glpn = 5我在PLSQL中怎么不能跑
请问PL中的SQL应该怎么写啊????????
还有
update (select * from proddta.f0911 where glco = '" & CO & "' and glctry*100+glfy = " & AYear & "and glpn =" & BMonth +  & ") a set glexa = (select rnrmk from (select * from proddta.f0413 inner join proddta.f0414 on rmpyid=rnpyid and rmdctm=rndctm and rnrc5 = 1这样一条语句速度太慢 我怎么样优化呢??
谢谢各位大哥了!!!

解决方案 »

  1.   

    oracle的最好发到oracle去。我现在手上没测试环境..
      

  2.   

    update f03b13 set gldkj=(select rydmtj from f0911 where ...)
       where ...
      

  3.   

    PLSQL 里面update 要点击 【事务提交】按钮的,是不是没有提交事务?
      

  4.   

    --oracle两表数据关联的UPDATE表tb1及数据如下:
            ID          A          B
    ---------- ---------- ----------
             1         10         20
             2          1          2
             3          3          2表tb2及数据如下:
            ID          A          B
    ---------- ---------- ----------
             1         10         20
             2         10         20根据表tb2的id更新表tb1对应的a,b的值。update tb1 set (a,b) = (select a,b from tb2 where id = tb1.id) where id in (select distinct id from tb2)        ID          A          B
    ---------- ---------- ----------
             1         10         20
             2         10         20
             3          3          2
    ---------------------------------------------------------------------------------------------------------
    表tb2及数据如下:
            ID          A          B
    ---------- ---------- ----------
             1         10         20
             2         10         20
             3          3          2
             1         20         40
             2         20         40根据ID分组求A,B的和,然后更新表tb1update tb1 set (a,b) = (select sum(a),sum(b) from tb2 where id = tb1.id) where id in (select distinct id from tb2)        ID          A          B
    ---------- ---------- ----------
             1         30         60
             2         30         60
      

  5.   

     update (select * from proddta.f0911 where glco = '02000' and GLDCT = 'RC' and glctry*100+glfy = 2008and glpn =8) a set gldkj = (select rydmtj from proddta.f03b13 b where a.glco=b.ryco and a.gldct=b.rydctg and a.gldoc=b.rydocg and a.glfy=b.ryfy and a.glpn =b.rypn)这个为什么就不能跑呢
      

  6.   


    --oracle 写法
    update a 
    set a.gldkj = vil((select rydmtj from ptdta.f03b13 where ryco=a.glco and rydctg = a.gldct and rydocg = a.gldoc and ryfy = a.glfy and rypn = a.glpn),a.gldkj) 
    where glco ='02000' and glctry = 20 and glfy=8 and glpn = 5
      

  7.   

    --我上面把你表名看错,应该这样update ptdta.f0911 
    set a.gldkj = vil((select rydmtj from ptdta.f03b13 where ryco=a.glco and rydctg = a.gldct and rydocg = a.gldoc and ryfy = a.glfy and rypn = a.glpn),a.gldkj) 
    where glco ='02000' and glctry = 20 and glfy=8 and glpn = 5
      

  8.   

    --上面还是错,应该这样.update ptdta.f0911 
    set a.gldkj = vil((select rydmtj from ptdta.f03b13 where ryco=a.glco and rydctg = a.gldct and rydocg = a.gldoc and ryfy = a.glfy and rypn = a.glpn),a.gldkj) 
    from ptdta.f0911 a
    where glco ='02000' and glctry = 20 and glfy=8 and glpn = 5