小弟,才疏学浅请多多帮助!!!
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里的对象看待! 不知道 是否理解错误!
高手指点!!
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里的对象看待! 不知道 是否理解错误!
高手指点!!
解决方案 »
- Oracle ProC Delete 动态表名问题
- 求一sql语句
- 关于数据锁定的问题,有一行记录被锁定.如何查找到这条操作锁定的语句?
- 安装oracle 时自动创建的数据库与配置oms 时创建的数据库有何区别。
- OracleOraHome90TNSListener服务不能起动(这个是不是叫监听器)
- oracle数据备份问题
- pl/sql developer有中文版吗?有关于它的书籍或资料吗
- 如何用sql查询出某个月的第一天,和最后一天
- 求助!关于INSET INTO的用法!
- 请问怎么讲2014-12-20 00:00:00.000变更为2014-12这种格式
- 关于时间索引,时间范围一天,但却进行了全表扫描。
- 急!求助 ora-1122 can not open database!!!!
存储过程调用函数是比较灵活的;
因为函数有返回值,可以用函数给变量赋值。例如,变量名 变量类型 := 包名.函数名(参数);
也可以在sql语句里直接调用函数。例如,select 包名.函数名(字段名) into 变量1 from 表名;
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是这是这样...
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可参考...
有些数据库的存储过程可以用C/C++或者Java这样的语言来写的,比如DB2和最新办的MySQL。