小弟,才疏学浅请多多帮助!!!
create or peplace package body product_package as
function update_simple_curros
return t_ref_cursor is
product_ref_cursor t_ref_cursor;
begin
open update_simple_curros for
select id,name,price,phone,from Jxmf_info_Customers;
return product_ref_cursor;
end update_simple_curros;
procedure update_product_price(
p_product_id in Jxmf_info_Customers.id%TYPE,
p_factory in number)
as
v_product_count integer;
begin
select count(*) into v_product_count  from Jxmf_info_Customers where id = p_product_id ;
if v_product_count =1 then
update Jxmf_info_Customers set price = price*p_factory where id = p_product_id ;
commit;
end if;
exception 
when others then
rollback;
end update_product_price;
end update_time;
/
比如:说:一个存储过程A 怎样调用B函数 B函数怎样调用C函数 C函数怎样调用D函数!
到头来 我执行A 就可以啦!!
我把存储过程一直当成java里的对象看待! 不知道 是否理解错误!
高手指点!!

解决方案 »

  1.   

    存储过程的标准定义:商业规则和业务逻辑可以通过程序存储在oracle中,这个程序就是存储过程。
    存储过程调用函数是比较灵活的;
    因为函数有返回值,可以用函数给变量赋值。例如,变量名 变量类型 := 包名.函数名(参数);
    也可以在sql语句里直接调用函数。例如,select 包名.函数名(字段名) into 变量1 from 表名;
      

  2.   


    procedure update_product_price( 
    p_product_id in Jxmf_info_Customers.id%TYPE, 
    p_factory in number) 
    as 
    v_product_count integer; 
     temp_          Number;--变量定义
     
    begin 
     temp_:=product_package.Function_Name(parameters);---你的函数,同样可以再Function调用相关函数
    select count(*) into v_product_count  from Jxmf_info_Customers where id = p_product_id ; 
    if v_product_count =1 then 
    update Jxmf_info_Customers set price = price*p_factory where id = p_product_id ; 
    commit; 
    end if; 
    exception 
    when others then 
    rollback; 
    end update_product_price; 不知LZ是这是这样...
      

  3.   


    PROCEDURE Modify__ (
       info_       OUT    VARCHAR2,
       objid_      IN     VARCHAR2,
       objversion_ IN OUT VARCHAR2,
       attr_       IN OUT VARCHAR2,
       action_     IN     VARCHAR2 )
    IS
       oldrec_ CUSTOMER_ORDER_TAB%ROWTYPE;
       newrec_ CUSTOMER_ORDER_TAB%ROWTYPE;
    BEGIN
       General_SYS.Init_Method(lu_name_, 'CUSTOMER_ORDER_API', 'Modify__');
       IF (action_ = 'CHECK') THEN
          newrec_ := Get_Object_By_Id___(objid_);--调用Function
          Unpack_Check_Update___(attr_, newrec_, objid_);--调用过程
       ELSIF (action_ = 'DO') THEN
          oldrec_ := Lock_By_Id___(objid_, objversion_);--调用Function
          newrec_ := oldrec_;
          Unpack_Check_Update___(attr_, newrec_, objid_);--调用过程
          Update___(objid_, oldrec_, newrec_, attr_, objversion_);---调用过程
       END IF;
       info_ := Client_SYS.Get_All_Info;
    END Modify__;
    --调用Function
    FUNCTION Get_Object_By_Id___ (
       objid_ IN VARCHAR2 ) RETURN CUSTOMER_ORDER_TAB%ROWTYPE
    IS
       lu_rec_ CUSTOMER_ORDER_TAB%ROWTYPE;
       CURSOR getrec IS
          SELECT *
          FROM   CUSTOMER_ORDER_TAB
          WHERE  rowid = objid_;
    BEGIN
       OPEN getrec;
       FETCH getrec INTO lu_rec_;
       IF (getrec%NOTFOUND) THEN
          CLOSE getrec;
          Error_SYS.Record_Removed(lu_name_);--过程
       END IF;
       CLOSE getrec;
       RETURN(lu_rec_);
    END Get_Object_By_Id___;LZ可参考...
      

  4.   

    那样理解应该也没有太大的问题。
    有些数据库的存储过程可以用C/C++或者Java这样的语言来写的,比如DB2和最新办的MySQL。