Hi,
I encountered the above error when attempting to call a function in a SQL statement. That called function in turn calls some other functions depending on the transaction type.
According to the documentation for the error message, I need to define Pragma Restrict_Refeerences. I have attempted to move the stand alone functions into a package and define a Pragma Restrict_References(fn_1, WNDS), however, I got a compilation error, PLS-00452: Subprogram fn_1 violates its associated pragma.
Can anyone provide me with some pointer as to how I may be able to resolve this issue?
The following are additional information:
Select A, B, C,
pkg_test.fn_1(TransType, ID)
From ( Select A, B, C TransType, ID
From Secondary_Table
where condition );
create or replace package pkg_test as
function fn_2 (i_key in Objects.ID%Type) return varchar2
v_result varchar2(50);
is
select 'Data_1: ' || field_1 || 'Data_2: ' || Field_2
into v_result
from Table_2
where ID = i_Key;
return v_result;
end fn_2;
function fn_3(i_key in Objects.id%Type) return varchar2
v_result varchar2(50);
v_type_ID Table_3.TypeID%type;
v_name Table_3.name%Type;
is
select name, type_id INTO v_Name, v_Type_ID
from Table_3
where ID = i_key;
v_Result := 'Label: ' || v_Name || ' Type name: ' ||
LookupTypeName(v_Type_ID);
--
-- LookupTypeName is a stand alone function
-- that contains a select ... INTO ... statement
-- and returns a varchar2 data type.
return v_result;
end fn_3;
FUNCTION fn_1 (
i_trans_type in Types.Data_Type%Type,
i_Primary_Key In Objects.ID%Type) Return Varchar2
is
if i_trans_type = 1 then
Return fn_2(i_Primary_Key);
else
Return fn_3(i_Primary_key);
end if;
end fn_1;
END;
I encountered the above error when attempting to call a function in a SQL statement. That called function in turn calls some other functions depending on the transaction type.
According to the documentation for the error message, I need to define Pragma Restrict_Refeerences. I have attempted to move the stand alone functions into a package and define a Pragma Restrict_References(fn_1, WNDS), however, I got a compilation error, PLS-00452: Subprogram fn_1 violates its associated pragma.
Can anyone provide me with some pointer as to how I may be able to resolve this issue?
The following are additional information:
Select A, B, C,
pkg_test.fn_1(TransType, ID)
From ( Select A, B, C TransType, ID
From Secondary_Table
where condition );
create or replace package pkg_test as
function fn_2 (i_key in Objects.ID%Type) return varchar2
v_result varchar2(50);
is
select 'Data_1: ' || field_1 || 'Data_2: ' || Field_2
into v_result
from Table_2
where ID = i_Key;
return v_result;
end fn_2;
function fn_3(i_key in Objects.id%Type) return varchar2
v_result varchar2(50);
v_type_ID Table_3.TypeID%type;
v_name Table_3.name%Type;
is
select name, type_id INTO v_Name, v_Type_ID
from Table_3
where ID = i_key;
v_Result := 'Label: ' || v_Name || ' Type name: ' ||
LookupTypeName(v_Type_ID);
--
-- LookupTypeName is a stand alone function
-- that contains a select ... INTO ... statement
-- and returns a varchar2 data type.
return v_result;
end fn_3;
FUNCTION fn_1 (
i_trans_type in Types.Data_Type%Type,
i_Primary_Key In Objects.ID%Type) Return Varchar2
is
if i_trans_type = 1 then
Return fn_2(i_Primary_Key);
else
Return fn_3(i_Primary_key);
end if;
end fn_1;
END;