Oracle 11g PL/SQL Positions of CONTANT variables in PACKAGE を参照してください PL/SQL コンパイラがこのアプローチを処理する方法:
FUNCTION PARSER(IN_VALUE IN VARCHAR2) RETURN VARCHAR2 IS
LC_PARAM CONSTANT VARCHAR2(10) := 'USERNAME';
LC_MSG CONSTANT VARCHAR2(80) := REPLACE('Hello USERNAME! How are you today?', LC_PARAM, IN_VALUE);
BEGIN
RETURN REPLACE(LC_MSG, LC_PARAM, LC_PARAM);
END PARSER;
またはこれさえ:
FUNCTION PARSER(IN_PARAM IN VARCHAR2,
IN_VALUE IN VARCHAR2) RETURN VARCHAR2 IS
LC_MSG CONSTANT VARCHAR2(80) := REPLACE('Hello USERNAME! How are you today?', IN_PARAM, IN_VALUE);
BEGIN
RETURN REPLACE(LC_MSG, IN_PARAM, IN_PARAM);
END PARSER;