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语句不执行亚?
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语句怎么不执行亚
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;
是的。