Last active
August 29, 2015 14:23
-
-
Save jonbartlett/ab450154885c56789ece to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE PACKAGE %FILE% IS | |
/* | |
* %FFILE% | |
* Copyright (C) %YEAR% %USER% <%MAIL%> | |
* | |
* Distributed under terms of the %LICENSE% license. | |
* | |
* $Date$ | |
* $Revision$ | |
* $Author$ | |
* | |
* $HeadURL$ | |
* $Id$ | |
* | |
*/ | |
-- | |
-- | |
--+===============================================================================+ | |
--| | | |
--| Procedure : main | | |
--| Description: | | |
--| Returns : none | | |
--| | | |
--+===============================================================================+ | |
procedure main (pv_param1 varchar2(50) | |
,pv_param2 varchar2(50)); | |
-- | |
-- | |
end %FILE% | |
/ | |
show errors | |
exit | |
create or replace package body %FILE% | |
is | |
/* | |
* %FFILE% | |
* Copyright (C) %YEAR% %USER% <%MAIL%> | |
* | |
* Distributed under terms of the %LICENSE% license. | |
* | |
* $Date$ | |
* $Revision$ | |
* $Author$ | |
* | |
* $HeadURL$ | |
* $Id$ | |
* | |
*/ | |
-- | |
gv_package_name constant varchar2(64) := '%FILE%'; | |
-- | |
gn_return_success constant number := 0; | |
gn_return_warning constant number := 1; | |
gn_return_error constant number := 2; | |
-- | |
type error_rec_type is record | |
( proc_name varchar2(32000) | |
, error_msg varchar2(32000) | |
, sqlerrm varchar2(32000)); | |
-- | |
type error_stack_type is table of error_rec_type index by binary_integer; | |
-- | |
g_error_stack error_stack_type; | |
-- | |
-- | |
--+===============================================================================+ | |
--| | | |
--| Procedure : log | | |
--| Description: | | |
--| Returns : none | | |
--| | | |
--+===============================================================================+ | |
procedure log (msg in varchar2, pv_proc_name in varchar2) | |
is | |
-- | |
begin | |
-- | |
fnd_file.put_line(fnd_file.log, pv_proc_name||': '||msg); | |
-- | |
end log; | |
-- | |
-- | |
--+===============================================================================+ | |
--| | | |
--| Procedure : out | | |
--| Description: | | |
--| Returns : none | | |
--| | | |
--+===============================================================================+ | |
procedure out (msg in varchar2) | |
is | |
-- | |
begin | |
-- | |
fnd_file.put_line(fnd_file.output, msg); | |
-- | |
end out; | |
-- | |
-- | |
--+===============================================================================+ | |
--| | | |
--| Procedure : add_error | | |
--| Description: | | |
--| Returns : none | | |
--| | | |
--+===============================================================================+ | |
procedure add_error (pv_error_msg in varchar2 | |
,pv_sqlerrm in varchar2 default null | |
,pv_proc_name in varchar2) | |
is | |
-- | |
l_cnt number; | |
-- | |
begin | |
-- | |
l_cnt := g_error_stack.count; | |
g_error_stack(l_cnt+1).proc_name := pv_proc_name; | |
g_error_stack(l_cnt+1).error_msg := pv_error_msg; | |
g_error_stack(l_cnt+1).sqlerrm := pv_sqlerrm; | |
-- | |
end add_error; | |
-- | |
-- | |
--+===============================================================================+ | |
--| | | |
--| Procedure : log_error_stack | | |
--| Description: | | |
--| Returns : none | | |
--| | | |
--+===============================================================================+ | |
procedure log_error_stack | |
is | |
-- | |
cv_proc_name constant varchar2(50) := 'log_error_stack'; | |
-- | |
begin | |
-- | |
out(' '); | |
out('** ERROR STACK **'); | |
-- | |
for i in g_error_stack.first..g_error_stack.last | |
loop | |
-- | |
out('Message: '|| g_error_stack(i).error_msg); | |
out('Sqlerrm: '|| g_error_stack(i).sqlerrm); | |
out('Procedure: '|| g_error_stack(i).proc_name); | |
out('------------------------------------------------------'); | |
-- | |
end loop; | |
-- | |
-- | |
end log_error_stack; | |
-- | |
-- | |
--+===============================================================================+ | |
--| | | |
--| Function : check_exists | | |
--| Description: checks something | | |
--| Returns : boolean | | |
--| | | |
--+===============================================================================+ | |
function check_exists (pv_param1 in varchar2(10) | |
,pv_param2 in varchar2(10)) | |
return boolean | |
is | |
-- | |
cv_proc_name constant varchar2(50) := 'check_exists'; | |
-- | |
vb_exists boolean := false; | |
-- | |
begin | |
-- | |
log('+', cv_proc_name); | |
-- | |
log('pv_param1: '||pv_param1, cv_proc_name); | |
log('pv_param2: '||pv_param2, cv_proc_name); | |
-- | |
-- | |
if 1 = 2 then | |
-- | |
vb_exists := true; | |
-- | |
end if; | |
-- | |
log('-', cv_proc_name); | |
-- | |
return (vb_exists); | |
-- | |
exception | |
when others then | |
-- | |
log('unexpected exception: '||sqlerrm, cv_proc_name); | |
-- | |
add_error (pv_error_msg => 'unexpected expection' | |
,pv_sqlerrm => sqlerrm | |
,pv_proc_name => cv_proc_name); | |
-- | |
raise; | |
-- | |
end check_exists; | |
-- | |
-- | |
--+===============================================================================+ | |
--| | | |
--| Procedure : main | | |
--| Description: | | |
--| Returns : none | | |
--| | | |
--+===============================================================================+ | |
procedure main (pv_param1 varchar2(50) | |
,pv_param2 varchar2(50)) | |
is | |
-- | |
cv_proc_name constant varchar2(50) := 'main'; | |
-- | |
begin | |
-- | |
log('+', cv_proc_name); | |
-- | |
log('pv_param1: '||pv_param1, cv_proc_name); | |
log('pv_param2: '||pv_param2, cv_proc_name); | |
-- | |
-- | |
-- %HERE% | |
-- | |
log('-', cv_proc_name); | |
-- | |
exception | |
when others then | |
-- | |
log('unexpected exception: '||sqlerrm, cv_proc_name); | |
-- | |
add_error (pv_error_msg => 'unexpected expection' | |
,pv_sqlerrm => sqlerrm | |
,pv_proc_name => cv_proc_name); | |
-- | |
raise; | |
-- | |
end main; | |
-- | |
end %FILE% | |
/ | |
show errors | |
exit | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment