修改“在子程序里声明变量和常量并赋值”章节示例中 p_name 的类型,使用 ware.w_name%type 代替 varchar。
delimiter /
CREATE OR REPLACE PACKAGE pkg_ware_mgmt as
MAX_WARES constant number(2,0) := 10;
MAX_DISTS_PER_WARE constant number(2,0) := 10;
FUNCTION f_check_ware_exists(p_name IN ware.w_name%TYPE) RETURN BOOLEAN ;
END;
/
delimiter ;
delimiter /
CREATE OR REPLACE PACKAGE BODY pkg_ware_mgmt as
FUNCTION f_check_ware_exists( p_name IN ware.w_name%TYPE ) RETURN BOOLEAN
IS
i_cnt number := -1;
b_ret boolean := FALSE;
BEGIN
SELECT count(*) INTO i_cnt FROM ware WHERE w_name = p_name AND rownum < 2;
b_ret := (i_cnt = 1);
RETURN b_ret;
EXCEPTION
WHEN OTHERS THEN
RETURN FALSE;
END;
END;
/
delimiter ;
obclient>