是否有任何简单的方法来获取函数/过程中使用的所有 Oracle 关键字?
让我印象深刻的第一件事是根据空间将给定对象名称的 user_source 中的文本分开,但这会留下一些场景,例如 DBMS_OUTPUT.PUT_LINE('HELLO WORLD') 等,
除了按空格、点、括号分割之外,还有其他方法吗?
问候, 公斤
最佳答案
您可以使用内置 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')
关于sql - 如何提取函数/过程中使用的所有 Oracle 关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52187791/