1 package body FND_FILE_MIME_TYPES_PKG as
2 /* $Header: AFATFMTB.pls 120.3.12020000.2 2012/12/04 20:29:38 ctilley ship $ */
3
4 PROCEDURE INSERT_ROW (X_ROWID in out nocopy VARCHAR2,
5 X_MIME_TYPE in VARCHAR2,
6 X_CP_FORMAT_CODE in VARCHAR2 DEFAULT NULL,
7 X_CTX_FORMAT_CODE in VARCHAR2 default 'IGNORE',
8 X_CREATION_DATE in DATE DEFAULT SYSDATE,
9 X_CREATED_BY in NUMBER,
10 X_LAST_UPDATE_DATE in DATE DEFAULT SYSDATE,
11 X_LAST_UPDATED_BY in NUMBER,
12 X_LAST_UPDATE_LOGIN in NUMBER DEFAULT NULL,
13 X_FILE_EXT in VARCHAR2,
14 X_ALLOW_FILE_UPLOAD in VARCHAR2) IS
15
16 cursor C is select rowid from fnd_mime_types
17 where lower(mime_type) = lower(x_mime_type)
18 and nvl(lower(file_ext),'NULL') = nvl(lower(x_file_ext),'NULL');
19
20 cursor cnt is select count(*) from fnd_mime_types
21 where lower(mime_type) = lower(x_mime_type)
22 and nvl(lower(file_ext),'NULL') = nvl(lower(x_file_ext),'NULL');
23
24 chk_exists number;
25 x_mime_type_id number;
26 BEGIN
27 open cnt;
28 fetch cnt into chk_exists;
29
30 /* Checking if a record exists before attempting to insert a record.
31 * Using 2 cursors so that whether a record exists or not the rowid
32 * can be retrieved and returned to the caller
33 */
34
35 if (chk_exists = 0) then
36 select fnd_mime_types_s.NEXTVAL into x_mime_type_id from dual;
37
38 INSERT INTO fnd_mime_types (mime_type_id,
39 mime_type,
40 cp_format_code,
41 ctx_format_code,
42 creation_date,
43 created_by,
44 last_update_date,
45 last_updated_by,
46 last_update_login,
47 file_ext,
48 allow_file_upload)
49 VALUES
50 (x_mime_type_id,
51 x_mime_type,
52 x_cp_format_code,
53 x_ctx_format_code,
54 x_creation_date,
55 x_created_by,
56 x_last_update_date,
57 x_last_updated_by,
58 x_last_update_login,
59 x_file_ext,
60 x_allow_file_upload);
61
62 end if;
63
64 /* Now get the rowid for the mime_type and file_ext specified.
65 * This could be for the newly created record or the previous existing record
66 */
67 open C;
68 fetch C into x_rowid;
69 if (C%NOTFOUND) then
70 close C;
71 raise no_data_found;
72 end if;
73
74 close cnt;
75 close C;
76 END INSERT_ROW;
77
78
79 PROCEDURE UPDATE_ROW (X_MIME_TYPE in VARCHAR2,
80 X_CP_FORMAT_CODE in VARCHAR2,
81 X_CTX_FORMAT_CODE in VARCHAR2,
82 X_LAST_UPDATE_DATE in DATE,
83 X_LAST_UPDATED_BY in NUMBER,
84 X_LAST_UPDATE_LOGIN in NUMBER DEFAULT NULL,
85 X_FILE_EXT in VARCHAR2,
86 X_ALLOW_FILE_UPLOAD in VARCHAR2) IS
87
88 l_cp_format_code varchar2(4);
89 l_ctx_format_code varchar2(20);
90 l_allow_file_upload varchar2(1);
91 l_file_ext varchar2(10);
92
93 BEGIN
94 begin
95 select decode(x_cp_format_code,fnd_file_mime_types_pkg.null_char,null,null,m.cp_format_code,x_cp_format_code),
96 decode(x_ctx_format_code,fnd_file_mime_types_pkg.null_char,null,null,m.ctx_format_code,x_ctx_format_code),
97 decode(x_file_ext,fnd_file_mime_types_pkg.null_char,null,null,m.file_ext,x_file_ext),
98 decode(x_allow_file_upload,fnd_file_mime_types_pkg.null_char,null,null,m.allow_file_upload,x_allow_file_upload)
99 into l_cp_format_code, l_ctx_format_code, l_file_ext, l_allow_file_upload
100 from fnd_mime_types m
101 where lower(mime_type) = lower(x_mime_type)
102 and lower(file_ext) = lower(x_file_ext);
103 exception when no_data_found then
104
105 select decode(x_cp_format_code,fnd_file_mime_types_pkg.null_char,null,null,m.cp_format_code,x_cp_format_code),
106 decode(x_ctx_format_code,fnd_file_mime_types_pkg.null_char,null,null,m.ctx_format_code,x_ctx_format_code),
107 decode(x_file_ext,fnd_file_mime_types_pkg.null_char,null,null,m.file_ext,x_file_ext),
108 decode(x_allow_file_upload,fnd_file_mime_types_pkg.null_char,null,null,m.allow_file_upload,x_allow_file_upload)
109 into l_cp_format_code, l_ctx_format_code, l_file_ext, l_allow_file_upload
110 from fnd_mime_types m
111 where lower(mime_type) = lower(x_mime_type);
112 end;
113
114
115 update fnd_mime_types
116 set cp_format_code = l_cp_format_code,
117 ctx_format_code = l_ctx_format_code,
118 file_ext = l_file_ext,
119 allow_file_upload = l_allow_file_upload
120 where mime_type = x_mime_type;
121
122 END UPDATE_ROW;
123
124
125 PROCEDURE DELETE_ROW (X_MIME_TYPE in VARCHAR2,
126 X_FILE_EXT in VARCHAR2) IS
127
128 BEGIN
129 delete from fnd_mime_types
130 where lower(mime_type) like lower(x_mime_type)
131 and lower(file_ext) like lower(x_file_ext);
132
133 if (sql%notfound) then
134 raise no_data_found;
135 end if;
136
137 END DELETE_ROW;
138
139 PROCEDURE SET_FILE_EXT (X_MIME_TYPE IN VARCHAR2, X_FILE_EXT IN VARCHAR2) IS
140
141 BEGIN
142 UPDATE FND_MIME_TYPES
143 SET FILE_EXT = X_FILE_EXT
144 WHERE lower(MIME_TYPE) like lower(X_MIME_TYPE);
145
146 END;
147
148 PROCEDURE SET_ALLOW_UPLOAD (X_FILE_EXT IN VARCHAR2, X_ALLOW_FILE_UPLOAD IN VARCHAR2) IS
149
150 BEGIN
151 UPDATE FND_MIME_TYPES
152 SET ALLOW_FILE_UPLOAD = X_ALLOW_FILE_UPLOAD
153 WHERE lower(FILE_EXT) = lower(X_FILE_EXT);
154
155 END;
156
157
158 END FND_FILE_MIME_TYPES_PKG;