如何提取 Function/Procedure 中使用的所有 Oracle 关键字
How to extract all Oracle Keywords used In a Function/Procedure
是否有任何简单的方法来获取 function/procedure 中使用的所有 Oracle 关键字?
让我印象深刻的第一件事是根据 space 将给定对象名称的文本从 user_source 中拆分出来,但这会留下一些未发现的场景,例如 DBMS_OUTPUT.PUT_LINE('HELLO WORLD') 等等,
除了按 space、点、括号拆分之外,还有其他方法吗?
此致,
公斤
您可以使用内置 ALL_STATEMENTS
/ALL_IDENTIFIERS
。
ALL_STATEMENTS describes all SQL statements in stored PL/SQL objects accessible to the user.
To gather information about PL/SQL identifiers and SQL statements in your code base, execute the following statement in your session
ALTER SESSION SET plscope_settings='identifiers:all, statements:all';
-- function/package compilation
SELECT st.owner,
st.object_name,
st.line,
s.text
FROM all_statements st join all_source s
ON ( st.owner = s.owner
AND st.object_name = s.name
AND st.line = s.line )
WHERE st.TYPE IN ('EXECUTE IMMEDIATE', 'OPEN')
是否有任何简单的方法来获取 function/procedure 中使用的所有 Oracle 关键字?
让我印象深刻的第一件事是根据 space 将给定对象名称的文本从 user_source 中拆分出来,但这会留下一些未发现的场景,例如 DBMS_OUTPUT.PUT_LINE('HELLO WORLD') 等等,
除了按 space、点、括号拆分之外,还有其他方法吗?
此致, 公斤
您可以使用内置 ALL_STATEMENTS
/ALL_IDENTIFIERS
。
ALL_STATEMENTS describes all SQL statements in stored PL/SQL objects accessible to the user.
To gather information about PL/SQL identifiers and SQL statements in your code base, execute the following statement in your session
ALTER SESSION SET plscope_settings='identifiers:all, statements:all';
-- function/package compilation
SELECT st.owner,
st.object_name,
st.line,
s.text
FROM all_statements st join all_source s
ON ( st.owner = s.owner
AND st.object_name = s.name
AND st.line = s.line )
WHERE st.TYPE IN ('EXECUTE IMMEDIATE', 'OPEN')