For tracing PLSQL code , Print function show output in DBMS Output as per Arguments.
1) For implementation of this function simply add
G_Debug_Enabled Variable and Function Specification in your package Specification. For enable tracing set G_Debug_Enabled as True before execute your code.
G_Debug_Enabled Boolean default false;
procedure print(pString in varchar2
, pText_1 in varchar2 default null
, pValue1 in varchar2 default null
, pText_2 in varchar2 default null
, pValue2 in varchar2 default null
, pText_3 in varchar2 default null
, pValue3 in varchar2 default null
, pText_4 in varchar2 default null
, pValue4 in varchar2 default null
, pText_5 in varchar2 default null
, pValue5 in varchar2 default null
, pText_6 in varchar2 default null
, pValue6 in varchar2 default null
, pText_7 in varchar2 default null
, pValue7 in varchar2 default null
, pText_8 in varchar2 default null
, pValue8 in varchar2 default null
, pText_9 in varchar2 default null
, pValue9 in varchar2 default null
);
procedure test_Print_function;
2) Add Function Body in Package Specification Body
procedure print(pString in varchar2
, pText_1 in varchar2 default null
, pValue1 in varchar2 default null
, pText_2 in varchar2 default null
, pValue2 in varchar2 default null
, pText_3 in varchar2 default null
, pValue3 in varchar2 default null
, pText_4 in varchar2 default null
, pValue4 in varchar2 default null
, pText_5 in varchar2 default null
, pValue5 in varchar2 default null
, pText_6 in varchar2 default null
, pValue6 in varchar2 default null
, pText_7 in varchar2 default null
, pValue7 in varchar2 default null
, pText_8 in varchar2 default null
, pValue8 in varchar2 default null
, pText_9 in varchar2 default null
, pValue9 in varchar2 default null
)
is
begin
if G_Debug_Enabled then
Dbms_output.put_line('$ '||pString||' : '||pText_1||' => '||pValue1||' '||pText_2||'
=> '||pValue2||' '||pText_3||' => '||pValue3||' '||pText_4||' => '||pValue4||' '||pText_5||' => '||pValue5||' '||pText_6||' => '||pValue6||' '||pText_7||' => '||pValue7||' '||pText_8||' => '||pValue8||' '||pText_9||' => '||pValue9);
end if;
end;
procedure test_Print_function
is
begin
print('Function Test','TransactionID',10,'EmployeeName','mFaisal');
end;
3) Now test test_print_function
begin
-- Call the procedure
PKG_wf_api.G_Debug_Enabled:=true;
PKG_wf_api.test_print_function;
end;
Output:
$ Function Test : TransactionID => 10 EmployeeName => mFaisal