各位,想问一下这个存储过程如何写.
表1 test2
a   b
表2 test3
c   dtest2.a=test3.c想将A和C关联的数据B更新到CSELECT ::update test3 set d=
(select b from test2
where a='a2')
where c='a2'我写的存储过程:create PROCEDURE dd(P_ID IN NUMBER)
ISCURSOR REMARK IS
SELECT a
FROM test2
WHERE a = P_ID;beginFOR j in re loopupdate test3 set d=
(select b from test2
where a=j.p_id)
where c=j.p_idend loop;end; 帮忙看下那里有问题..

解决方案 »

  1.   

    create PROCEDURE dd(P_ID IN NUMBER) 
    IS CURSOR REMARK IS 
    SELECT a,b 
    FROM test2 
    WHERE a = P_ID; begin FOR j in re loop update test3 set d= j.b
    where c = j.a;
    end loop; end; 
    试试。
      

  2.   

    PROCEDURE HAPPY.DD 编译错误错误:PLS-00103: ???? "END"?????????
           .(*@%&-+;/atmodremreturnreturning
              <an exponent (**)>andor||
           ?? ";" ???? "END" ????
    行:18
      

  3.   

    create or replace procedure t(P_ID IN NUMBER) isCURSOR REMARK IS 
    SELECT a 
    FROM test2 
    WHERE a = P_ID; begin
      FOR j in re loop update test3 set d= 
    (select b from test2 
    where a=j.a) 
    where c=j.a ;end loop; 
    end t;
      

  4.   

    不会编译出错吧?刚刚试了一下。
    你这种情况没有必要使用update中的子查询的。
    好好想想,应该很容易实现。
      

  5.   

    我看了你写的SQL,做过测试,不用子查询的话是整列更新的.所以我才想到用子查询.
    另外,我这个存储过程编译能通过,但如何CALL T呢?
    请指教.
      

  6.   

    begin
       t(1);
    end;select * from test3;存储过程的调用本身就是PLSQL语句,不是表达式的一部分来调用的的(函数是)最终要看存储过程运行的结果  就要看你的那个存储过程是干什么的,
    这里你更新TEST3,就查查TEST3看变化吧!
      

  7.   

    package 里面的存储过程如何调用呢?
    begin 
      cc.t(1); 
    end; 不能调用测试.
      

  8.   


    上面错了

    begin 
      t(1); 
    end; 存储过程不属于哪个表!
      

  9.   

    可能我误会你的意思
    要是想调用游标,参量就把它写在一个包里(PACKAGE)
    包是全局的,存储过程和函数是局部的