-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy_entity.sql
More file actions
247 lines (246 loc) · 10.7 KB
/
copy_entity.sql
File metadata and controls
247 lines (246 loc) · 10.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
SET SERVEROUTPUT ON SIZE 1000000
SET LINESIZE 1000
----------------------------------------------------------------------------------------------------
-- Copyright 1998-2012, Unitask Inc., All rights reserved.
-- Filename: copy_entity.sql
-- Date: 2012-02-09
-- Author: aporter
--
-- Description:
-- This script will copy an existing UMD Entity and assist you in quickly creating new UMD entities
--
-- Usage Format:
-- sqlplus apps/<pass> @copy_entity.sql <EBS User> <Existing Entity> <New Entity>
--
-- Example:
-- sqlplus apps/apps @copy_entity.sql SYSADMIN FILE FILE_VCS
--
----------------------------------------------------------------------------------------------------
--
-- Variables ...
--
DECLARE
v_user_name VARCHAR(100) := UPPER('&1');
v_user_id NUMBER := 0;
v_old_entity_name VARCHAR2(30) := UPPER('&2');
v_old_entity_id NUMBER := 0;
v_new_entity_name VARCHAR2(30) := UPPER('&3');
v_new_entity_exists VARCHAR2(10);
v_new_entity_id NUMBER := 0;
v_entity_ldr_param_id NUMBER := 0;
CURSOR c_user_id IS
SELECT user_id
FROM FND_USER
WHERE user_name = v_user_name;
CURSOR c_old_entity_id IS
SELECT entity_id
FROM xxpck_entities
WHERE entity_name = v_old_entity_name;
CURSOR c_new_entity_exists IS
SELECT 'X'
FROM xxpck_entities
WHERE entity_name = v_new_entity_name;
--
-- Let the Fun Begin ...
--
BEGIN
OPEN c_user_id;
FETCH c_user_id INTO v_user_id;
--
-- Check to see if we have a valid EBS user Name/Id
--
IF (c_user_id%FOUND) THEN
DBMS_OUTPUT.PUT_LINE('Found FND_USER row for user name: '||v_user_name||' id: '||TO_CHAR(v_user_id));
OPEN c_old_entity_id;
FETCH c_old_entity_id into v_old_entity_id;
--
-- Check to see if we have an existing UMD Entity
--
IF (c_old_entity_id%FOUND) THEN
DBMS_OUTPUT.PUT_LINE('Found XXPCK_ENTITY row for UMD Entity: '||v_old_entity_name||' id: '||TO_CHAR(v_old_entity_id));
OPEN c_new_entity_exists;
FETCH c_new_entity_exists INTO v_new_entity_exists;
--
-- Check to see if the 'new' entity alreay exists
--
IF (c_new_entity_exists%FOUND) THEN
DBMS_OUTPUT.PUT_LINE('New UMD Entity [' || v_new_entity_name || '] already exists. Exiting program.');
ELSE -- (c_new_entity_exists%FOUND)
DBMS_OUTPUT.PUT_LINE('About to create new UMD Entity [' || v_new_entity_name || '].');
--
-- Time to get to work...
---
-- Get the new Entity ID from the sequence number
--
SELECT xxpck_entities_s.nextval INTO v_new_entity_id FROM dual;
dbms_output.put_line('New Id is '||v_new_entity_id||' ');
if (v_new_entity_id > 0) then
-- Time to get to work...
INSERT INTO xxpck_entities
(entity_id,
entity_name,
loader_id,
user_defined_flag,
created_by,
creation_date,
last_updated_by,
last_update_date,
download_string,
upload_string,
freeze_definition,
notify_on_create,
notify_on_update,
create_dist_list,
update_dist_list,
compile_date,
description,
attribute_category,
attribute1,
attribute2,
attribute3,
attribute4,
attribute5,
attribute6,
attribute7,
attribute8,
attribute9,
attribute10,
attribute11,
attribute12,
attribute13,
attribute14,
attribute15,
pre_download_tp,
pre_download_string,
post_download_tp,
post_download_string,
pre_upload_tp,
pre_upload_string,
post_upload_tp,
post_upload_string,
vcs_flag,
vcs_action,
vcs_project_root,
vcs_project_path,
vcs_file_calc_formula)
SELECT v_new_entity_id, -- entity_id
v_new_entity_name, -- entity_name
loader_id,
'Y', -- user_defined_flag
v_user_id, -- created_by
SYSDATE, -- creation_date
v_user_id, -- last_updated_by
SYSDATE, -- last_update_date
download_string,
upload_string,
'N', -- freeze_definition
notify_on_create,
notify_on_update,
create_dist_list,
update_dist_list,
NULL, -- compile_date
description,
attribute_category,
attribute1,
attribute2,
attribute3,
attribute4,
attribute5,
attribute6,
attribute7,
attribute8,
attribute9,
attribute10,
attribute11,
attribute12,
attribute13,
attribute14,
attribute15,
pre_download_tp,
pre_download_string,
post_download_tp,
post_download_string,
pre_upload_tp,
pre_upload_string,
post_upload_tp,
post_upload_string,
vcs_flag,
vcs_action,
vcs_project_root,
vcs_project_path,
vcs_file_calc_formula
FROM xxpck_entities
WHERE entity_id = v_old_entity_id;
-- Process the lines...
INSERT INTO xxpck_entity_ldr_params
(entity_ldr_param_id,
entity_id,
param_name,
required,
user_enabled,
created_by,
creation_date,
last_updated_by,
last_update_date,
assigment_type,
value_set,
default_value)
SELECT xxpck_entity_ldr_params_s.nextval, -- entity_ldr_param_id
v_new_entity_id, -- entity_id
param_name,
required,
user_enabled,
v_user_id, -- created_by
SYSDATE, -- creation_date
v_user_id, -- last_updated_by
SYSDATE, -- last_update_date
assigment_type,
value_set,
default_value
from (
select *
FROM xxpck_entity_ldr_params
WHERE entity_id = v_old_entity_id
ORDER BY entity_ldr_param_id
);
--
-- Inner order by query above is fix for sequence rules, see Oracle docs ...
--
-- We are done, save the work and put out a new message ...
--
COMMIT;
DBMS_OUTPUT.PUT_LINE(' ');
DBMS_OUTPUT.PUT_LINE('The new UMD Entity ' || v_new_entity_name || ' has been created!');
DBMS_OUTPUT.PUT_LINE(' ');
DBMS_OUTPUT.PUT_LINE('Next Steps:');
DBMS_OUTPUT.PUT_LINE('1. Edit the New Entity');
DBMS_OUTPUT.PUT_LINE('2. Change Description and other Metadata fields, but hold off on any functional changes till after verification');
DBMS_OUTPUT.PUT_LINE(' PLEASE NOTE: Entity Descriptions are used for LOV -- Choose words accordingly!');
DBMS_OUTPUT.PUT_LINE('3. Compile the New Entity before you can use it.');
DBMS_OUTPUT.PUT_LINE('4. Logout/Login EBS');
DBMS_OUTPUT.PUT_LINE('5. Verify Entity works just as the copied source entity');
DBMS_OUTPUT.PUT_LINE('6. Modify the new entity as required . . .');
DBMS_OUTPUT.PUT_LINE('7. Re-Compile as required . . .');
DBMS_OUTPUT.PUT_LINE('8. Migrate the New Entity to the target EBS instance(s)');
DBMS_OUTPUT.PUT_LINE(' ');
DBMS_OUTPUT.PUT_LINE('Enjoy your new UMD Entity');
ELSE -- (v_new_entity_id%FOUND)
DBMS_OUTPUT.PUT_LINE('Can''t get new entity id! ');
END IF; -- (v_new_entity_id%FOUND)
END IF; -- (c_new_entity_exists%FOUND)
CLOSE c_new_entity_exists;
ELSE -- (c_old_entity_id%FOUND)
DBMS_OUTPUT.PUT_LINE('Can''t file existing UMD Entity row for: ' || v_old_entity_name);
END IF; -- (c_old_entity_id%FOUND)
CLOSE c_old_entity_id;
ELSE -- (c_user_id%FOUND)
DBMS_OUTPUT.PUT_LINE('Can''t file FND_USER row for user name: ' || v_user_name);
END IF; -- (c_user_id%FOUND)
CLOSE c_user_id;
DBMS_OUTPUT.PUT_LINE(' ');
EXCEPTION
when others then
dbms_output.put_line('Error: '||sqlerrm||'');
RAISE;
END;
/