我有这个巨大的查询,它使用了一些文本,看起来像变量,但我不知道它们是什么,我真的无法搞清楚。它们不是全局的,也不是oracle包中其他任何地方定义的。特别是在名为“has_value”的变量(或其任何东西)之下是如此令人困惑,因为它在多种情况下用于跨越很多表的查询。
PROCEDURE assemble_default_where(
i_search_id IN search_table.search_id%TYPE,
o_where_clause OUT VARCHAR2,
o_from_clause OUT VARCHAR2,
o_error_number OUT error_message.error_number%TYPE) IS
l_base VARCHAR2(30) := 'd';
CURSOR c_where_clause IS
SELECT DECODE
(sl.parameter_name,
'track Location', join_operator || ' ' || open_brackets || ' ' || not_operator || ' EXISTS(SELECT 1 FROM track_locations loc WHERE ' || l_base
|| '.plan_number = loc.plan_number AND ' || l_base || '.order_id = loc.order_id AND loc.t_id = NVL('''
|| track_location_rsect_id(has_value) || ''', loc.t_id) AND loc.tstatus = NVL(''' || track_tstatus_id(has_value)
FROM search_lines sl
WHERE search_id = i_search_id
ORDER BY line_no;
我遗漏了一些查询,因为它与我的问题无关。
我想知道join_operator,has_value和open_brackets来自哪里以及它们是什么?
答案 0 :(得分:0)
有几种选择:
在实践中,您可能已经注意到它是#1,#2,#3还是#4。 #6和#7非常罕见。我猜它是函数的函数或同义词。
要排除变量,请在IDE中或使用此SQL搜索代码:
select * from dba_source where lower(text) like '%join_operator%';
要排除对象,请使用此SQL搜索所有对象:
select * from dba_objects where object_name = 'JOIN_OPERATOR';
<强>更新强>
PL/SQL和DBA_DEPENDENCIES
也可以帮助识别对象。
示例架构
alter session set plscope_settings = 'IDENTIFIERS:ALL';
create table search_lines(
search_id number, line_no number, parameter_name varchar2(100));
create or replace function join_operator_function return varchar2 is
begin
return 'asdf';
end;
/
create synonym join_operator for join_operator_function;
create or replace PROCEDURE assemble_default_where
is
CURSOR c_where_clause IS
SELECT DECODE(sl.parameter_name, 'track Location', join_operator)
FROM search_lines sl
ORDER BY line_no;
begin
null;
end;
/
PL / SCOPE示例
WITH v AS (
SELECT Line,
Col,
INITCAP(NAME) Name,
LOWER(TYPE) Type,
LOWER(USAGE) Usage,
USAGE_ID,
USAGE_CONTEXT_ID
FROM USER_IDENTIFIERS
WHERE Object_Name = 'ASSEMBLE_DEFAULT_WHERE'
AND Object_Type = 'PROCEDURE'
)
SELECT RPAD(LPAD(' ', 2*(Level-1)) ||
Name, 30, '.')||' '||
RPAD(Type, 30)||
RPAD(Usage, 30)
IDENTIFIER_USAGE_CONTEXTS
FROM v
START WITH USAGE_CONTEXT_ID = 0
CONNECT BY PRIOR USAGE_ID = USAGE_CONTEXT_ID
ORDER SIBLINGS BY Line, Col
/
Assemble_Default_Where........ procedure declaration
Assemble_Default_Where...... procedure definition
C_Where_Clause............ cursor declaration
Join_Operator_Function.. function call
DBA_DEPENDENCIES示例
select referenced_owner, referenced_name, referenced_type
from dba_dependencies
where owner = user
and name = 'ASSEMBLE_DEFAULT_WHERE';
REFERENCED_OWNER REFERENCED_NAME REFERENCED_TYPE
---------------- --------------- ---------------
SYS STANDARD PACKAGE
SYS SYS_STUB_FOR_PURITY_ANALYSIS PACKAGE
JHELLER_DBA JOIN_OPERATOR SYNONYM
JHELLER_DBA JOIN_OPERATOR_FUNCTION FUNCTION
JHELLER_DBA SEARCH_LINES TABLE