DBA Data[Home] [Help]

PACKAGE BODY: APPS.AMS_ATCH_UPGRADE

Source


1 PACKAGE BODY AMS_ATCH_UPGRADE AS
2 /* $Header: amsvatub.pls 115.6 2002/12/05 01:04:08 rmajumda noship $ */
3 -- ===============================================================
4 -- Start of Comments
5 -- Package name
6 --          AMS_ATCH_UPGRADE
7 -- Purpose
8 --
9 -- History
10 --
11 -- NOTE
12 --
13 -- End of Comments
14 -- ===============================================================
15 
16 
17 G_PKG_NAME CONSTANT VARCHAR2(30):= 'AMS_ATCH_UPGRADE';
18 G_FILE_NAME CONSTANT VARCHAR2(12) := 'amsvatub.pls';
19 
20 
21 -- Hint: Primary key needs to be returned.
22 PROCEDURE Create_LOB_From_BFILE(
23                                  p_file_name IN Varchar2,
24 				 p_dir_name  IN Varchar2,
25 				 x_file_id   OUT NOCOPY  Number
26                               )
27 
28  IS
29    l_src_opened boolean := false;
30    l_dest_opened boolean := false;
31 
32    Dest_Loc BLOB;
33    Src_Loc  BFILE ;
34    amount   integer  := 50;
35 
36    l_lob_id  number;
37 
38    cursor c_get_next_lob_id is
39       select fnd_lobs_s.nextval
40       from dual;
41 
42 
43 BEGIN
44          Src_Loc  := BFILENAME(p_dir_name,p_file_name);
45 
46 	 --open the BFile
47 	 DBMS_LOB.OPEN(Src_Loc,DBMS_LOB.LOB_READONLY);
48 	 l_src_opened := true;
49 
50          OPEN c_get_next_lob_id;
51          FETCH c_get_next_lob_id INTO l_LOB_ID;
52          CLOSE c_get_next_lob_id;
53 
54 	 x_file_id := l_lob_id;
55 
56 	 --insert an empty lob into fnd_lobs
57 	 insert
58 	 into
59 	 fnd_lobs
60 	 (file_id,
61 	 file_name,
62 	 file_content_type,
63 	 file_data,
64 	 upload_date,
65 	 file_format,
66 	 program_name
67 	 )
68 	 values
69 	 (
70 	 l_LOB_ID,
71 	 p_file_name,
72 	 'image/html',
73 	 empty_blob(),
74 	 sysdate,
75 	 'image',
76 	 'AMS_CONTENT'
77 	 )
78 	 returning file_data into Dest_Loc;
79 
80 
81 	 --Now, open the lob
82 	 DBMS_LOB.OPEN(Dest_Loc,DBMS_LOB.LOB_READWRITE);
83 
84 	 l_dest_opened := true;
85 
86 	 --Now, load the lob from BFILE
87 	 DBMS_LOB.LOADFROMFILE(Dest_Loc,Src_Loc,Amount);
88 
89 	 DBMS_LOB.CLOSE(DEST_LOC);
90 	 DBMS_LOB.CLOSE(Src_Loc);
91 
92 EXCEPTION
93     when others then
94         if (l_dest_opened) then
95 	   DBMS_LOB.CLOSE(DEST_LOC);
96         end if;
97         if (l_src_opened) then
98 	   DBMS_LOB.CLOSE(Src_Loc);
99         end if;
100 	raise;
101 
102 END;
103 
104 END;