1 package body WF_TEMP_LOB as
2 /* $Header: wflobb.pls 115.1 2003/09/10 12:16:24 vshanmug noship $ */
3
4 function GetLob(p_lob_tab in out nocopy wf_temp_lob_table_type)
5 return pls_integer
6 is
7 m pls_integer;
8 begin
9 -- search for a free lob
10 for i in 1..p_lob_tab.COUNT loop
11 if (p_lob_tab(i).free) then
12 p_lob_tab(i).free := false;
13 return(i);
14 end if;
15 end loop;
16
17 -- if we reach here, there is no temp lob available, create one.
18 m := p_lob_tab.COUNT+1;
19 p_lob_tab(m).temp_lob := null;
20 dbms_lob.createtemporary(p_lob_tab(m).temp_lob,true,DBMS_LOB.SESSION);
21 p_lob_tab(m).free := false;
22
23 return(m);
24
25 exception
26 when OTHERS then
27 wf_core.context('WF_TEMP_LOB','GetLob');
28 raise;
29 end GetLob;
30
31 procedure ReleaseLob(
32 p_lob_tab in out nocopy wf_temp_lob_table_type,
33 loc in pls_integer)
34 is
35 begin
36 if (loc > 0 and loc <= p_lob_tab.COUNT) then
37 if (not p_lob_tab(loc).free) then
38 dbms_lob.trim(p_lob_tab(loc).temp_lob,0);
39 p_lob_tab(loc).free := true;
40 end if;
41 end if;
42
43 exception
44 when OTHERS then
45 wf_core.context('WF_TEMP_LOB','ReleaseLob');
46 raise;
47 end ReleaseLob;
48
49 procedure ShowLob(p_lob_tab in out nocopy wf_temp_lob_table_type)
50 is
51 buf varchar2(200);
52 amt binary_integer := 200;
53 len integer;
54 begin
55 if (wf_log_pkg.level_procedure >= fnd_log.g_current_runtime_level) then
56 wf_log_pkg.string(wf_log_pkg.level_procedure,
57 'wf.plsql.WF_TEMP_LOB.ShowLOB.Begin',
58 'Count: '||to_char(p_lob_tab.COUNT));
59 end if;
60
61 for i in 1..p_lob_tab.COUNT loop
62 len := dbms_lob.getlength(p_lob_tab(i).temp_lob);
63
64 if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
65 wf_log_pkg.string(wf_log_pkg.level_statement,
66 'wf.plsql.WF_TEMP_LOB.ShowLOB.allocate',
67 'p_lob_tab('||to_char(i)||').temp_lob length:'||to_char(len));
68 end if;
69
70 if (p_lob_tab(i).free) then
71 if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
72 wf_log_pkg.string(wf_log_pkg.level_statement,
73 'wf.plsql.WF_TEMP_LOB.ShowLOB.free',
74 'p_lob_tab('||to_char(i)||').temp_lob is free.');
75 end if;
76 else
77 if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
78 wf_log_pkg.string(wf_log_pkg.level_statement,
79 'wf.plsql.WF_TEMP_LOB.ShowLOB.used',
80 'p_lob_tab('||to_char(i)||').temp_lob is in use.');
81 end if;
82
83 if (len = 0) then
84 if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
85 wf_log_pkg.string(wf_log_pkg.level_statement,
86 'wf.plsql.WF_TEMP_LOB.ShowLOB.empty',
87 'lob content: empty');
88 end if;
89 else
90 dbms_lob.read(p_lob_tab(i).temp_lob,amt,1,buf);
91 if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
92 wf_log_pkg.string(wf_log_pkg.level_statement,
93 'wf.plsql.WF_TEMP_LOB.ShowLOB.content',
94 'lob content: '||buf);
95 end if;
96 end if;
97 end if;
98 end loop;
99
100 exception
101 when OTHERS then
102 wf_core.context('WF_TEMP_LOB','ShowLob');
103 raise;
104 end ShowLob;
105
106 END WF_TEMP_LOB;