oracle存储过程 if esle,该如何解决
oracle存储过程 if esle
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语句怎么不执行亚
------解决方案--------------------
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语句怎么不执行亚
------解决方案--------------------
-- LZ 你注意这两句
categoryName varchar2(256);
update t_materialcategory t set t.categoryname = categoryName where t.id = categoryId;
-- 你的列名 , 和你的变量名一样了,等于没有更新,你把变量名改成一个别的,就没问题了。