DBA Data[Home] [Help]

PACKAGE BODY: APPS.XLA_UTIL

Source


1 PACKAGE BODY XLA_UTIL AS
2 /* $Header: xlautil.pkb 120.0 2003/11/22 02:29:05 weshen noship $ */
3 
4 /*===========================================================================*/
5 /* PRIVATE VARIABLES
6 /*===========================================================================*/
7 debug_flag		BOOLEAN := FALSE;
8 file_debug_flag		BOOLEAN := FALSE;
9 pg_fp           	utl_file.file_type;
10 
11 pg_query_context      	VARCHAR2(100) := NULL;
12 
13 /*===========================================================================*/
14 /* PRIVATE PROCEDURES/FUNCTIONS
15 /*===========================================================================*/
16 
17 PROCEDURE file_debug( text in varchar2 ) is
18 BEGIN
19   if file_debug_flag then
20     utl_file.put_line(pg_fp, text);
21     utl_file.fflush(pg_fp);
22   end if;
23 END;
24 
25 
26 /*===========================================================================*/
27 /* PUBLIC PROCEDURES/FUNCTIONS
28 /*===========================================================================*/
29 
30 PROCEDURE enable_debug is
31 BEGIN
32   debug_flag := TRUE;
33   dbms_output.enable;
34 END enable_debug;
35 
36 PROCEDURE enable_debug(buffer_size	NUMBER) is
37 BEGIN
38   debug_flag := TRUE;
39   dbms_output.enable( buffer_size );
40 END;
41 
42 PROCEDURE enable_debug(path_name in varchar2,
43                        file_name in varchar2 default 'DEFAULT') IS
44 BEGIN
45   if not file_debug_flag then	-- Ignore multiple calls to enable_debug
46     pg_fp := utl_file.fopen(path_name, file_name||'.dbg', 'w');
47     file_debug_flag := TRUE;
48   end if;
49 EXCEPTION
50   when utl_file.invalid_path then
51 	-- fnd_message.set_name('AR', 'GENERIC_MESSAGE');
52 	-- fnd_message.set_token('GENERIC_TEXT', 'Invalid path: '||path_name);
53 	app_exception.raise_exception;
54   when utl_file.invalid_mode then
55 	-- fnd_message.set_name('AR', 'GENERIC_MESSAGE');
56 	-- fnd_message.set_token('GENERIC_TEXT', 'Cannot open file '||file_name||
57 --				 ' in write mode.');
58 	app_exception.raise_exception;
59 END enable_debug;
60 
61 PROCEDURE disable_debug is
62 BEGIN
63   debug_flag := FALSE;
64 
65   if file_debug_flag then
66     file_debug_flag := FALSE;
67     utl_file.fclose(pg_fp);
68   end if;
69 END disable_debug;
70 
71 PROCEDURE debug(text	IN VARCHAR2) is
72   rest varchar2(32767);
73   buffer_overflow exception;
74   pragma exception_init(buffer_overflow, -20000);
75 BEGIN
76 
77   if file_debug_flag then
78     file_debug(text);
79   else
80     if debug_flag then
81         rest := text;
82         loop
83             if( rest is null ) then
84                 exit;
85             else
86                 dbms_output.put_line(substrb(rest, 1, 255));
87                 rest := substrb(rest, 256);
88             end if;
89 
90         end loop;
91     end if;
92   end if;
93 EXCEPTION
94   when buffer_overflow then
95       null;  -- buffer overflow, ignore
96   when others then
97       raise;
98 END debug;
99 
100 PROCEDURE set_query_context (
101 		p_context       IN  VARCHAR2) IS
102 BEGIN
103  pg_query_context := p_context;
104 END;
105 
106 FUNCTION get_query_context RETURN VARCHAR2 IS
107 BEGIN
108   RETURN ( pg_query_context );
109 END;
110 
111 -- lgandhi bug 2969915 Created a new function to check the the existence of the function in the data base.
112 -- Its a wrapper over  FND_FUNCTION.GET_FUNCTION_ID
113 -- returns: the function id, or NULL if it can't be found.
114 
115 
116 FUNCTION get_function_id(p_function_name in varchar2  ) RETURN NUMBER IS
117 BEGIN
118   RETURN (fnd_function.get_function_id (p_function_name));
119 END;
120 
121 
122 END XLA_UTIL;