[Home] [Help]
PACKAGE BODY: APPS.OZF_TP_UTIL_PVT
Source
1 PACKAGE BODY OZF_TP_UTIL_PVT AS
2 /* $Header: ozfvtpub.pls 120.1 2005/09/26 16:42:42 mkothari noship $ */
3 VERSION CONSTANT CHAR(80) := '$Header: ozfvtpub.pls 120.1 2005/09/26 16:42:42 mkothari noship $';
4
5
6 -- ------------------------
7 -- Global Variables
8 -- ------------------------
9 g_debug BOOLEAN := FALSE;
10 g_timer_start DATE := NULL;
11 g_duration NUMBER := NULL;
12
13
14 PROCEDURE initialize(
15 p_log_file VARCHAR2,
16 p_out_file VARCHAR2,
17 p_directory VARCHAR2) IS
18 BEGIN
19 g_debug := TRUE;
20
21 /*
22 FND_FILE.PUT_NAMES(
23 p_log_file,
24 p_out_file,
25 NVL(p_directory, fnd_profile.value('BIS_DEBUG_LOG_DIRECTORY')));
26 */
27
28
29 END initialize;
30
31
32 PROCEDURE put_timestamp(
33 p_text VARCHAR2) IS
34 BEGIN
35 put_line(p_text||' - '||to_char(sysdate, 'MM/DD/YYYY HH24:MI:SS'));
36 END put_timestamp;
37
38
39
40 PROCEDURE start_timer IS
41 BEGIN
42 g_duration := 0;
43 g_timer_start := sysdate;
44 END start_timer;
45
46
47
48 PROCEDURE stop_timer IS
49 BEGIN
50
51 IF g_timer_start IS NULL THEN
52 g_duration := 0;
53 ELSE
54 g_duration := sysdate - g_timer_start;
55 END IF;
56 g_timer_start := NULL;
57
58 END stop_timer;
59
60
61 PROCEDURE print_timer(
62 p_text VARCHAR2)
63 IS
64 l_duration NUMBER := NULL;
65 BEGIN
66 IF (g_timer_start IS NOT NULL) THEN
67 l_duration := sysdate - g_timer_start;
68 ELSE
69 l_duration := g_duration;
70 END IF;
71
72 IF (l_duration IS NOT NULL) THEN
73 put_line(p_text||' - '||
74 to_char(floor(l_duration)) ||' Days '||
75 to_char(mod(floor(l_duration*24), 24))||':'||
76 to_char(mod(floor(l_duration*24*60), 60))||':'||
77 to_char(mod(floor(l_duration*24*60*60), 60)));
78 END IF;
79
80 END print_timer;
81
82
83
84 PROCEDURE debug_line(
85 p_text VARCHAR2) IS
86 BEGIN
87 IF (g_debug) THEN
88 put_line(p_text);
89 END IF;
90 END debug_line;
91
92
93
94 PROCEDURE put_line(
95 p_text VARCHAR2) IS
96 BEGIN
97 FND_FILE.PUT_LINE(FND_FILE.LOG, p_text);
98
99 -- DBMS_OUTPUT.PUT_LINE( to_char(sysdate,'DD-MON-YYYY HH24:MI:SS') || '-- ' ||p_text);
100
101 END put_line;
102
103
104 FUNCTION get_schema_name(
105 p_app_short_name in varchar2 default 'OZF'
106 ) return varchar2 IS
107 l_status varchar2(512);
108 l_industry varchar2(512);
109 l_schema varchar2(512);
110 BEGIN
111 if( fnd_installation.get_app_info( p_app_short_name,
112 l_status, l_industry, l_schema ) )
113 then
114 return l_schema;
115 else
116 return null;
117 end if;
118 END get_schema_name;
119
120 Function get_utl_file_dir return VARCHAR2 IS
121 l_dir VARCHAR2(1000);
122 l_utl_dir VARCHAR2(100);
123 l_count NUMBER := 0;
124 l_log_begin NUMBER := 0;
125 l_log_end NUMBER := 0;
126 l_comma_pos NUMBER := 0;
127 l_dummy NUMBER;
128
129 BEGIN
130 SELECT value into l_dir
131 FROM v$parameter where upper(name) = 'UTL_FILE_DIR';
132
133 l_dir := l_dir || ','; -- Add sentinel
134
135 l_log_begin := INSTR(l_dir, '/log');
136
137 IF (l_log_begin = 0) THEN /* then get the first string */
138 l_utl_dir := substr(l_dir, 1, INSTR(l_dir, ',') - 1);
139 return l_utl_dir;
140 END IF;
141 l_log_end := INSTR(l_dir, ',', l_log_begin) - 1;
142
143 --have now determined the first occurrence of '/log' and the end pos
144 -- now to determine the start position of the log directory
145
146 l_dir := substr(l_dir, 0, l_log_end);
147
148 LOOP
149 l_comma_pos := INSTR(l_dir, ',', l_comma_pos+1);
150 IF (l_comma_pos <> 0) THEN
151 l_count := l_comma_pos + 1;
152 END IF;
153
154 EXIT WHEN l_comma_pos = 0;
155 END LOOP;
156
157 l_utl_dir := substr(l_dir, l_count+1, l_log_end);
158
159 RETURN l_utl_dir;
160
161 EXCEPTION
162 when others then
163 return null;
164 END;
165
166
167
168 END OZF_TP_UTIL_PVT;