oracle中途结束存储过程?

天空之城B哥 2014-06-23 02:58:37
oracle 存储过程 if.....else...
因为有好几个 if.....else... 怎么在else中中途结束存储过程?
return??
...全文
1943 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
天空之城B哥 2014-06-23
  • 打赏
  • 举报
回复
请教亚~~~~~
天空之城B哥 2014-06-23
  • 打赏
  • 举报
回复
create or replace package body material_mgmt is procedure modify_material_category_name(categoryId number) is parentCategoryName varchar2(256); parentId number(19); cateName varchar2(64); categoryName varchar2(256); i number(19); begin select t.parentid into parentId from t_materialcategory t where t.id = categoryId; select t.name into cateName from t_materialcategory t where t.id = categoryId; if parentId is null then update t_materialcategory t set t.categoryname = cateName where t.id = categoryId; else select t.categoryname into parentCategoryName from t_materialcategory t where t.id = parentId; categoryName := parentCategoryName ||'-'|| cateName; update t_materialcategory t set t.categoryname = categoryName where t.id = categoryId; end if; select count(*) into i from t_materialCategory o where o.parentid = categoryId; if i > 0 then update t_materialcategory t set t.categoryname = ( select p.categoryname ||'-'|| t.name from t_materialcategory p where p.id = t.parentid ) where t.id in (select o.id from t_materialCategory o where o.parentid = categoryId ); else return; end if; select count(*) into i from t_materialCategory o where o.parentid in(select o.id from t_materialCategory o where o.parentid = categoryId and o.leaf = 0 ); if i > 0 then update t_materialcategory t set t.categoryname = ( select p.categoryname ||'-'|| t.name from t_materialcategory p where p.id = t.parentid ) where t.parentid in (select o.id from t_materialCategory o where o.parentid = categoryId and o.leaf = 0); else return; end if; select count(*) into i from t_materialCategory o where o.parentid in(select o.id from t_materialCategory o where o.parentid in(select o.id from t_materialCategory o where o.parentid = categoryId and o.leaf = 0)and o.leaf = 0); if i > 0 then update t_materialcategory t set t.categoryname = ( select p.categoryname ||'-'|| t.name from t_materialcategory p where p.id = t.parentid ) where t.parentid in (select o.id from t_materialCategory o where o.parentid in(select o.id from t_materialCategory o where o.parentid = categoryId and o.leaf = 0)and o.leaf = 0); else return; end if; select count(*) into i from t_materialCategory o where o.parentid in(select o.id from t_materialCategory o where o.parentid in(select o.id from t_materialCategory o where o.parentid in(select o.id from t_materialCategory o where o.parentid = categoryId and o.leaf = 0)and o.leaf = 0)and o.leaf = 0); if i > 0 then update t_materialcategory t set t.categoryname = ( select p.categoryname ||'-'|| t.name from t_materialcategory p where p.id = t.parentid ) where t.parentid in (select o.id from t_materialCategory o where o.parentid in(select o.id from t_materialCategory o where o.parentid in (select o.id from t_materialCategory o where o.parentid = categoryId and o.leaf = 0)and o.leaf = 0) and o.leaf = 0); else return; end if; commit; end; end material_mgmt; 整个过程代码,,在每个else里加return了。 出现的问题是我最上面的if 。。else else语句不执行亚?
天空之城B哥 2014-06-23
  • 打赏
  • 举报
回复
create or replace package body material_mgmt is procedure modify_material_category_name(categoryId number) is parentCategoryName varchar2(256); parentId number(19); cateName varchar2(64); categoryName varchar2(256); i number(19); begin select t.parentid into parentId from t_materialcategory t where t.id = categoryId; select t.name into cateName from t_materialcategory t where t.id = categoryId; if parentId is null then update t_materialcategory t set t.categoryname = cateName where t.id = categoryId; else select t.categoryname into parentCategoryName from t_materialcategory t where t.id = parentId; categoryName := parentCategoryName ||'-'|| cateName; update t_materialcategory t set t.categoryname = categoryName where t.id = categoryId; end if; end; end material_mgmt; 我的那个if 。。else。。当我满足else条件时 else语句怎么不执行亚
  • 打赏
  • 举报
回复
return;
liao_z_j 2014-06-23
  • 打赏
  • 举报
回复
DECLARE A NUMBER(6); BEGIN IF 1 = 2 THEN A := 1; ELSIF 2 = 2 THEN A := 2; DBMS_OUTPUT.PUT_LINE(A); RETURN; ELSE A := 3; DBMS_OUTPUT.PUT_LINE(A); END IF; END; 是的。

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧