一个例子 看了之后感觉对自己很有帮助
/* File on web: justonce.sql */
CREATE OR REPLACE PACKAGE BODY justonce
IS
TYPE desc_t IS TABLE OF hairstyles.description%TYPE
INDEX BY BINARY_INTEGER;
descriptions desc_t;
FUNCTION description (code_in IN hairstyles.code%TYPE)
RETURN hairstyles.description%TYPE
IS
return_value hairstyles.description%TYPE;
FUNCTION desc_from_database RETURN hairstyles.description%TYPE
IS
CURSOR desc_cur IS
SELECT description FROM hairstyles WHERE code = code_in;
desc_rec desc_cur%ROWTYPE;
BEGIN
OPEN desc_cur;
FETCH desc_cur INTO desc_rec;
CLOSE desc_cur;
RETURN desc_rec.description;
END;
BEGIN
RETURN descriptions (code_in);
EXCEPTION
WHEN NO_DATA_FOUND THEN
descriptions (code_in) := desc_from_database;
RETURN descriptions (code_in);
END;
END justonce;