1 PACKAGE BODY JTY_WEBADI_OTH_TERR_UPDATE_PKG AS
2 /* $Header: jtfowupb.pls 120.77 2012/05/18 10:21:44 nbombili ship $ */
3
4 -- Start of Comments
5
6 -- ---------------------------------------------------
7
8 -- PACKAGE NAME: JTY_WEBADI_OTH_TERR_UPDATE_PKG
9
10 -- ---------------------------------------------------
11
12
13
14 -- PURPOSE
15
16 -- upload other territories information from excel
17
18 --
19
20 --
21
22 -- PROCEDURES:
23
24 -- (see below for specification)
25
26 --
27
28 --
29
30 -- HISTORY
31
32 -- 09/01/2005 mhtran Package Body Created
33 -- 02/03/2005 MHTRAN Modified
34 --
35
36 -- End of Comments
37
38 --
39
40
41 TYPE number_tbl_type is table of NUMBER index by PLS_INTEGER;
42 TYPE varchar2_tbl_type is table of VARCHAR2(360) index by PLS_INTEGER;
43 TYPE date_tbl_type is table of DATE index by PLS_INTEGER;
44 TYPE var_1_tbl_type is table of VARCHAR2(1) index by PLS_INTEGER;
45 TYPE var_2000_tbl_type is table of VARCHAR2(2000) index by PLS_INTEGER;
46
47 TYPE Terr_Values_Rec_Type IS RECORD
48 (TERR_VALUE_ID number_tbl_type,
49 LAST_UPDATE_DATE date_tbl_type,
50 LAST_UPDATED_BY number_tbl_type,
51 CREATION_DATE date_tbl_type,
52 CREATED_BY number_tbl_type,
53 LAST_UPDATE_LOGIN number_tbl_type,
54 TERR_QUAL_ID number_tbl_type,
55 COMPARISON_OPERATOR varchar2_tbl_type,
56 LOW_VALUE_CHAR varchar2_tbl_type,
57 HIGH_VALUE_CHAR varchar2_tbl_type,
58 LOW_VALUE_NUMBER number_tbl_type,
59 HIGH_VALUE_NUMBER number_tbl_type,
60 INTEREST_TYPE_ID number_tbl_type,
61 PRIMARY_INTEREST_CODE_ID number_tbl_type,
62 SECONDARY_INTEREST_CODE_ID number_tbl_type,
63 CURRENCY_CODE varchar2_tbl_type,
64 ID_USED_FLAG var_1_tbl_type,
65 LOW_VALUE_CHAR_ID number_tbl_type,
66 ORG_ID number_tbl_type,
67 VALUE1_ID number_tbl_type,
68 VALUE2_ID number_tbl_type,
69 VALUE3_ID number_tbl_type
70 );
71
72 TYPE Terr_Qual_Rec_Type IS RECORD
73 ( CONVERT_TO_ID_FLAG var_1_tbl_type,
74 TERR_QUAL_ID number_tbl_type,
75 qual_value_id number_tbl_type,
76 qual_value1 varchar2_tbl_type,
77 qual_value2 varchar2_tbl_type,
78 qual_value3 varchar2_tbl_type,
79 qualifier_num number_tbl_type,
80 html_lov_sql1 var_2000_tbl_type,
81 qual_cond varchar2_tbl_type,
82 qual_type varchar2_tbl_type,
83 LAST_UPDATE_DATE date_tbl_type,
84 LAST_UPDATED_BY number_tbl_type,
85 CREATION_DATE date_tbl_type,
86 CREATED_BY number_tbl_type,
87 LAST_UPDATE_LOGIN number_tbl_type,
88 TERR_ID number_tbl_type,
89 QUAL_USG_ID number_tbl_type,
90 ORG_ID number_tbl_type
91 );
92
93 TYPE Terr_values_out_rec_type IS RECORD
94 ( TERR_VALUE_ID number_tbl_type,
95 TERR_QUAL_ID number_tbl_type
96 );
97
98 PROCEDURE debugmsg(msg VARCHAR2) IS
99 BEGIN
100 if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
101 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'jtf.plsql.JTY_WEBADI_OTH_TERR_UPDATE_PKG', msg);
102 end if;
103 END debugmsg;
104
105 PROCEDURE get_hierarchy
106 ( p_user_sequence IN number,
107 p_intf_type IN varchar2 default 'U',
108 x_return_status out nocopy varchar2,
109 x_msg_data out nocopy varchar2
110 )
111 IS
112
113 cursor get_hierarchy_csr
114 ( v_user_sequence number,
115 v_intf_type varchar2) IS
116 SELECT TERR_NAME, trim(HIERARCHY) hierarchy, ORG_ID, org_name
117 FROM JTY_WEBADI_OTH_TERR_INTF
118 where user_sequence = v_user_sequence
119 and interface_type = v_intf_type
120 and header = 'TERR'
121 and lay_seq_num is not null
122 and status is null;
123
124 type get_hierarchy_type is TABLE of get_hierarchy_csr%rowtype INDEX BY PLS_INTEGER;
125
126 l_hierarchy_tbl get_hierarchy_type;
127 l_parent_id number;
128 l_anc_id number;
129 l_instr number;
130 l_count number;
131 l_terr varchar2(2000);
132 l_parent varchar2(2000);
133 l_return_csr NUMBER;
134
135 BEGIN
136
137 x_return_status := FND_API.G_RET_STS_SUCCESS;
138 /*
139 update JTY_WEBADI_OTH_TERR_INTF
140 set parent_terr_id = null
141 where user_sequence = p_user_sequence
142 and interface_type = p_intf_type
143 and hierarchy is null;
144 */
145 --dbms_output.put_line('Start hierarchy');
146 -- get parent_id from hierarchy columns
147 open get_hierarchy_csr(p_user_sequence, p_intf_type);
148 fetch get_hierarchy_csr bulk collect into l_hierarchy_tbl;
149 close get_hierarchy_csr;
150
151 if l_hierarchy_tbl.count > 0 then
152 for c in l_hierarchy_tbl.first..l_hierarchy_tbl.last loop
153 l_parent_id := 1;
154 l_anc_id := 1;
155
156 if l_hierarchy_tbl(c).hierarchy is null then
157 -- no hierarchy found. Root node
158 l_parent := l_hierarchy_tbl(c).org_name;
159
160 update JTY_WEBADI_OTH_TERR_INTF
161 set parent_terr_id = l_parent_id
162 , parent_terr_name = l_parent
163 where terr_name = l_hierarchy_tbl(c).terr_name
164 and user_sequence = p_user_sequence
165 and interface_type = p_intf_type;
166
167 --dbms_output.put_line('hierarchy updated');
168
169 else
170 l_terr := l_hierarchy_tbl(c).hierarchy;
171 l_instr := instr(l_terr,'->');
172 --dbms_output.put_line('l_instr,l_terr: '||l_instr||','||l_terr);
173 loop
174 if l_instr = 0 then
175 l_parent := l_terr;
176 --dbms_output.put_line('l_instr = 0, l_parent: '||l_parent);
177
178 select count(*) into l_count
179 from jtf_terr_all
180 where name = l_parent
181 and parent_territory_id = l_anc_id
182 and org_id = l_hierarchy_tbl(c).org_id;
183
184 case l_count
185 when 0 then
186 -- If this is a new heirarchy, setting its parent to CATCH ALL intially and updating it later to correct parent (populate_parent_id).
187 update JTY_WEBADI_OTH_TERR_INTF
188 set parent_terr_id = 1
189 , parent_terr_name = l_parent
190 where terr_name = l_hierarchy_tbl(c).terr_name
191 and user_sequence = p_user_sequence
192 and interface_type = p_intf_type;
193 when 1 then
194 -- lowest level parent_id found, update interface table
195 select terr_id into l_parent_id
196 from jtf_terr_all
197 where org_id = l_hierarchy_tbl(c).org_id
198 and name = l_parent
199 and parent_territory_id = l_anc_id;
200
201 -- Update mode only: Top down checking if new parent territory is already a child of the current territory
202 -- This fix is to avoid error ORA-01436: CONNECT BY loop in user data
203 BEGIN
204 SELECT COUNT(*)
205 INTO l_return_csr
206 FROM JTY_WEBADI_OTH_TERR_INTF j
207 WHERE j.terr_id = l_parent_id -- new parent territory id
208 AND user_sequence = p_user_sequence
209 and interface_type = p_intf_type
210 and action_flag = 'U' -- Update mode
211 CONNECT BY PRIOR j.terr_id = j.parent_terr_id
212 START WITH j.terr_name = l_hierarchy_tbl(c).terr_name; -- territory_id
213
214 IF (l_return_csr = 0 )THEN
215 update JTY_WEBADI_OTH_TERR_INTF
216 set parent_terr_id = l_parent_id
217 , parent_terr_name = l_parent
218 where terr_name = l_hierarchy_tbl(c).terr_name
219 and user_sequence = p_user_sequence
220 and interface_type = p_intf_type;
221
222 ELSE
223 x_return_status := fnd_api.g_ret_sts_error;
224 fnd_message.clear;
225 fnd_message.set_name('JTF', 'JTY_OTH_TERR_CIR_REF');
226 x_msg_data := fnd_message.GET();
227
228 UPDATE jty_webadi_oth_terr_intf
229 SET status = x_return_status,
230 error_msg = x_msg_data
231 WHERE terr_name = l_hierarchy_tbl(c).terr_name
232 AND user_sequence = p_user_sequence
233 AND interface_type = p_intf_type;
234 END IF;
235 EXCEPTION WHEN OTHERS THEN
236 IF SQLCODE = -01436 THEN
237 x_return_status := fnd_api.g_ret_sts_error;
238 fnd_message.clear;
239 fnd_message.set_name('JTF', 'JTY_OTH_TERR_CIR_REF');
240 x_msg_data := fnd_message.GET();
241
242 UPDATE jty_webadi_oth_terr_intf
243 SET status = x_return_status,
244 error_msg = x_msg_data
245 WHERE terr_name = l_hierarchy_tbl(c).terr_name
246 AND user_sequence = p_user_sequence
247 AND interface_type = p_intf_type;
248 END IF;
249 END;
250
251 else
252 x_return_status := FND_API.G_RET_STS_ERROR;
253 fnd_message.clear;
254 FND_MESSAGE.set_name ('JTF', 'JTY_OTH_TERR_NON_UNIQUE_TERR');
255 FND_MESSAGE.set_token ('POSITION', l_parent);
256 X_Msg_Data := fnd_message.get();
257 update JTY_WEBADI_OTH_TERR_INTF
258 set status = x_return_status
259 , error_msg = X_Msg_Data
260 where terr_name = l_hierarchy_tbl(c).terr_name
261 and user_sequence = p_user_sequence
262 and interface_type = p_intf_type;
263 end case;
264 EXIT;
265 else
266 l_parent := substr(l_terr,1,l_instr -1);
267 --dbms_output.put_line('l_parent: '||l_parent);
268
269 select count(*) into l_count
270 from jtf_terr_all
271 where name = l_parent
272 and parent_territory_id = l_anc_id
273 and org_id = l_hierarchy_tbl(c).org_id;
274
275 case l_count
276 when 0 then
277 l_parent := substr(l_terr,instr(l_terr,'->',-1)+2);
278 --dbms_output.put_line('case 0, l_parent: '||l_parent);
279 -- If this is a new heirarchy, setting its parent to CATCH ALL intially and updating it later to correct parent (populate_parent_id).
280 update JTY_WEBADI_OTH_TERR_INTF
281 set parent_terr_id = 1
282 , parent_terr_name = l_parent
283 where terr_name = l_hierarchy_tbl(c).terr_name
284 and user_sequence = p_user_sequence
285 and interface_type = p_intf_type;
286 exit;
287 when 1 then
288 select terr_id into l_parent_id
289 from jtf_terr_all
290 where org_id = l_hierarchy_tbl(c).org_id
291 and name = l_parent
292 and parent_territory_id = l_anc_id;
293 else
294 x_return_status := FND_API.G_RET_STS_ERROR;
295 fnd_message.clear;
296 FND_MESSAGE.set_name ('JTF', 'JTY_OTH_TERR_NON_UNIQUE_TERR');
297 FND_MESSAGE.set_token ('POSITION', l_parent);
298 X_Msg_Data := fnd_message.get();
299
300 update JTY_WEBADI_OTH_TERR_INTF
301 set status = x_return_status
302 , error_msg = X_Msg_Data
303 where terr_name = l_hierarchy_tbl(c).terr_name
304 and user_sequence = p_user_sequence
305 and interface_type = p_intf_type;
306 exit;
307 end case;
308
309 l_anc_id := l_parent_id;
310 l_terr := substr(l_terr, l_instr+2);
311 l_instr := instr(l_terr, '->');
312
313 --dbms_output.put_line('l_instr, l_terr, l_parent, l_anc_id: '||l_instr||', '||l_terr||', '||l_parent||', '||l_anc_id);
314
315 END IF; -- instr = 0
316 end loop; -- loop through instr
317 end if; -- hierarchy is null
318
319 end loop;
320 end if;
321
322 exception
323 when others then
324 x_return_status := FND_API.G_RET_STS_ERROR;
325 end get_hierarchy;
326
327 -- This procedure populates the parent terr id when new territory heirarchy is being created.
328
329 PROCEDURE populate_parent_id(
330 p_user_sequence IN NUMBER,
331 p_intf_type IN VARCHAR2 DEFAULT 'U',
332 p_hierarchy IN VARCHAR2,
333 p_org_id IN NUMBER,
334 p_terr_id IN NUMBER,
335 p_terr_name IN VARCHAR2,
336 x_return_status OUT nocopy VARCHAR2,
337 x_msg_data OUT nocopy VARCHAR2 )
338
339 IS
340 l_parent_id NUMBER;
341 l_anc_id NUMBER;
342 l_instr NUMBER;
343 l_count NUMBER;
344 l_terr VARCHAR2(2000);
345 l_parent VARCHAR2(2000);
346 l_return_csr NUMBER;
347
348 BEGIN
349
350 x_return_status := fnd_api.g_ret_sts_success;
351
352 l_parent_id := 1;
353 l_anc_id := 1;
354 l_terr := p_hierarchy;
355 l_instr := instr(l_terr, '->');
356 --dbms_output.put_line('l_instr,l_terr: '||l_instr||','||l_terr);
357 LOOP
358
359 IF l_instr = 0 THEN
360 l_parent := l_terr;
361 --dbms_output.put_line('l_instr = 0, l_parent: '||l_parent);
362
363 SELECT COUNT(*)
364 INTO l_count
365 FROM jtf_terr_all
366 WHERE name = l_parent
367 AND parent_territory_id = l_anc_id
368 AND org_id = p_org_id;
369
370 IF (l_count = 1 OR l_count = 0 ) THEN
371 -- lowest level parent_id found, update interface table
372 SELECT terr_id
373 INTO l_parent_id
374 FROM jtf_terr_all
375 WHERE org_id = p_org_id
376 AND name = l_parent
377 AND parent_territory_id = l_anc_id;
378
379 -- Top down checking if new parent territory is already a child of the current territory
380 -- This fix is to avoid error ORA-01436: CONNECT BY loop in user data
381 BEGIN
382 SELECT COUNT(*)
383 INTO l_return_csr
384 FROM jtf_terr_all j
385 WHERE j.terr_id = l_parent_id -- new parent territory id
386 CONNECT BY PRIOR j.terr_id = j.parent_territory_id
387 START WITH j.terr_id = p_terr_id; -- territory_id
388
389 IF (l_return_csr = 0 )THEN
390 UPDATE jtf_terr_all
391 SET parent_territory_id = l_parent_id
392 WHERE terr_id = p_terr_id;
393 ELSE
394 x_return_status := fnd_api.g_ret_sts_error;
395 fnd_message.clear;
396 fnd_message.set_name('JTF', 'JTY_OTH_TERR_CIR_REF');
397 x_msg_data := fnd_message.GET();
398
399 UPDATE jty_webadi_oth_terr_intf
400 SET status = x_return_status,
401 error_msg = x_msg_data
402 WHERE terr_name = p_terr_name
403 AND user_sequence = p_user_sequence
404 AND interface_type = p_intf_type;
405 END IF;
406 EXCEPTION WHEN OTHERS THEN
407 IF SQLCODE = -01436 THEN
408 x_return_status := fnd_api.g_ret_sts_error;
409 fnd_message.clear;
410 fnd_message.set_name('JTF', 'JTY_OTH_TERR_CIR_REF');
411 x_msg_data := fnd_message.GET();
412
413 UPDATE jty_webadi_oth_terr_intf
414 SET status = x_return_status,
415 error_msg = x_msg_data
416 WHERE terr_name = p_terr_name
417 AND user_sequence = p_user_sequence
418 AND interface_type = p_intf_type;
419 END IF;
420 END;
421
422 ELSE
423 x_return_status := fnd_api.g_ret_sts_error;
424 fnd_message.clear;
425 fnd_message.set_name('JTF', 'JTY_OTH_TERR_NON_UNIQUE_TERR');
426 fnd_message.set_token('POSITION', l_parent);
427 x_msg_data := fnd_message.GET();
428
429 UPDATE jty_webadi_oth_terr_intf
430 SET status = x_return_status,
431 error_msg = x_msg_data
432 WHERE terr_name = p_terr_name
433 AND user_sequence = p_user_sequence
434 AND interface_type = p_intf_type;
435
436 END IF;
437 EXIT;
438
439 ELSE
440 l_parent := SUBSTR(l_terr, 1, l_instr -1);
441 --dbms_output.put_line('l_parent: '||l_parent);
442
443 SELECT COUNT(*)
444 INTO l_count
445 FROM jtf_terr_all
446 WHERE name = l_parent
447 AND parent_territory_id = l_anc_id
448 AND org_id = p_org_id;
449
450 IF l_count = 1 THEN
451 SELECT terr_id
452 INTO l_parent_id
453 FROM jtf_terr_all
454 WHERE org_id = p_org_id
455 AND name = l_parent
456 AND parent_territory_id = l_anc_id;
457
458 --Bug 9204941
459 ELSIF l_count = 0 THEN
460
461 SELECT terr_id
462 INTO l_parent_id
463 FROM jty_webadi_oth_terr_intf
464 WHERE org_id = p_org_id
465 AND terr_name = l_parent
466 AND parent_terr_id = l_anc_id;
467
468 ELSE
469 x_return_status := fnd_api.g_ret_sts_error;
470 fnd_message.clear;
471 fnd_message.set_name('JTF', 'JTY_OTH_TERR_NON_UNIQUE_TERR');
472 fnd_message.set_token('POSITION', l_parent);
473 x_msg_data := fnd_message.GET();
474
475 UPDATE jty_webadi_oth_terr_intf
476 SET status = x_return_status,
477 error_msg = x_msg_data
478 WHERE terr_name = p_terr_name
479 AND user_sequence = p_user_sequence
480 AND interface_type = p_intf_type;
481
482 EXIT;
483
484 END IF;
485
486 l_anc_id := l_parent_id;
487 l_terr := SUBSTR(l_terr, l_instr + 2);
488 l_instr := instr(l_terr, '->');
489 END IF;
490
491 -- instr = 0
492 END LOOP;
493
494 -- loop through instr
495
496 EXCEPTION
497 WHEN others THEN
498 x_return_status := fnd_api.g_ret_sts_error;
499 END populate_parent_id;
500
501 PROCEDURE VALIDATE_TERRITORY_RECORDS
502 ( P_USER_SEQUENCE IN NUMBER,
503 P_INTF_TYPE IN VARCHAR2,
504 X_RETURN_STATUS OUT NOCOPY VARCHAR2,
505 X_MSG_DATA OUT NOCOPY VARCHAR2
506 ) IS
507 l_action_flag varchar2(1) := 'U';
508 l_header varchar2(15);
509 l_count number;
510
511 CURSOR get_qual_csr(
512 v_user_sequence number,
513 v_intf_type varchar2,
514 v_header varchar2) IS
515 select jqh.qualifier_name, sub.lay_seq_num
516 from JTY_WEBADI_QUAL_HEADER jqh,
517 (
518 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
519 1 qual_num
520 FROM JTY_WEBADI_OTH_TERR_INTF jut
521 where jut.USER_SEQUENCE = v_user_sequence
522 and jut.status is null
523 and jut.qual1_value1 is not null
524 and jut.INTERFACE_TYPE = v_intf_type
525 and jut.header = v_header
526 union all
527 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
528 2 qual_num
529 FROM JTY_WEBADI_OTH_TERR_INTF jut
530 where jut.USER_SEQUENCE = v_user_sequence
531 and jut.status is null
532 and jut.qual2_value1 is not null
533 and jut.INTERFACE_TYPE = v_intf_type
534 and jut.header = v_header
535 union all
536 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
537 3 qual_num
538 FROM JTY_WEBADI_OTH_TERR_INTF jut
539 where jut.USER_SEQUENCE = v_user_sequence
540 and jut.status is null
541 and jut.qual3_value1 is not null
542 and jut.INTERFACE_TYPE = v_intf_type
543 and jut.header = v_header
544 union all
545 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
546 4 qual_num
547 FROM JTY_WEBADI_OTH_TERR_INTF jut
548 where jut.USER_SEQUENCE = v_user_sequence
549 and jut.status is null
550 and jut.qual4_value1 is not null
551 and jut.INTERFACE_TYPE = v_intf_type
552 and jut.header = v_header
553 union all
554 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
555 5 qual_num
556 FROM JTY_WEBADI_OTH_TERR_INTF jut
557 where jut.USER_SEQUENCE = v_user_sequence
558 and jut.status is null
559 and jut.qual5_value1 is not null
560 and jut.INTERFACE_TYPE = v_intf_type
561 and jut.header = v_header
562 union all
563 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
564 6 qual_num
565 FROM JTY_WEBADI_OTH_TERR_INTF jut
566 where jut.USER_SEQUENCE = v_user_sequence
567 and jut.status is null
568 and jut.qual6_value1 is not null
569 and jut.INTERFACE_TYPE = v_intf_type
570 and jut.header = v_header
571 union all
572 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
573 7 qual_num
574 FROM JTY_WEBADI_OTH_TERR_INTF jut
575 where jut.USER_SEQUENCE = v_user_sequence
576 and jut.status is null
577 and jut.qual7_value1 is not null
578 and jut.INTERFACE_TYPE = v_intf_type
579 and jut.header = v_header
580 union all
581 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
582 8 qual_num
583 FROM JTY_WEBADI_OTH_TERR_INTF jut
584 where jut.USER_SEQUENCE = v_user_sequence
585 and jut.status is null
586 and jut.qual8_value1 is not null
587 and jut.INTERFACE_TYPE = v_intf_type
588 and jut.header = v_header
589 union all
590 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
591 9 qual_num
592 FROM JTY_WEBADI_OTH_TERR_INTF jut
593 where jut.USER_SEQUENCE = v_user_sequence
594 and jut.status is null
595 and jut.qual9_value1 is not null
596 and jut.INTERFACE_TYPE = v_intf_type
597 and jut.header = v_header
598 union all
599 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
600 10 qual_num
601 FROM JTY_WEBADI_OTH_TERR_INTF jut
602 where jut.USER_SEQUENCE = v_user_sequence
603 and jut.status is null
604 and jut.qual10_value1 is not null
605 and jut.INTERFACE_TYPE = v_intf_type
606 and jut.header = v_header
607 union all
608 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
609 11 qual_num
610 FROM JTY_WEBADI_OTH_TERR_INTF jut
611 where jut.USER_SEQUENCE = v_user_sequence
612 and jut.status is null
613 and jut.qual11_value1 is not null
614 and jut.INTERFACE_TYPE = v_intf_type
615 and jut.header = v_header
616 union all
617 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
618 12 qual_num
619 FROM JTY_WEBADI_OTH_TERR_INTF jut
620 where jut.USER_SEQUENCE = v_user_sequence
621 and jut.status is null
622 and jut.qual12_value1 is not null
623 and jut.INTERFACE_TYPE = v_intf_type
624 and jut.header = v_header
625 union all
626 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
627 13 qual_num
628 FROM JTY_WEBADI_OTH_TERR_INTF jut
629 where jut.USER_SEQUENCE = v_user_sequence
630 and jut.status is null
631 and jut.qual13_value1 is not null
632 and jut.INTERFACE_TYPE = v_intf_type
633 and jut.header = v_header
634 union all
635 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
636 14 qual_num
637 FROM JTY_WEBADI_OTH_TERR_INTF jut
638 where jut.USER_SEQUENCE = v_user_sequence
639 and jut.status is null
640 and jut.qual14_value1 is not null
641 and jut.INTERFACE_TYPE = v_intf_type
642 and jut.header = v_header
643 union all
644 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
645 15 qual_num
646 FROM JTY_WEBADI_OTH_TERR_INTF jut
647 where jut.USER_SEQUENCE = v_user_sequence
648 and jut.status is null
649 and jut.qual15_value1 is not null
650 and jut.INTERFACE_TYPE = v_intf_type
651 and jut.header = v_header
652 union all
653 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
654 16 qual_num
655 FROM JTY_WEBADI_OTH_TERR_INTF jut
656 where jut.USER_SEQUENCE = v_user_sequence
657 and jut.status is null
658 and jut.qual16_value1 is not null
659 and jut.INTERFACE_TYPE = v_intf_type
660 and jut.header = v_header
661 union all
662 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
663 17 qual_num
664 FROM JTY_WEBADI_OTH_TERR_INTF jut
665 where jut.USER_SEQUENCE = v_user_sequence
666 and jut.status is null
667 and jut.qual17_value1 is not null
668 and jut.INTERFACE_TYPE = v_intf_type
669 and jut.header = v_header
670 union all
671 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
672 18 qual_num
673 FROM JTY_WEBADI_OTH_TERR_INTF jut
674 where jut.USER_SEQUENCE = v_user_sequence
675 and jut.status is null
676 and jut.qual18_value1 is not null
677 and jut.INTERFACE_TYPE = v_intf_type
678 and jut.header = v_header
679 union all
680 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
681 19 qual_num
682 FROM JTY_WEBADI_OTH_TERR_INTF jut
683 where jut.USER_SEQUENCE = v_user_sequence
684 and jut.status is null
685 and jut.qual19_value1 is not null
686 and jut.INTERFACE_TYPE = v_intf_type
687 and jut.header = v_header
688 union all
689 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
690 20 qual_num
691 FROM JTY_WEBADI_OTH_TERR_INTF jut
692 where jut.USER_SEQUENCE = v_user_sequence
693 and jut.status is null
694 and jut.qual20_value1 is not null
695 and jut.INTERFACE_TYPE = v_intf_type
696 and jut.header = v_header
697 union all
698 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
699 21 qual_num
700 FROM JTY_WEBADI_OTH_TERR_INTF jut
701 where jut.USER_SEQUENCE = v_user_sequence
702 and jut.status is null
703 and jut.qual21_value1 is not null
704 and jut.INTERFACE_TYPE = v_intf_type
705 and jut.header = v_header
706 union all
707 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
708 22 qual_num
709 FROM JTY_WEBADI_OTH_TERR_INTF jut
710 where jut.USER_SEQUENCE = v_user_sequence
711 and jut.status is null
712 and jut.qual22_value1 is not null
713 and jut.INTERFACE_TYPE = v_intf_type
714 and jut.header = v_header
715 union all
716 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
717 23 qual_num
718 FROM JTY_WEBADI_OTH_TERR_INTF jut
719 where jut.USER_SEQUENCE = v_user_sequence
720 and jut.status is null
721 and jut.qual23_value1 is not null
722 and jut.INTERFACE_TYPE = v_intf_type
723 and jut.header = v_header
724 union all
725 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
726 24 qual_num
727 FROM JTY_WEBADI_OTH_TERR_INTF jut
728 where jut.USER_SEQUENCE = v_user_sequence
729 and jut.status is null
730 and jut.qual24_value1 is not null
731 and jut.INTERFACE_TYPE = v_intf_type
732 and jut.header = v_header
733 union all
734 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
735 25 qual_num
736 FROM JTY_WEBADI_OTH_TERR_INTF jut
737 where jut.USER_SEQUENCE = v_user_sequence
738 and jut.status is null
739 and jut.qual25_value1 is not null
740 and jut.INTERFACE_TYPE = v_intf_type
741 and jut.header = v_header
742 union all
743 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
744 26 qual_num
745 FROM JTY_WEBADI_OTH_TERR_INTF jut
746 where jut.USER_SEQUENCE = v_user_sequence
747 and jut.status is null
748 and jut.qual26_value1 is not null
749 and jut.INTERFACE_TYPE = v_intf_type
750 and jut.header = v_header
751 union all
752 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
753 27 qual_num
754 FROM JTY_WEBADI_OTH_TERR_INTF jut
755 where jut.USER_SEQUENCE = v_user_sequence
756 and jut.status is null
757 and jut.qual27_value1 is not null
758 and jut.INTERFACE_TYPE = v_intf_type
759 and jut.header = v_header
760 union all
761 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
762 28 qual_num
763 FROM JTY_WEBADI_OTH_TERR_INTF jut
764 where jut.USER_SEQUENCE = v_user_sequence
765 and jut.status is null
766 and jut.qual28_value1 is not null
767 and jut.INTERFACE_TYPE = v_intf_type
768 and jut.header = v_header
769 union all
770 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
771 29 qual_num
772 FROM JTY_WEBADI_OTH_TERR_INTF jut
773 where jut.USER_SEQUENCE = v_user_sequence
774 and jut.status is null
775 and jut.qual29_value1 is not null
776 and jut.INTERFACE_TYPE = v_intf_type
777 and jut.header = v_header
778 union all
779 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
780 30 qual_num
781 FROM JTY_WEBADI_OTH_TERR_INTF jut
782 where jut.USER_SEQUENCE = v_user_sequence
783 and jut.status is null
784 and jut.qual30_value1 is not null
785 and jut.INTERFACE_TYPE = v_intf_type
786 and jut.header = v_header
787 union all
788 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
789 31 qual_num
790 FROM JTY_WEBADI_OTH_TERR_INTF jut
791 where jut.USER_SEQUENCE = v_user_sequence
792 and jut.status is null
793 and jut.qual31_value1 is not null
794 and jut.INTERFACE_TYPE = v_intf_type
795 and jut.header = v_header
796 union all
797 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
798 32 qual_num
799 FROM JTY_WEBADI_OTH_TERR_INTF jut
800 where jut.USER_SEQUENCE = v_user_sequence
801 and jut.status is null
802 and jut.qual32_value1 is not null
803 and jut.INTERFACE_TYPE = v_intf_type
804 and jut.header = v_header
805 union all
806 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
807 33 qual_num
808 FROM JTY_WEBADI_OTH_TERR_INTF jut
809 where jut.USER_SEQUENCE = v_user_sequence
810 and jut.status is null
811 and jut.qual33_value1 is not null
812 and jut.INTERFACE_TYPE = v_intf_type
813 and jut.header = v_header
814 union all
815 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
816 34 qual_num
817 FROM JTY_WEBADI_OTH_TERR_INTF jut
818 where jut.USER_SEQUENCE = v_user_sequence
819 and jut.status is null
820 and jut.qual34_value1 is not null
821 and jut.INTERFACE_TYPE = v_intf_type
822 and jut.header = v_header
823 union all
824 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
825 35 qual_num
826 FROM JTY_WEBADI_OTH_TERR_INTF jut
827 where jut.USER_SEQUENCE = v_user_sequence
828 and jut.status is null
829 and jut.qual35_value1 is not null
830 and jut.INTERFACE_TYPE = v_intf_type
831 and jut.header = v_header
832 union all
833 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
834 36 qual_num
835 FROM JTY_WEBADI_OTH_TERR_INTF jut
836 where jut.USER_SEQUENCE = v_user_sequence
837 and jut.status is null
838 and jut.qual36_value1 is not null
839 and jut.INTERFACE_TYPE = v_intf_type
840 and jut.header = v_header
841 union all
842 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
843 37 qual_num
844 FROM JTY_WEBADI_OTH_TERR_INTF jut
845 where jut.USER_SEQUENCE = v_user_sequence
846 and jut.status is null
847 and jut.qual37_value1 is not null
848 and jut.INTERFACE_TYPE = v_intf_type
849 and jut.header = v_header
850 union all
851 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
852 38 qual_num
853 FROM JTY_WEBADI_OTH_TERR_INTF jut
854 where jut.USER_SEQUENCE = v_user_sequence
855 and jut.status is null
856 and jut.qual38_value1 is not null
857 and jut.INTERFACE_TYPE = v_intf_type
858 and jut.header = v_header
859 union all
860 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
861 39 qual_num
862 FROM JTY_WEBADI_OTH_TERR_INTF jut
863 where jut.USER_SEQUENCE = v_user_sequence
864 and jut.status is null
865 and jut.qual39_value1 is not null
866 and jut.INTERFACE_TYPE = v_intf_type
867 and jut.header = v_header
868 union all
869 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
870 40 qual_num
871 FROM JTY_WEBADI_OTH_TERR_INTF jut
872 where jut.USER_SEQUENCE = v_user_sequence
873 and jut.status is null
874 and jut.qual40_value1 is not null
875 and jut.INTERFACE_TYPE = v_intf_type
876 and jut.header = v_header
877 union all
878 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
879 41 qual_num
880 FROM JTY_WEBADI_OTH_TERR_INTF jut
881 where jut.USER_SEQUENCE = v_user_sequence
882 and jut.status is null
883 and jut.qual41_value1 is not null
884 and jut.INTERFACE_TYPE = v_intf_type
885 and jut.header = v_header
886 union all
887 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
888 42 qual_num
889 FROM JTY_WEBADI_OTH_TERR_INTF jut
890 where jut.USER_SEQUENCE = v_user_sequence
891 and jut.status is null
892 and jut.qual42_value1 is not null
893 and jut.INTERFACE_TYPE = v_intf_type
894 and jut.header = v_header
895 union all
896 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
897 43 qual_num
898 FROM JTY_WEBADI_OTH_TERR_INTF jut
899 where jut.USER_SEQUENCE = v_user_sequence
900 and jut.status is null
901 and jut.qual43_value1 is not null
902 and jut.INTERFACE_TYPE = v_intf_type
903 and jut.header = v_header
904 union all
905 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
906 44 qual_num
907 FROM JTY_WEBADI_OTH_TERR_INTF jut
908 where jut.USER_SEQUENCE = v_user_sequence
909 and jut.status is null
910 and jut.qual44_value1 is not null
911 and jut.INTERFACE_TYPE = v_intf_type
912 and jut.header = v_header
913 union all
914 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
915 45 qual_num
916 FROM JTY_WEBADI_OTH_TERR_INTF jut
917 where jut.USER_SEQUENCE = v_user_sequence
918 and jut.status is null
919 and jut.qual45_value1 is not null
920 and jut.INTERFACE_TYPE = v_intf_type
921 and jut.header = v_header
922 union all
923 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
924 46 qual_num
925 FROM JTY_WEBADI_OTH_TERR_INTF jut
926 where jut.USER_SEQUENCE = v_user_sequence
927 and jut.status is null
928 and jut.qual46_value1 is not null
929 and jut.INTERFACE_TYPE = v_intf_type
930 and jut.header = v_header
931 union all
932 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
933 47 qual_num
934 FROM JTY_WEBADI_OTH_TERR_INTF jut
935 where jut.USER_SEQUENCE = v_user_sequence
936 and jut.status is null
937 and jut.qual47_value1 is not null
938 and jut.INTERFACE_TYPE = v_intf_type
939 and jut.header = v_header
940 union all
941 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
942 48 qual_num
943 FROM JTY_WEBADI_OTH_TERR_INTF jut
944 where jut.USER_SEQUENCE = v_user_sequence
945 and jut.status is null
946 and jut.qual48_value1 is not null
947 and jut.INTERFACE_TYPE = v_intf_type
948 and jut.header = v_header
949 union all
950 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
951 49 qual_num
952 FROM JTY_WEBADI_OTH_TERR_INTF jut
953 where jut.USER_SEQUENCE = v_user_sequence
954 and jut.status is null
955 and jut.qual49_value1 is not null
956 and jut.INTERFACE_TYPE = v_intf_type
957 and jut.header = v_header
958 union all
959 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
960 50 qual_num
961 FROM JTY_WEBADI_OTH_TERR_INTF jut
962 where jut.USER_SEQUENCE = v_user_sequence
963 and jut.status is null
964 and jut.qual50_value1 is not null
965 and jut.INTERFACE_TYPE = v_intf_type
966 and jut.header = v_header
967 union all
968 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
969 51 qual_num
970 FROM JTY_WEBADI_OTH_TERR_INTF jut
971 where jut.USER_SEQUENCE = v_user_sequence
972 and jut.status is null
973 and jut.qual51_value1 is not null
974 and jut.INTERFACE_TYPE = v_intf_type
975 and jut.header = v_header
976 union all
977 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
978 52 qual_num
979 FROM JTY_WEBADI_OTH_TERR_INTF jut
980 where jut.USER_SEQUENCE = v_user_sequence
981 and jut.status is null
982 and jut.qual52_value1 is not null
983 and jut.INTERFACE_TYPE = v_intf_type
984 and jut.header = v_header
985 union all
986 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
987 53 qual_num
988 FROM JTY_WEBADI_OTH_TERR_INTF jut
989 where jut.USER_SEQUENCE = v_user_sequence
990 and jut.status is null
991 and jut.qual53_value1 is not null
992 and jut.INTERFACE_TYPE = v_intf_type
993 and jut.header = v_header
994 union all
995 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
996 54 qual_num
997 FROM JTY_WEBADI_OTH_TERR_INTF jut
998 where jut.USER_SEQUENCE = v_user_sequence
999 and jut.status is null
1000 and jut.qual54_value1 is not null
1001 and jut.INTERFACE_TYPE = v_intf_type
1002 and jut.header = v_header
1003 union all
1004 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1005 55 qual_num
1006 FROM JTY_WEBADI_OTH_TERR_INTF jut
1007 where jut.USER_SEQUENCE = v_user_sequence
1008 and jut.status is null
1009 and jut.qual55_value1 is not null
1010 and jut.INTERFACE_TYPE = v_intf_type
1011 and jut.header = v_header
1012 union all
1013 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1014 56 qual_num
1015 FROM JTY_WEBADI_OTH_TERR_INTF jut
1016 where jut.USER_SEQUENCE = v_user_sequence
1017 and jut.status is null
1018 and jut.qual56_value1 is not null
1019 and jut.INTERFACE_TYPE = v_intf_type
1020 and jut.header = v_header
1021 union all
1022 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1023 57 qual_num
1024 FROM JTY_WEBADI_OTH_TERR_INTF jut
1025 where jut.USER_SEQUENCE = v_user_sequence
1026 and jut.status is null
1027 and jut.qual57_value1 is not null
1028 and jut.INTERFACE_TYPE = v_intf_type
1029 and jut.header = v_header
1030 union all
1031 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1032 58 qual_num
1033 FROM JTY_WEBADI_OTH_TERR_INTF jut
1034 where jut.USER_SEQUENCE = v_user_sequence
1035 and jut.status is null
1036 and jut.qual58_value1 is not null
1037 and jut.INTERFACE_TYPE = v_intf_type
1038 and jut.header = v_header
1039 union all
1040 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1041 59 qual_num
1042 FROM JTY_WEBADI_OTH_TERR_INTF jut
1043 where jut.USER_SEQUENCE = v_user_sequence
1044 and jut.status is null
1045 and jut.qual59_value1 is not null
1046 and jut.INTERFACE_TYPE = v_intf_type
1047 and jut.header = v_header
1048 union all
1049 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1050 60 qual_num
1051 FROM JTY_WEBADI_OTH_TERR_INTF jut
1052 where jut.USER_SEQUENCE = v_user_sequence
1053 and jut.status is null
1054 and jut.qual60_value1 is not null
1055 and jut.INTERFACE_TYPE = v_intf_type
1056 and jut.header = v_header
1057 union all
1058 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1059 61 qual_num
1060 FROM JTY_WEBADI_OTH_TERR_INTF jut
1061 where jut.USER_SEQUENCE = v_user_sequence
1062 and jut.status is null
1063 and jut.qual61_value1 is not null
1064 and jut.INTERFACE_TYPE = v_intf_type
1065 and jut.header = v_header
1066 union all
1067 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1068 62 qual_num
1069 FROM JTY_WEBADI_OTH_TERR_INTF jut
1070 where jut.USER_SEQUENCE = v_user_sequence
1071 and jut.status is null
1072 and jut.qual62_value1 is not null
1073 and jut.INTERFACE_TYPE = v_intf_type
1074 and jut.header = v_header
1075 union all
1076 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1077 63 qual_num
1078 FROM JTY_WEBADI_OTH_TERR_INTF jut
1079 where jut.USER_SEQUENCE = v_user_sequence
1080 and jut.status is null
1081 and jut.qual63_value1 is not null
1082 and jut.INTERFACE_TYPE = v_intf_type
1083 and jut.header = v_header
1084 union all
1085 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1086 64 qual_num
1087 FROM JTY_WEBADI_OTH_TERR_INTF jut
1088 where jut.USER_SEQUENCE = v_user_sequence
1089 and jut.status is null
1090 and jut.qual64_value1 is not null
1091 and jut.INTERFACE_TYPE = v_intf_type
1092 and jut.header = v_header
1093 union all
1094 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1095 65 qual_num
1096 FROM JTY_WEBADI_OTH_TERR_INTF jut
1097 where jut.USER_SEQUENCE = v_user_sequence
1098 and jut.status is null
1099 and jut.qual65_value1 is not null
1100 and jut.INTERFACE_TYPE = v_intf_type
1101 and jut.header = v_header
1102 union all
1103 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1104 66 qual_num
1105 FROM JTY_WEBADI_OTH_TERR_INTF jut
1106 where jut.USER_SEQUENCE = v_user_sequence
1107 and jut.status is null
1108 and jut.qual46_value1 is not null
1109 and jut.INTERFACE_TYPE = v_intf_type
1110 and jut.header = v_header
1111 union all
1112 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1113 67 qual_num
1114 FROM JTY_WEBADI_OTH_TERR_INTF jut
1115 where jut.USER_SEQUENCE = v_user_sequence
1116 and jut.status is null
1117 and jut.qual67_value1 is not null
1118 and jut.INTERFACE_TYPE = v_intf_type
1119 and jut.header = v_header
1120 union all
1121 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1122 68 qual_num
1123 FROM JTY_WEBADI_OTH_TERR_INTF jut
1124 where jut.USER_SEQUENCE = v_user_sequence
1125 and jut.status is null
1126 and jut.qual68_value1 is not null
1127 and jut.INTERFACE_TYPE = v_intf_type
1128 and jut.header = v_header
1129 union all
1130 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1131 69 qual_num
1132 FROM JTY_WEBADI_OTH_TERR_INTF jut
1133 where jut.USER_SEQUENCE = v_user_sequence
1134 and jut.status is null
1135 and jut.qual69_value1 is not null
1136 and jut.INTERFACE_TYPE = v_intf_type
1137 and jut.header = v_header
1138 union all
1139 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1140 70 qual_num
1141 FROM JTY_WEBADI_OTH_TERR_INTF jut
1142 where jut.USER_SEQUENCE = v_user_sequence
1143 and jut.status is null
1144 and jut.qual70_value1 is not null
1145 and jut.INTERFACE_TYPE = v_intf_type
1146 and jut.header = v_header
1147 union all
1148 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1149 71 qual_num
1150 FROM JTY_WEBADI_OTH_TERR_INTF jut
1151 where jut.USER_SEQUENCE = v_user_sequence
1152 and jut.status is null
1153 and jut.qual71_value1 is not null
1154 and jut.INTERFACE_TYPE = v_intf_type
1155 and jut.header = v_header
1156 union all
1157 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1158 72 qual_num
1159 FROM JTY_WEBADI_OTH_TERR_INTF jut
1160 where jut.USER_SEQUENCE = v_user_sequence
1161 and jut.status is null
1162 and jut.qual72_value1 is not null
1163 and jut.INTERFACE_TYPE = v_intf_type
1164 and jut.header = v_header
1165 union all
1166 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1167 73 qual_num
1168 FROM JTY_WEBADI_OTH_TERR_INTF jut
1169 where jut.USER_SEQUENCE = v_user_sequence
1170 and jut.status is null
1171 and jut.qual73_value1 is not null
1172 and jut.INTERFACE_TYPE = v_intf_type
1173 and jut.header = v_header
1174 union all
1175 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1176 74 qual_num
1177 FROM JTY_WEBADI_OTH_TERR_INTF jut
1178 where jut.USER_SEQUENCE = v_user_sequence
1179 and jut.status is null
1180 and jut.qual74_value1 is not null
1181 and jut.INTERFACE_TYPE = v_intf_type
1182 and jut.header = v_header
1183 union all
1184 select jut.lay_seq_num, jut.user_sequence, jut.terr_type_id,
1185 75 qual_num
1186 FROM JTY_WEBADI_OTH_TERR_INTF jut
1187 where jut.USER_SEQUENCE = v_user_sequence
1188 and jut.status is null
1189 and jut.qual75_value1 is not null
1190 and jut.INTERFACE_TYPE = v_intf_type
1191 and jut.header = v_header ) sub
1192 where jqh.qualifier_num = sub.qual_num
1193 and jqh.user_sequence = sub.user_sequence
1194 and not exists (select 1 from jtf_terr_type_qual_all jttq
1195 where jttq.terr_type_id = sub.terr_type_id
1196 and jttq.qual_usg_id = jqh.qual_usg_id);
1197
1198 TYPE Qual_Rec_Type IS RECORD
1199 ( lay_seq_num number_tbl_type,
1200 qualifier_name varchar2_tbl_type );
1201
1202 qual_rec Qual_Rec_Type;
1203 BEGIN
1204 debugmsg('VALIDATE_TERRITORY_RECORDS: P_USER_SEQUENCE : ' || P_USER_SEQUENCE);
1205 debugmsg('VALIDATE_TERRITORY_RECORDS: P_INTF_TYPE : ' || P_INTF_TYPE);
1206 x_return_status := FND_API.G_RET_STS_ERROR;
1207 fnd_message.clear;
1208 fnd_message.set_name ('JTF', 'JTF_TTY_INVALID_TERR_NAME');
1209 X_Msg_Data := fnd_message.get();
1210 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate JTF_TTY_INVALID_TERR_NAME : ' );
1211 update JTY_WEBADI_OTH_TERR_INTF jwot
1212 set status = x_return_status,
1213 error_msg = X_Msg_Data
1214 where jwot.terr_name is null
1215 and jwot.USER_SEQUENCE = p_USER_SEQUENCE
1216 and jwot.INTERFACE_TYPE = p_intf_type
1217 and jwot.status is null;
1218
1219 -- Fix for bug 8289489. Rank can't be null. This fix can be removed, if webadi raises error for not null columns.
1220 x_return_status := FND_API.G_RET_STS_ERROR;
1221 fnd_message.clear;
1222 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_INVALID_RANK');
1223 X_Msg_Data := fnd_message.get();
1224
1225 update JTY_WEBADI_OTH_TERR_INTF jwot
1226 set status = x_return_status,
1227 error_msg = X_Msg_Data
1228 where jwot.rank is null
1229 and jwot.header = 'TERR'
1230 and jwot.USER_SEQUENCE = p_USER_SEQUENCE
1231 and jwot.INTERFACE_TYPE = p_intf_type
1232 and jwot.status is null;
1233
1234 -- Fix for bug 8289489. ORG ID can't be null. This fix can be removed, if webadi raises error for not null columns.
1235 x_return_status := FND_API.G_RET_STS_ERROR;
1236 fnd_message.clear;
1237 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_INVALID_ORGID');
1238 X_Msg_Data := fnd_message.get();
1239
1240 update JTY_WEBADI_OTH_TERR_INTF jwot
1241 set status = x_return_status,
1242 error_msg = X_Msg_Data
1243 where jwot.org_id is null
1244 and jwot.header = 'TERR'
1245 and jwot.USER_SEQUENCE = p_USER_SEQUENCE
1246 and jwot.INTERFACE_TYPE = p_intf_type
1247 and jwot.status is null;
1248
1249 l_header := 'RSC';
1250 l_action_flag := 'D';
1251
1252 x_return_status := FND_API.G_RET_STS_ERROR;
1253 fnd_message.clear;
1254 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_INVALID_ID');
1255 X_Msg_Data := fnd_message.get();
1256 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate JTY_OTH_TERR_INVALID_ID : ' );
1257 update JTY_WEBADI_OTH_TERR_INTF jwot
1258 set status = x_return_status,
1259 error_msg = X_Msg_Data
1260 where ( (jwot.TERR_ID IS NULL and jwot.header = 'TERR')
1261 OR (jwot.header = 'QUAL' and jwot.TERR_QUAL_ID1 IS NULL
1262 and jwot.TERR_QUAL_ID2 IS NULL and jwot.TERR_QUAL_ID3 IS NULL
1263 and jwot.TERR_QUAL_ID4 IS NULL and jwot.TERR_QUAL_ID5 IS NULL
1264 and jwot.TERR_QUAL_ID6 IS NULL and jwot.TERR_QUAL_ID7 IS NULL
1265 and jwot.TERR_QUAL_ID8 IS NULL and jwot.TERR_QUAL_ID9 IS NULL
1266 and jwot.TERR_QUAL_ID10 IS NULL and jwot.TERR_QUAL_ID11 IS NULL
1267 and jwot.TERR_QUAL_ID12 IS NULL and jwot.TERR_QUAL_ID13 IS NULL
1268 and jwot.TERR_QUAL_ID14 IS NULL and jwot.TERR_QUAL_ID15 IS NULL
1269 and jwot.TERR_QUAL_ID16 IS NULL and jwot.TERR_QUAL_ID17 IS NULL
1270 and jwot.TERR_QUAL_ID18 IS NULL and jwot.TERR_QUAL_ID19 IS NULL
1271 and jwot.TERR_QUAL_ID20 IS NULL and jwot.TERR_QUAL_ID21 IS NULL
1272 and jwot.TERR_QUAL_ID22 IS NULL and jwot.TERR_QUAL_ID23 IS NULL
1273 and jwot.TERR_QUAL_ID24 IS NULL and jwot.TERR_QUAL_ID25 IS NULL
1274 and jwot.TERR_QUAL_ID26 IS NULL and jwot.TERR_QUAL_ID27 IS NULL
1275 and jwot.TERR_QUAL_ID28 IS NULL and jwot.TERR_QUAL_ID29 IS NULL
1276 and jwot.TERR_QUAL_ID30 IS NULL and jwot.TERR_QUAL_ID31 IS NULL
1277 and jwot.TERR_QUAL_ID32 IS NULL and jwot.TERR_QUAL_ID33 IS NULL
1278 and jwot.TERR_QUAL_ID34 IS NULL and jwot.TERR_QUAL_ID35 IS NULL
1279 and jwot.TERR_QUAL_ID36 IS NULL and jwot.TERR_QUAL_ID37 IS NULL
1280 and jwot.TERR_QUAL_ID38 IS NULL and jwot.TERR_QUAL_ID39 IS NULL
1281 and jwot.TERR_QUAL_ID40 IS NULL and jwot.TERR_QUAL_ID41 IS NULL
1282 and jwot.TERR_QUAL_ID42 IS NULL and jwot.TERR_QUAL_ID43 IS NULL
1283 and jwot.TERR_QUAL_ID44 IS NULL and jwot.TERR_QUAL_ID45 IS NULL
1284 and jwot.TERR_QUAL_ID46 IS NULL and jwot.TERR_QUAL_ID47 IS NULL
1285 and jwot.TERR_QUAL_ID48 IS NULL and jwot.TERR_QUAL_ID49 IS NULL
1286 and jwot.TERR_QUAL_ID50 IS NULL and jwot.TERR_QUAL_ID51 IS NULL
1287 and jwot.TERR_QUAL_ID52 IS NULL and jwot.TERR_QUAL_ID53 IS NULL
1288 and jwot.TERR_QUAL_ID54 IS NULL and jwot.TERR_QUAL_ID55 IS NULL
1289 and jwot.TERR_QUAL_ID56 IS NULL and jwot.TERR_QUAL_ID57 IS NULL
1290 and jwot.TERR_QUAL_ID58 IS NULL and jwot.TERR_QUAL_ID59 IS NULL
1291 and jwot.TERR_QUAL_ID60 IS NULL and jwot.TERR_QUAL_ID61 IS NULL
1292 and jwot.TERR_QUAL_ID62 IS NULL and jwot.TERR_QUAL_ID63 IS NULL
1293 and jwot.TERR_QUAL_ID64 IS NULL and jwot.TERR_QUAL_ID65 IS NULL
1294 and jwot.TERR_QUAL_ID66 IS NULL and jwot.TERR_QUAL_ID67 IS NULL
1295 and jwot.TERR_QUAL_ID68 IS NULL and jwot.TERR_QUAL_ID69 IS NULL
1296 and jwot.TERR_QUAL_ID70 IS NULL and jwot.TERR_QUAL_ID71 IS NULL
1297 and jwot.TERR_QUAL_ID72 IS NULL and jwot.TERR_QUAL_ID73 IS NULL
1298 and jwot.TERR_QUAL_ID74 IS NULL and jwot.TERR_QUAL_ID75 IS NULL
1299 )
1300 OR EXISTS (select 1 from jty_webadi_resources jwr
1301 where jwot.lay_seq_num = jwr.lay_seq_num
1302 and jwr.terr_rsc_id is null
1303 and jwr.header = l_header)
1304 )
1305 and jwot.USER_SEQUENCE = p_USER_SEQUENCE
1306 and jwot.INTERFACE_TYPE = p_intf_type
1307 and jwot.action_flag = l_action_flag
1308 and jwot.status is null;
1309
1310 l_action_flag := 'U';
1311
1312 x_return_status := FND_API.G_RET_STS_ERROR;
1313 fnd_message.clear;
1314 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_INVALID_TEMPLATE');
1315 X_Msg_Data := fnd_message.get();
1316 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate JTY_OTH_TERR_INVALID_TEMPLATE : ' );
1317 update JTY_WEBADI_OTH_TERR_INTF jwot
1318 set jwot.status = x_return_status,
1319 jwot.error_msg = X_Msg_Data
1320 where not exists ( SELECT 1
1321 FROM jtf_terr_all jt
1322 WHERE jt.TERRITORY_TYPE_ID = jwot.TERR_TYPE_ID
1323 and jt.terr_id = jwot.TERR_ID
1324 AND jt.ORG_ID = jwot.ORG_ID )
1325 and jwot.user_sequence = p_user_sequence
1326 and jwot.interface_type = p_intf_type
1327 and jwot.action_flag = l_action_flag
1328 and jwot.header <> l_header
1329 and jwot.status is null
1330 AND jwot.TERR_ID is not null;
1331
1332
1333 x_return_status := FND_API.G_RET_STS_ERROR;
1334 fnd_message.clear;
1335 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_NO_TEMPLATE');
1336 X_Msg_Data := fnd_message.get();
1337 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate JTY_OTH_TERR_NO_TEMPLATE : ' );
1338 update JTY_WEBADI_OTH_TERR_INTF jwot
1339 set status = x_return_status,
1340 error_msg = X_Msg_Data
1341 where jwot.TERR_TYPE_ID is null
1342 AND jwot.user_sequence = p_user_sequence
1343 and jwot.interface_type = p_intf_type
1344 and jwot.header <> l_header
1345 and jwot.status is null;
1346
1347 -- Commented it as a part of fix for bug #5479649
1348 /*
1349 x_return_status := FND_API.G_RET_STS_ERROR;
1350 fnd_message.clear;
1351 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_INVALID_ACCESS');
1352 X_Msg_Data := fnd_message.get();
1353 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate JTY_OTH_TERR_INVALID_ACCESS : ' );
1354 update JTY_WEBADI_OTH_TERR_INTF jwot
1355 set jwot.status = x_return_status,
1356 jwot.error_msg = X_Msg_Data
1357 where exists
1358 (select 1 from JTY_WEBADI_RESOURCES jwr
1359 where jwot.lay_seq_num = jwr.lay_seq_num
1360 AND jwr.TRANS_ACCESS_CODE1 is null
1361 AND jwr.TRANS_ACCESS_CODE2 is null
1362 AND jwr.TRANS_ACCESS_CODE3 is null
1363 AND jwr.TRANS_ACCESS_CODE4 is null
1364 AND jwr.TRANS_ACCESS_CODE5 is null
1365 AND jwr.TRANS_ACCESS_CODE6 is null
1366 AND jwr.TRANS_ACCESS_CODE7 is null
1367 AND jwr.TRANS_ACCESS_CODE8 is null
1368 AND jwr.TRANS_ACCESS_CODE9 is null
1369 AND jwr.TRANS_ACCESS_CODE10 is null
1370 and jwr.USER_SEQUENCE = jwot.USER_SEQUENCE
1371 and jwr.interface_type = jwot.interface_type
1372 and jwr.header = jwot.header)
1373 and jwot.user_sequence = p_user_sequence
1374 and jwot.interface_type = p_intf_type
1375 and jwot.header = l_header
1376 and jwot.status is null;
1377 */
1378
1379 -- Fix for bug #5583243 START
1380 -- if any access is left blank while uploading the data from excel,
1381 -- then the upload should populate the value 'NONE' in the database.
1382 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate Update None if access is left blank : ' );
1383 UPDATE JTY_WEBADI_RESOURCES jut
1384 SET jut.TRANS_ACCESS_CODE1 = NVL(jut.TRANS_ACCESS_CODE1,'NONE')
1385 , jut.TRANS_ACCESS_CODE2 = NVL(jut.TRANS_ACCESS_CODE2,'NONE')
1386 , jut.TRANS_ACCESS_CODE3 = NVL(jut.TRANS_ACCESS_CODE3,'NONE')
1387 , jut.TRANS_ACCESS_CODE4 = NVL(jut.TRANS_ACCESS_CODE4,'NONE')
1388 , jut.TRANS_ACCESS_CODE5 = NVL(jut.TRANS_ACCESS_CODE5,'NONE')
1389 , jut.TRANS_ACCESS_CODE6 = NVL(jut.TRANS_ACCESS_CODE6,'NONE')
1390 , jut.TRANS_ACCESS_CODE7 = NVL(jut.TRANS_ACCESS_CODE7,'NONE')
1391 , jut.TRANS_ACCESS_CODE8 = NVL(jut.TRANS_ACCESS_CODE8,'NONE')
1392 , jut.TRANS_ACCESS_CODE9 = NVL(jut.TRANS_ACCESS_CODE9,'NONE')
1393 , jut.TRANS_ACCESS_CODE10 = NVL(jut.TRANS_ACCESS_CODE10,'NONE')
1394 WHERE jut.USER_SEQUENCE = p_user_sequence
1395 AND jut.header = 'RSC'
1396 AND jut.INTERFACE_TYPE = p_intf_type;
1397
1398 -- Fix for bug #5583243 END
1399
1400 -- Fix for bug #5479649 START
1401 -- An error message should be displayed when all the access types
1402 -- are NONE for all the transaction type of a resource.
1403 x_return_status := FND_API.G_RET_STS_ERROR;
1404 fnd_message.clear;
1405 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_INVALID_ACCESS');
1406 X_Msg_Data := fnd_message.get();
1407 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate JTY_OTH_TERR_INVALID_ACCESS : ' );
1408 update JTY_WEBADI_OTH_TERR_INTF jwot
1409 set jwot.status = x_return_status,
1410 jwot.error_msg = X_Msg_Data
1411 where exists
1412 (select 1 from JTY_WEBADI_RESOURCES jwr
1413 where jwot.lay_seq_num = jwr.lay_seq_num
1414 AND jwr.TRANS_ACCESS_CODE1 = 'NONE'
1415 AND jwr.TRANS_ACCESS_CODE2 = 'NONE'
1416 AND jwr.TRANS_ACCESS_CODE3 = 'NONE'
1417 AND jwr.TRANS_ACCESS_CODE4 = 'NONE'
1418 AND jwr.TRANS_ACCESS_CODE5 = 'NONE'
1419 AND jwr.TRANS_ACCESS_CODE6 = 'NONE'
1420 AND jwr.TRANS_ACCESS_CODE7 = 'NONE'
1421 AND jwr.TRANS_ACCESS_CODE8 = 'NONE'
1422 AND jwr.TRANS_ACCESS_CODE9 = 'NONE'
1423 AND jwr.TRANS_ACCESS_CODE10 = 'NONE'
1424 and jwr.USER_SEQUENCE = jwot.USER_SEQUENCE
1425 and jwr.interface_type = jwot.interface_type
1426 and jwr.header = jwot.header)
1427 and jwot.user_sequence = p_user_sequence
1428 and jwot.interface_type = p_intf_type
1429 and jwot.header = l_header
1430 and jwot.status is null;
1431
1432 -- Fix for bug #5479649 END.
1433
1434 -- Fix for bug # 6372728 START
1435 -- Should display a error message when user tries to add a duplicate reosurce.
1436 x_return_status := FND_API.G_RET_STS_ERROR;
1437 fnd_message.clear;
1438 fnd_message.set_name ('JTF', 'JTF_TTY_DUPLICATE_RESOURCE');
1439 X_Msg_Data := fnd_message.get();
1440 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate JTF_TTY_DUPLICATE_RESOURCE : ' );
1441 update JTY_WEBADI_OTH_TERR_INTF jwot
1442 set status = x_return_status
1443 , error_msg = X_Msg_Data
1444 where jwot.USER_SEQUENCE = p_USER_SEQUENCE
1445 and jwot.INTERFACE_TYPE = p_intf_type
1446 and jwot.status is null
1447 and jwot.action_flag = 'C'
1448 and jwot.header = 'RSC'
1449 and exists( select 1
1450 from JTF_TERR_RSC_ALL jtr,JTY_WEBADI_RESOURCES jwr
1451 where jwr.USER_SEQUENCE = jwot.USER_SEQUENCE
1452 and jwr.header = jwot.header
1453 and jwr.INTERFACE_TYPE = jwot.INTERFACE_TYPE
1454 and jwot.lay_seq_num = jwr.lay_seq_num
1455 and jtr.TERR_ID = jwr.TERR_ID
1456 and jtr.RESOURCE_ID = jwr.RESOURCE_ID
1457 and nvl(jtr.role, 'X') = nvl(jwr.role_code, 'X')
1458 and nvl(jtr.group_id, -1) = nvl(jwr.group_id, -1)
1459 and decode(jtr.resource_type,'RS_GROUP',1,'RS_TEAM',2,'RS_ROLE',3,0) = jwr.resource_type
1460 and ( jwr.res_start_date between jtr.start_date_active and jtr.end_date_active
1461 or jwr.res_end_date between jtr.start_date_active and jtr.end_date_active )
1462 );
1463 -- Fix for bug # 6372728 END
1464
1465 -- Fix for bug # 9124144 START
1466 update JTY_WEBADI_OTH_TERR_INTF jwot
1467 set status = x_return_status
1468 , error_msg = X_Msg_Data
1469 where jwot.USER_SEQUENCE = p_USER_SEQUENCE
1470 and jwot.INTERFACE_TYPE = p_intf_type
1471 and jwot.status is null
1472 and jwot.action_flag = 'C'
1473 and jwot.header = 'RSC'
1474 and exists( select 1
1475 from JTY_WEBADI_RESOURCES jwr1,JTY_WEBADI_RESOURCES jwr2
1476 where jwr1.USER_SEQUENCE = jwot.USER_SEQUENCE
1477 and jwr1.header = jwot.header
1478 and jwr1.INTERFACE_TYPE = jwot.INTERFACE_TYPE
1479 and jwot.lay_seq_num = jwr1.lay_seq_num
1480 and jwr1.lay_seq_num <> jwr2.lay_seq_num
1481 and jwr1.TERR_ID = jwr2.TERR_ID
1482 and jwr1.RESOURCE_ID = jwr2.RESOURCE_ID
1483 and nvl(jwr1.role_code, 'X') = nvl(jwr2.role_code, 'X')
1484 and nvl(jwr1.group_id, -1) = nvl(jwr2.group_id, -1)
1485 and jwr1.resource_type = jwr2.resource_type
1486 and ( jwr2.res_start_date between jwr1.res_start_date and jwr1.res_end_date
1487 or jwr2.res_end_date between jwr1.res_start_date and jwr1.res_end_date )
1488 );
1489 -- Fix for bug # 9124144 END
1490
1491 x_return_status := FND_API.G_RET_STS_ERROR;
1492 fnd_message.clear;
1493 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_RSC_START_DATE');
1494 X_Msg_Data := fnd_message.get();
1495 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate JTY_OTH_TERR_RSC_START_DATE : ' );
1496 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
1497 set jwot.status = x_return_status,
1498 jwot.error_msg = X_Msg_Data
1499 where exists
1500 (select 1 from JTY_WEBADI_RESOURCES jwr
1501 where jwot.lay_seq_num = jwr.lay_seq_num
1502 and jwr.USER_SEQUENCE = jwot.USER_SEQUENCE
1503 and jwr.interface_type = jwot.interface_type
1504 and jwr.header = jwot.header
1505 and NOT(jwr.RES_START_DATE between jwot.TERR_START_DATE and jwot.TERR_END_DATE)
1506 --and (jwr.RES_START_DATE <= nvl(jwot.TERR_START_DATE,sysdate))
1507 )
1508 and jwot.user_sequence = p_user_sequence
1509 and jwot.interface_type = p_intf_type
1510 and jwot.header = l_header
1511 and jwot.status is null;
1512
1513 x_return_status := FND_API.G_RET_STS_ERROR;
1514 fnd_message.clear;
1515 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_RSC_END_DATE');
1516 X_Msg_Data := fnd_message.get();
1517 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate JTY_OTH_TERR_RSC_END_DATE : ' );
1518 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
1519 set jwot.status = x_return_status,
1520 jwot.error_msg = X_Msg_Data
1521 where exists
1522 (select 1 from JTY_WEBADI_RESOURCES jwr
1523 where jwot.lay_seq_num = jwr.lay_seq_num
1524 and jwr.USER_SEQUENCE = jwot.USER_SEQUENCE
1525 and jwr.interface_type = jwot.interface_type
1526 and jwr.header = jwot.header
1527 and not (jwr.RES_END_DATE between nvl(jwot.TERR_START_DATE,sysdate)
1528 and NVL(jwot.TERR_END_DATE, ADD_MONTHS(NVL(jwot.TERR_START_DATE,SYSDATE), 12)))
1529 )
1530 and jwot.user_sequence = p_user_sequence
1531 and jwot.interface_type = p_intf_type
1532 and jwot.header = l_header
1533 and jwot.status is null;
1534
1535
1536 l_header := 'QUAL';
1537 x_return_status := FND_API.G_RET_STS_ERROR;
1538 fnd_message.clear;
1539 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_INVALID_QUAL');
1540 X_Msg_Data := fnd_message.get();
1541 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate JTY_OTH_TERR_INVALID_QUAL : ' );
1542 open get_qual_csr(p_user_sequence, p_intf_type, l_header);
1543 fetch get_qual_csr bulk collect into qual_rec.qualifier_name, qual_rec.lay_seq_num;
1544 close get_qual_csr;
1545 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate qual_rec.lay_seq_num.count : ' || qual_rec.lay_seq_num.count );
1546 if qual_rec.lay_seq_num.count > 0 then
1547 forall i in qual_rec.lay_seq_num.first..qual_rec.lay_seq_num.last
1548 update JTY_WEBADI_OTH_TERR_INTF jwot
1549 set jwot.status = x_return_status,
1550 jwot.error_msg = decode(jwot.error_msg,null,X_Msg_Data||': '||qual_rec.qualifier_name(i),
1551 jwot.error_msg ||', ' || qual_rec.qualifier_name(i))
1552 where jwot.lay_seq_num = qual_rec.lay_seq_num(i)
1553 and jwot.user_sequence = p_user_sequence
1554 and jwot.interface_type = p_intf_type
1555 and jwot.header = l_header;
1556 end if;
1557
1558 l_header := 'TERR';
1559
1560 x_return_status := FND_API.G_RET_STS_ERROR;
1561 fnd_message.clear;
1562 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_START_DATE');
1563 X_Msg_Data := fnd_message.get();
1564 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate JTY_OTH_TERR_START_DATE : ' );
1565 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
1566 set status = x_return_status,
1567 error_msg = X_Msg_Data
1568 where jwot.interface_type = p_intf_type
1569 AND jwot.HEADER= l_header
1570 and jwot.USER_SEQUENCE = p_USER_SEQUENCE
1571 AND jwot.hierarchy is not null
1572 and jwot.TERR_START_DATE is not null
1573 and jwot.status is null
1574 and ( exists ( select 1
1575 from JTY_WEBADI_OTH_TERR_INTF jwot2
1576 where jwot.parent_terr_id is null
1577 and NOT(jwot.TERR_START_DATE between NVL(jwot2.terr_start_date,SYSDATE)
1578 and NVL(jwot2.TERR_END_DATE, ADD_MONTHS(NVL(jwot2.TERR_START_DATE,SYSDATE), 12)))
1579 and jwot.parent_terr_name = jwot2.terr_name)
1580 or exists ( select 1
1581 from JTF_TERR_ALL jta
1582 where jwot.parent_terr_id = jta.terr_id
1583 and NOT(jwot.TERR_START_DATE between jta.START_DATE_ACTIVE and jta.END_DATE_ACTIVE))
1584 );
1585
1586 x_return_status := FND_API.G_RET_STS_ERROR;
1587 fnd_message.clear;
1588 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_END_DATE');
1589 X_Msg_Data := fnd_message.get();
1590 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate JTY_OTH_TERR_END_DATE : ' );
1591 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
1592 set status = x_return_status,
1593 error_msg = X_Msg_Data
1594 where jwot.interface_type = p_intf_type
1595 AND jwot.HEADER= l_header
1596 and jwot.USER_SEQUENCE = p_USER_SEQUENCE
1597 AND jwot.hierarchy is not null
1598 AND jwot.TERR_END_DATE is not null
1599 and jwot.status is null
1600 and (exists ( select 1
1601 from JTY_WEBADI_OTH_TERR_INTF jwot2
1602 where jwot.parent_terr_id is null
1603 and NOT (jwot.TERR_END_DATE between NVL(jwot2.terr_start_date,SYSDATE)
1604 and NVL(jwot2.TERR_END_DATE, ADD_MONTHS(NVL(jwot2.TERR_START_DATE,SYSDATE), 12)))
1605 and jwot.parent_terr_name = jwot2.terr_name)
1606 or exists ( select 1
1607 from JTF_TERR_ALL jta
1608 where jwot.parent_terr_id = jta.terr_id
1609 and NOT(jwot.TERR_END_DATE between jta.START_DATE_ACTIVE and jta.END_DATE_ACTIVE))
1610 );
1611
1612 -- Fix for bug #7707288 START
1613
1614 -- Should display a error message when user tries to create a territory
1615 -- with same name.
1616 x_return_status := FND_API.G_RET_STS_ERROR;
1617 fnd_message.clear;
1618 fnd_message.set_name ('JTF', 'JTY_TTY_DUPLICATE_TERR');
1619 X_Msg_Data := fnd_message.get();
1620 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate JTY_TTY_DUPLICATE_TERR : ' );
1621
1622 update JTY_WEBADI_OTH_TERR_INTF jwot
1623 set status = x_return_status
1624 , error_msg = X_Msg_Data
1625 where jwot.header = 'TERR'
1626 and jwot.action_flag='C'
1627 and jwot.USER_SEQUENCE = p_USER_SEQUENCE
1628 and jwot.status is null
1629 and exists( select 1
1630 from JTF_TERR_ALL jta
1631 where jta.name = jwot.terr_name
1632 and ( jwot.terr_start_date BETWEEN jta.start_date_active AND jta.end_date_Active
1633 or jwot.terr_end_date BETWEEN jta.start_date_active AND jta.end_date_Active
1634 )
1635 );
1636
1637 -- The above fix checks for duplicate territory name only while creating a new territory.
1638 -- The following fix checks for the duplicate territory name while updating a territory. Fix for bug: 8289489.
1639 update JTY_WEBADI_OTH_TERR_INTF jwot
1640 set status = x_return_status
1641 , error_msg = X_Msg_Data
1642 where jwot.header = 'TERR'
1643 and jwot.action_flag='U'
1644 and jwot.USER_SEQUENCE = p_USER_SEQUENCE
1645 and jwot.status is null
1646 and exists( select 1
1647 from JTF_TERR_ALL jta
1648 where jta.name = jwot.terr_name
1649 and jta.terr_id <> jwot.terr_id
1650 and ( jwot.terr_start_date BETWEEN jta.start_date_active AND jta.end_date_Active
1651 or jwot.terr_end_date BETWEEN jta.start_date_active AND jta.end_date_Active
1652 )
1653 );
1654
1655 -- Fix for bug # 7707288 END
1656
1657 -- Fix for bug #8208298 START
1658
1659 -- Should display a error message when user tries to create a territory
1660 -- with empty Territory DFF.
1661 x_return_status := FND_API.G_RET_STS_ERROR;
1662 fnd_message.clear;
1663 fnd_message.set_name ('JTF', 'JTY_TERR_OTH_MTERR_DFF_NA');
1664 X_Msg_Data := fnd_message.get();
1665 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate JTY_TERR_OTH_MTERR_DFF_NA : ' );
1666 update JTY_WEBADI_OTH_TERR_INTF jwot
1667 set status = x_return_status
1668 , error_msg = X_Msg_Data
1669 where jwot.header = 'TERR'
1670 and jwot.action_flag IN ('C', 'U')
1671 and jwot.USER_SEQUENCE = p_USER_SEQUENCE
1672 and jwot.status is null
1673 and attribute_category is NULL
1674 ;
1675
1676 -- Fix for bug # 8208298 END
1677
1678
1679 x_return_status := FND_API.G_RET_STS_ERROR;
1680 fnd_message.clear;
1681 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_NO_ACCESS');
1682 X_Msg_Data := fnd_message.get();
1683 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate JTY_OTH_TERR_NO_ACCESS : ' );
1684 update JTY_WEBADI_OTH_TERR_INTF jwot
1685 set status = x_return_status,
1686 error_msg = X_Msg_Data
1687 where (jwot.org_id is null
1688 or mo_global.check_access(jwot.org_id) <> 'Y')
1689 and jwot.USER_SEQUENCE = p_USER_SEQUENCE
1690 and jwot.INTERFACE_TYPE = p_intf_type
1691 and jwot.status is null;
1692
1693 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
1694 set (status,error_msg) = (SELECT jwot2.STATUS, jwot2.error_msg
1695 FROM JTY_WEBADI_OTH_TERR_INTF jwot2
1696 where jwot.terr_name = jwot2.terr_name
1697 and jwot2.header = l_header
1698 and jwot.USER_SEQUENCE = jwot2.USER_SEQUENCE
1699 and jwot.INTERFACE_TYPE = jwot2.INTERFACE_TYPE)
1700 WHERE jwot.USER_SEQUENCE = p_USER_SEQUENCE
1701 and jwot.INTERFACE_TYPE = p_intf_type
1702 and jwot.header <> l_header
1703 and jwot.status is null;
1704
1705 -- Fix for BUG12758833 by nbombili
1706 --Here Account classification and Oppurtunity classification qualifiers validation has been done.
1707
1708 x_return_status := FND_API.G_RET_STS_ERROR;
1709 fnd_message.clear;
1710 update JTY_WEBADI_OTH_TERR_INTF jwot
1711 set status = x_return_status,
1712 error_msg = 'Primary Interest and Secondary Interest values are mandatory. Please enter values for Primary and Secondary Interest'
1713 where ((jwot.QUAL1_VALUE1 is not null AND (jwot.QUAL1_VALUE2 is null OR jwot.QUAL1_VALUE3 is null))
1714 OR (jwot.QUAL2_VALUE1 is not null AND (jwot.QUAL2_VALUE2 is null OR jwot.QUAL2_VALUE3 is null)))
1715 and jwot.USER_SEQUENCE = p_USER_SEQUENCE
1716 and jwot.INTERFACE_TYPE = p_intf_type
1717 and jwot.status is null;
1718
1719 --end of the fix by nbombili
1720
1721 x_return_status := FND_API.G_RET_STS_SUCCESS;
1722 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate x_return_status : ' || x_return_status);
1723 select count(*) into l_count
1724 from JTY_WEBADI_OTH_TERR_INTF jwot
1725 where status is not null
1726 and jwot.USER_SEQUENCE = p_USER_SEQUENCE
1727 and jwot.INTERFACE_TYPE = p_intf_type;
1728
1729 --dbms_output.put_line ('l_count: '||l_count);
1730 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate l_count : ' || l_count);
1731 if l_count > 0 then
1732 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
1733 set status = x_return_status
1734 where status is null
1735 and jwot.USER_SEQUENCE = p_USER_SEQUENCE
1736 and jwot.INTERFACE_TYPE = p_intf_type;
1737
1738 x_return_status := FND_API.G_RET_STS_ERROR;
1739 else
1740 x_return_status := FND_API.G_RET_STS_SUCCESS;
1741 end if;
1742 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate end x_return_status : ' || x_return_status);
1743 EXCEPTION
1744 WHEN OTHERS THEN
1745 debugmsg('VALIDATE_TERRITORY_RECORDS: Validate EXCEPTION others : ' || SQLERRM(SQLCODE()));
1746 X_RETURN_STATUS := FND_API.G_RET_STS_ERROR;
1747 END VALIDATE_TERRITORY_RECORDS;
1748
1749 PROCEDURE SET_CREATE_RECORDS(
1750 p_user_sequence IN NUMBER,
1751 p_intf_type IN VARCHAR2)
1752 IS
1753 l_action_flag varchar2(1) := 'C';
1754 l_intf_type varchar2(1);
1755 l_login_id number;
1756 BEGIN
1757
1758 l_login_id := fnd_global.login_id;
1759 l_intf_type := p_intf_type;
1760
1761
1762 update JTY_WEBADI_OTH_TERR_INTF jwot
1763 set LAST_UPDATE_LOGIN = l_login_id,
1764 (terr_start_date,TERR_END_DATE) =
1765 (SELECT NVL(jwot.TERR_START_DATE,TRUNC(SYSDATE)),
1766 NVL(jwot.TERR_END_DATE, ADD_MONTHS(NVL(jwot.TERR_START_DATE,TRUNC(SYSDATE)), 12) )
1767 FROM JTY_WEBADI_OTH_TERR_INTF jwot2
1768 WHERE jwot.terr_id = jwot2.terr_id
1769 and jwot.user_sequence = jwot2.user_sequence
1770 and jwot2.header = 'TERR'
1771 and rownum = 1),
1772 usage_id = (select jwot2.usage_id from
1773 JTY_WEBADI_OTH_TERR_INTF jwot2
1774 where jwot.user_sequence = jwot2.user_sequence
1775 and interface_type = 'D'
1776 and jwot2.usage_id is not null
1777 and rownum = 1)
1778 where jwot.user_sequence = p_user_sequence
1779 and jwot.interface_type = l_intf_type
1780 and jwot.action_flag = l_action_flag
1781 and jwot.status is null;
1782
1783 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
1784 SET (TERR_ID, TERR_START_DATE, TERR_END_DATE) =
1785 (select jta.terr_id, NVL(jwot.TERR_START_DATE,jta.START_DATE_ACTIVE)
1786 , NVL(jwot.TERR_END_DATE,jta.END_DATE_ACTIVE)
1787 from jtf_terr_all jta
1788 where jta.terr_id = jwot.terr_id
1789 --and jta.parent_territory_id = jwot.parent_terr_id
1790 and rownum = 1)
1791 where status is null
1792 and interface_type = l_intf_type
1793 and user_sequence = p_user_sequence
1794 and exists (select 1
1795 from jtf_terr_all jta
1796 where jta.terr_id = jwot.terr_id
1797 --and jta.parent_territory_id = jwot.parent_terr_id
1798 ) ;
1799
1800 --dbms_output.put_line(' # records processed for intf table: '||SQL%ROWCOUNT);
1801 update JTY_WEBADI_OTH_TERR_INTF
1802 set QUAL1_VALUE_ID = NULL, QUAL2_VALUE_ID = NULL
1803 , QUAL3_VALUE_ID = NULL, QUAL4_VALUE_ID = NULL
1804 , QUAL5_VALUE_ID = NULL, QUAL6_VALUE_ID = NULL
1805 , QUAL7_VALUE_ID = NULL, QUAL8_VALUE_ID = NULL
1806 , QUAL9_VALUE_ID = NULL, QUAL10_VALUE_ID = NULL
1807 , QUAL11_VALUE_ID = NULL, QUAL12_VALUE_ID = NULL
1808 , QUAL13_VALUE_ID = NULL, QUAL14_VALUE_ID = NULL
1809 , QUAL15_VALUE_ID = NULL, QUAL16_VALUE_ID = NULL
1810 , QUAL17_VALUE_ID = NULL, QUAL18_VALUE_ID = NULL
1811 , QUAL19_VALUE_ID = NULL, QUAL20_VALUE_ID = NULL
1812 , QUAL21_VALUE_ID = NULL, QUAL22_VALUE_ID = NULL
1813 , QUAL23_VALUE_ID = NULL, QUAL24_VALUE_ID = NULL
1814 , QUAL25_VALUE_ID = NULL, QUAL26_VALUE_ID = NULL
1815 , QUAL27_VALUE_ID = NULL, QUAL28_VALUE_ID = NULL
1816 , QUAL29_VALUE_ID = NULL, QUAL30_VALUE_ID = NULL
1817 , QUAL31_VALUE_ID = NULL, QUAL32_VALUE_ID = NULL
1818 , QUAL33_VALUE_ID = NULL, QUAL34_VALUE_ID = NULL
1819 , QUAL35_VALUE_ID = NULL, QUAL36_VALUE_ID = NULL
1820 , QUAL37_VALUE_ID = NULL, QUAL38_VALUE_ID = NULL
1821 , QUAL39_VALUE_ID = NULL, QUAL40_VALUE_ID = NULL
1822 , QUAL41_VALUE_ID = NULL, QUAL42_VALUE_ID = NULL
1823 , QUAL43_VALUE_ID = NULL, QUAL44_VALUE_ID = NULL
1824 , QUAL45_VALUE_ID = NULL, QUAL46_VALUE_ID = NULL
1825 , QUAL47_VALUE_ID = NULL, QUAL48_VALUE_ID = NULL
1826 , QUAL49_VALUE_ID = NULL, QUAL50_VALUE_ID = NULL
1827 , QUAL51_VALUE_ID = NULL, QUAL52_VALUE_ID = NULL
1828 , QUAL53_VALUE_ID = NULL, QUAL54_VALUE_ID = NULL
1829 , QUAL55_VALUE_ID = NULL, QUAL56_VALUE_ID = NULL
1830 , QUAL57_VALUE_ID = NULL, QUAL58_VALUE_ID = NULL
1831 , QUAL59_VALUE_ID = NULL, QUAL60_VALUE_ID = NULL
1832 , QUAL61_VALUE_ID = NULL, QUAL62_VALUE_ID = NULL
1833 , QUAL63_VALUE_ID = NULL, QUAL64_VALUE_ID = NULL
1834 , QUAL65_VALUE_ID = NULL, QUAL66_VALUE_ID = NULL
1835 , QUAL67_VALUE_ID = NULL, QUAL68_VALUE_ID = NULL
1836 , QUAL69_VALUE_ID = NULL, QUAL70_VALUE_ID = NULL
1837 , QUAL71_VALUE_ID = NULL, QUAL72_VALUE_ID = NULL
1838 , QUAL73_VALUE_ID = NULL, QUAL74_VALUE_ID = NULL
1839 , QUAL75_VALUE_ID = NULL
1840 where status is null
1841 and interface_type = l_intf_type
1842 and user_sequence = p_user_sequence
1843 and action_flag = l_action_flag
1844 and header = 'QUAL';
1845
1846 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
1847 set jwot.terr_id = null
1848 where jwot.status is null
1849 and jwot.interface_type = l_intf_type
1850 and jwot.user_sequence = p_user_sequence
1851 and jwot.action_flag = l_action_flag
1852 and exists (select 1 from JTY_WEBADI_OTH_TERR_INTF jwot2
1853 where jwot.terr_id = jwot2.terr_id
1854 and jwot.action_flag = jwot2.action_flag
1855 and jwot.user_sequence = jwot2.user_sequence
1856 and jwot.interface_type = jwot2.interface_type
1857 and jwot2.header = 'TERR');
1858
1859 UPDATE JTY_WEBADI_RESOURCES jwr
1860 SET TERR_ID = (select jwot.terr_id
1861 from JTY_WEBADI_OTH_TERR_INTF jwot
1862 where jwr.lay_seq_num = jwot.lay_seq_num
1863 and rownum = 1) ,
1864 TERR_RSC_ID = NULL,
1865 TERR_RSC_ACCESS_ID1 = NULL, TERR_RSC_ACCESS_ID2 = NULL,
1866 TERR_RSC_ACCESS_ID3 = NULL, TERR_RSC_ACCESS_ID4 = NULL,
1867 TERR_RSC_ACCESS_ID5 = NULL, TERR_RSC_ACCESS_ID6 = NULL,
1868 TERR_RSC_ACCESS_ID7 = NULL, TERR_RSC_ACCESS_ID8 = NULL,
1869 TERR_RSC_ACCESS_ID9 = NULL, TERR_RSC_ACCESS_ID10 = NULL
1870 where exists
1871 ( select 1 from JTY_WEBADI_OTH_TERR_INTF jwot
1872 where jwot.interface_type = l_intf_type
1873 and jwot.user_sequence = p_user_sequence
1874 and jwot.status is null
1875 and jwot.action_flag = l_action_flag
1876 and jwot.lay_seq_num = jwr.lay_seq_num
1877 and jwot.header = 'RSC');
1878
1879 END SET_CREATE_RECORDS;
1880
1881 PROCEDURE UPDATE_TERR_QUAL_ID(
1882 P_USER_SEQUENCE IN NUMBER,
1883 P_INTF_TYPE IN VARCHAR2,
1884 P_HEADER IN VARCHAR2)
1885
1886 IS
1887
1888 cursor get_terr_qual_id_csr(
1889 v_header varchar2,
1890 v_user_sequence number,
1891 v_intf_type varchar2,
1892 v_qual_num number
1893 ) IS
1894 select jtq.terr_qual_id, jwot.lay_seq_num
1895 from JTY_WEBADI_QUAL_HEADER qgt , jtf_terr_qual_all jtq, JTY_WEBADI_OTH_TERR_INTF jwot
1896 WHERE qgt.qual_usg_id = jtq.qual_usg_id
1897 and jtq.org_id = jwot.org_id
1898 AND qgt.user_sequence = jwot.user_sequence
1899 AND jtq.terr_id = jwot.terr_id
1900 and jwot.header = v_header
1901 AND jwot.USER_SEQUENCE = v_user_sequence
1902 AND jwot.interface_type = v_intf_type
1903 and qgt.qualifier_num = v_qual_num
1904 and jwot.status is null
1905 group by jwot.terr_id, jtq.terr_qual_id, jwot.lay_seq_num;
1906
1907 TYPE Terr_Qual_Rec_Type IS RECORD
1908 ( TERR_QUAL_ID number_tbl_type,
1909 lay_seq_num number_tbl_type);
1910
1911 l_terr_qual_rec Terr_Qual_Rec_Type;
1912
1913 BEGIN
1914
1915 for i in 1..75 loop
1916 open get_terr_qual_id_csr(p_header, p_user_sequence, p_intf_type, i);
1917 fetch get_terr_qual_id_csr bulk collect into l_terr_qual_rec.terr_qual_id,
1918 --l_terr_qual_rec.qualifier_num,
1919 l_terr_qual_rec.lay_seq_num;
1920 close get_terr_qual_id_csr;
1921
1922 if l_terr_qual_rec.lay_seq_num.count > 0 then
1923 --dbms_output.put_line ('i: '||i);
1924 case i
1925 when 1 then
1926 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
1927 update JTY_WEBADI_OTH_TERR_INTF jwot
1928 set jwot.terr_qual_id1 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
1929 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
1930 and jwot.header = p_header
1931 and jwot.user_sequence = p_user_sequence
1932 and jwot.interface_type = p_intf_type
1933 and jwot.status is null;
1934 --dbms_output.put_line('1 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
1935 when 2 then
1936 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
1937 update JTY_WEBADI_OTH_TERR_INTF jwot
1938 set jwot.terr_qual_id2 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
1939 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
1940 and jwot.header = p_header
1941 and jwot.user_sequence = p_user_sequence
1942 and jwot.interface_type = p_intf_type
1943 and jwot.status is null;
1944 --dbms_output.put_line('2 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
1945 when 3 then
1946 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
1947 update JTY_WEBADI_OTH_TERR_INTF jwot
1948 set jwot.terr_qual_id3 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
1949 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
1950 and jwot.header = p_header
1951 and jwot.user_sequence = p_user_sequence
1952 and jwot.interface_type = p_intf_type
1953 and jwot.status is null;
1954 --dbms_output.put_line('3 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
1955 when 4 then
1956 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
1957 update JTY_WEBADI_OTH_TERR_INTF jwot
1958 set jwot.terr_qual_id4 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
1959 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
1960 and jwot.header = p_header
1961 and jwot.user_sequence = p_user_sequence
1962 and jwot.interface_type = p_intf_type
1963 and jwot.status is null;
1964 --dbms_output.put_line('4 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
1965 when 5 then
1966 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
1967 update JTY_WEBADI_OTH_TERR_INTF jwot
1968 set jwot.terr_qual_id5 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
1969 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
1970 and jwot.header = p_header
1971 and jwot.user_sequence = p_user_sequence
1972 and jwot.interface_type = p_intf_type
1973 and jwot.status is null;
1974 --dbms_output.put_line('5 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
1975 when 6 then
1976 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
1977 update JTY_WEBADI_OTH_TERR_INTF jwot
1978 set jwot.terr_qual_id6 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
1979 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
1980 and jwot.header = p_header
1981 and jwot.user_sequence = p_user_sequence
1982 and jwot.interface_type = p_intf_type
1983 and jwot.status is null;
1984 --dbms_output.put_line('6 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
1985 when 7 then
1986 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
1987 update JTY_WEBADI_OTH_TERR_INTF jwot
1988 set jwot.terr_qual_id7 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
1989 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
1990 and jwot.header = p_header
1991 and jwot.user_sequence = p_user_sequence
1992 and jwot.interface_type = p_intf_type
1993 and jwot.status is null;
1994 --dbms_output.put_line('7 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
1995 when 8 then
1996 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
1997 update JTY_WEBADI_OTH_TERR_INTF jwot
1998 set jwot.terr_qual_id8 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
1999 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2000 and jwot.header = p_header
2001 and jwot.user_sequence = p_user_sequence
2002 and jwot.interface_type = p_intf_type
2003 and jwot.status is null;
2004 --dbms_output.put_line('8 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2005 when 9 then
2006 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2007 update JTY_WEBADI_OTH_TERR_INTF jwot
2008 set jwot.terr_qual_id9 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2009 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2010 and jwot.header = p_header
2011 and jwot.user_sequence = p_user_sequence
2012 and jwot.interface_type = p_intf_type
2013 and jwot.status is null;
2014 --dbms_output.put_line('9 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2015 when 10 then
2016 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2017 update JTY_WEBADI_OTH_TERR_INTF jwot
2018 set jwot.terr_qual_id10 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2019 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2020 and jwot.header = p_header
2021 and jwot.user_sequence = p_user_sequence
2022 and jwot.interface_type = p_intf_type
2023 and jwot.status is null;
2024 --dbms_output.put_line('10 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2025 when 11 then
2026 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2027 update JTY_WEBADI_OTH_TERR_INTF jwot
2028 set jwot.terr_qual_id11 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2029 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2030 and jwot.header = p_header
2031 and jwot.user_sequence = p_user_sequence
2032 and jwot.interface_type = p_intf_type
2033 and jwot.status is null;
2034 --dbms_output.put_line('11 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2035 when 12 then
2036 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2037 update JTY_WEBADI_OTH_TERR_INTF jwot
2038 set jwot.terr_qual_id12 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2039 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2040 and jwot.header = p_header
2041 and jwot.user_sequence = p_user_sequence
2042 and jwot.interface_type = p_intf_type
2043 and jwot.status is null;
2044 --dbms_output.put_line('12 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2045 when 13 then
2046 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2047 update JTY_WEBADI_OTH_TERR_INTF jwot
2048 set jwot.terr_qual_id13 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2049 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2050 and jwot.header = p_header
2051 and jwot.user_sequence = p_user_sequence
2052 and jwot.interface_type = p_intf_type
2053 and jwot.status is null;
2054 --dbms_output.put_line('13 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2055 when 14 then
2056 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2057 update JTY_WEBADI_OTH_TERR_INTF jwot
2058 set jwot.terr_qual_id14 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2059 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2060 and jwot.header = p_header
2061 and jwot.user_sequence = p_user_sequence
2062 and jwot.interface_type = p_intf_type
2063 and jwot.status is null;
2064 --dbms_output.put_line('14 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2065 when 15 then
2066 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2067 update JTY_WEBADI_OTH_TERR_INTF jwot
2068 set jwot.terr_qual_id15 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2069 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2070 and jwot.header = p_header
2071 and jwot.user_sequence = p_user_sequence
2072 and jwot.interface_type = p_intf_type
2073 and jwot.status is null;
2074 --dbms_output.put_line('15 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2075 when 16 then
2076 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2077 update JTY_WEBADI_OTH_TERR_INTF jwot
2078 set jwot.terr_qual_id16 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2079 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2080 and jwot.header = p_header
2081 and jwot.user_sequence = p_user_sequence
2082 and jwot.interface_type = p_intf_type
2083 and jwot.status is null;
2084 --dbms_output.put_line('16 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2085 when 17 then
2086 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2087 update JTY_WEBADI_OTH_TERR_INTF jwot
2088 set jwot.terr_qual_id17 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2089 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2090 and jwot.header = p_header
2091 and jwot.user_sequence = p_user_sequence
2092 and jwot.interface_type = p_intf_type
2093 and jwot.status is null;
2094 --dbms_output.put_line('17 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2095 when 18 then
2096 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2097 update JTY_WEBADI_OTH_TERR_INTF jwot
2098 set jwot.terr_qual_id18 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2099 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2100 and jwot.header = p_header
2101 and jwot.user_sequence = p_user_sequence
2102 and jwot.interface_type = p_intf_type
2103 and jwot.status is null;
2104 --dbms_output.put_line('18 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2105 when 19 then
2106 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2107 update JTY_WEBADI_OTH_TERR_INTF jwot
2108 set jwot.terr_qual_id19 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2109 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2110 and jwot.header = p_header
2111 and jwot.user_sequence = p_user_sequence
2112 and jwot.interface_type = p_intf_type
2113 and jwot.status is null;
2114 --dbms_output.put_line('19 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2115 when 20 then
2116 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2117 update JTY_WEBADI_OTH_TERR_INTF jwot
2118 set jwot.terr_qual_id20 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2119 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2120 and jwot.header = p_header
2121 and jwot.user_sequence = p_user_sequence
2122 and jwot.interface_type = p_intf_type
2123 and jwot.status is null;
2124 --dbms_output.put_line('20 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2125 when 21 then
2126 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2127 update JTY_WEBADI_OTH_TERR_INTF jwot
2128 set jwot.terr_qual_id21 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2129 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2130 and jwot.header = p_header
2131 and jwot.user_sequence = p_user_sequence
2132 and jwot.interface_type = p_intf_type
2133 and jwot.status is null;
2134 --dbms_output.put_line('21 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2135 when 22 then
2136 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2137 update JTY_WEBADI_OTH_TERR_INTF jwot
2138 set jwot.terr_qual_id22 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2139 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2140 and jwot.header = p_header
2141 and jwot.user_sequence = p_user_sequence
2142 and jwot.interface_type = p_intf_type
2143 and jwot.status is null;
2144 --dbms_output.put_line('22 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2145 when 23 then
2146 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2147 update JTY_WEBADI_OTH_TERR_INTF jwot
2148 set jwot.terr_qual_id23 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2149 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2150 and jwot.header = p_header
2151 and jwot.user_sequence = p_user_sequence
2152 and jwot.interface_type = p_intf_type
2153 and jwot.status is null;
2154 --dbms_output.put_line('23 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2155 when 24 then
2156 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2157 update JTY_WEBADI_OTH_TERR_INTF jwot
2158 set jwot.terr_qual_id24 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2159 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2160 and jwot.header = p_header
2161 and jwot.user_sequence = p_user_sequence
2162 and jwot.interface_type = p_intf_type
2163 and jwot.status is null;
2164 --dbms_output.put_line('24 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2165 when 25 then
2166 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2167 update JTY_WEBADI_OTH_TERR_INTF jwot
2168 set jwot.terr_qual_id25 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2169 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2170 and jwot.header = p_header
2171 and jwot.user_sequence = p_user_sequence
2172 and jwot.interface_type = p_intf_type
2173 and jwot.status is null;
2174 --dbms_output.put_line('25 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2175 when 26 then
2176 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2177 update JTY_WEBADI_OTH_TERR_INTF jwot
2178 set jwot.terr_qual_id26 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2179 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2180 and jwot.header = p_header
2181 and jwot.user_sequence = p_user_sequence
2182 and jwot.interface_type = p_intf_type
2183 and jwot.status is null;
2184 --dbms_output.put_line('26 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2185 when 27 then
2186 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2187 update JTY_WEBADI_OTH_TERR_INTF jwot
2188 set jwot.terr_qual_id27 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2189 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2190 and jwot.header = p_header
2191 and jwot.user_sequence = p_user_sequence
2192 and jwot.interface_type = p_intf_type
2193 and jwot.status is null;
2194 --dbms_output.put_line('27 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2195 when 28 then
2196 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2197 update JTY_WEBADI_OTH_TERR_INTF jwot
2198 set jwot.terr_qual_id28 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2199 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2200 and jwot.header = p_header
2201 and jwot.user_sequence = p_user_sequence
2202 and jwot.interface_type = p_intf_type
2203 and jwot.status is null;
2204 --dbms_output.put_line('28 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2205 when 29 then
2206 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2207 update JTY_WEBADI_OTH_TERR_INTF jwot
2208 set jwot.terr_qual_id29 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2209 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2210 and jwot.header = p_header
2211 and jwot.user_sequence = p_user_sequence
2212 and jwot.interface_type = p_intf_type
2213 and jwot.status is null;
2214 --dbms_output.put_line('29 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2215
2216 when 30 then
2217 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2218 update JTY_WEBADI_OTH_TERR_INTF jwot
2219 set jwot.terr_qual_id30 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2220 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2221 and jwot.header = p_header
2222 and jwot.user_sequence = p_user_sequence
2223 and jwot.interface_type = p_intf_type
2224 and jwot.status is null;
2225 --dbms_output.put_line('30 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2226 when 31 then
2227 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2228 update JTY_WEBADI_OTH_TERR_INTF jwot
2229 set jwot.terr_qual_id31 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2230 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2231 and jwot.header = p_header
2232 and jwot.user_sequence = p_user_sequence
2233 and jwot.interface_type = p_intf_type
2234 and jwot.status is null;
2235 --dbms_output.put_line('31 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2236 when 32 then
2237 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2238 update JTY_WEBADI_OTH_TERR_INTF jwot
2239 set jwot.terr_qual_id32 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2240 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2241 and jwot.header = p_header
2242 and jwot.user_sequence = p_user_sequence
2243 and jwot.interface_type = p_intf_type
2244 and jwot.status is null;
2245 --dbms_output.put_line('32 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2246 when 33 then
2247 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2248 update JTY_WEBADI_OTH_TERR_INTF jwot
2249 set jwot.terr_qual_id33 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2250 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2251 and jwot.header = p_header
2252 and jwot.user_sequence = p_user_sequence
2253 and jwot.interface_type = p_intf_type
2254 and jwot.status is null;
2255 --dbms_output.put_line('33 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2256 when 34 then
2257 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2258 update JTY_WEBADI_OTH_TERR_INTF jwot
2259 set jwot.terr_qual_id34 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2260 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2261 and jwot.header = p_header
2262 and jwot.user_sequence = p_user_sequence
2263 and jwot.interface_type = p_intf_type
2264 and jwot.status is null;
2265 --dbms_output.put_line('34 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2266 when 35 then
2267 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2268 update JTY_WEBADI_OTH_TERR_INTF jwot
2269 set jwot.terr_qual_id35 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2270 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2271 and jwot.header = p_header
2272 and jwot.user_sequence = p_user_sequence
2273 and jwot.interface_type = p_intf_type
2274 and jwot.status is null;
2275 --dbms_output.put_line('35 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2276 when 36 then
2277 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2278 update JTY_WEBADI_OTH_TERR_INTF jwot
2279 set jwot.terr_qual_id36 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2280 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2281 and jwot.header = p_header
2282 and jwot.user_sequence = p_user_sequence
2283 and jwot.interface_type = p_intf_type
2284 and jwot.status is null;
2285 --dbms_output.put_line('36 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2286 when 37 then
2287 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2288 update JTY_WEBADI_OTH_TERR_INTF jwot
2289 set jwot.terr_qual_id37 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2290 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2291 and jwot.header = p_header
2292 and jwot.user_sequence = p_user_sequence
2293 and jwot.interface_type = p_intf_type
2294 and jwot.status is null;
2295 --dbms_output.put_line('37 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2296 when 38 then
2297 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2298 update JTY_WEBADI_OTH_TERR_INTF jwot
2299 set jwot.terr_qual_id38 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2300 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2301 and jwot.header = p_header
2302 and jwot.user_sequence = p_user_sequence
2303 and jwot.interface_type = p_intf_type
2304 and jwot.status is null;
2305 --dbms_output.put_line('38 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2306 when 39 then
2307 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2308 update JTY_WEBADI_OTH_TERR_INTF jwot
2309 set jwot.terr_qual_id39 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2310 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2311 and jwot.header = p_header
2312 and jwot.user_sequence = p_user_sequence
2313 and jwot.interface_type = p_intf_type
2314 and jwot.status is null;
2315 --dbms_output.put_line('39 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2316 when 40 then
2317 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2318 update JTY_WEBADI_OTH_TERR_INTF jwot
2319 set jwot.terr_qual_id40 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2320 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2321 and jwot.header = p_header
2322 and jwot.user_sequence = p_user_sequence
2323 and jwot.interface_type = p_intf_type
2324 and jwot.status is null;
2325 --dbms_output.put_line('40 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2326 when 41 then
2327 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2328 update JTY_WEBADI_OTH_TERR_INTF jwot
2329 set jwot.terr_qual_id41 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2330 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2331 and jwot.header = p_header
2332 and jwot.user_sequence = p_user_sequence
2333 and jwot.interface_type = p_intf_type
2334 and jwot.status is null;
2335 --dbms_output.put_line('41 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2336 when 42 then
2337 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2338 update JTY_WEBADI_OTH_TERR_INTF jwot
2339 set jwot.terr_qual_id42 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2340 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2341 and jwot.header = p_header
2342 and jwot.user_sequence = p_user_sequence
2343 and jwot.interface_type = p_intf_type
2344 and jwot.status is null;
2345 --dbms_output.put_line('42 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2346 when 43 then
2347 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2348 update JTY_WEBADI_OTH_TERR_INTF jwot
2349 set jwot.terr_qual_id43 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2350 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2351 and jwot.header = p_header
2352 and jwot.user_sequence = p_user_sequence
2353 and jwot.interface_type = p_intf_type
2354 and jwot.status is null;
2355 --dbms_output.put_line('43 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2356 when 44 then
2357 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2358 update JTY_WEBADI_OTH_TERR_INTF jwot
2359 set jwot.terr_qual_id44 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2360 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2361 and jwot.header = p_header
2362 and jwot.user_sequence = p_user_sequence
2363 and jwot.interface_type = p_intf_type
2364 and jwot.status is null;
2365 --dbms_output.put_line('44 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2366 when 45 then
2367 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2368 update JTY_WEBADI_OTH_TERR_INTF jwot
2369 set jwot.terr_qual_id45 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2370 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2371 and jwot.header = p_header
2372 and jwot.user_sequence = p_user_sequence
2373 and jwot.interface_type = p_intf_type
2374 and jwot.status is null;
2375 --dbms_output.put_line('45 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2376 when 46 then
2377 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2378 update JTY_WEBADI_OTH_TERR_INTF jwot
2379 set jwot.terr_qual_id46 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2380 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2381 and jwot.header = p_header
2382 and jwot.user_sequence = p_user_sequence
2383 and jwot.interface_type = p_intf_type
2384 and jwot.status is null;
2385 --dbms_output.put_line('46 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2386 when 47 then
2387 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2388 update JTY_WEBADI_OTH_TERR_INTF jwot
2389 set jwot.terr_qual_id47 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2390 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2391 and jwot.header = p_header
2392 and jwot.user_sequence = p_user_sequence
2393 and jwot.interface_type = p_intf_type
2394 and jwot.status is null;
2395 --dbms_output.put_line('47 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2396 when 48 then
2397 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2398 update JTY_WEBADI_OTH_TERR_INTF jwot
2399 set jwot.terr_qual_id48 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2400 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2401 and jwot.header = p_header
2402 and jwot.user_sequence = p_user_sequence
2403 and jwot.interface_type = p_intf_type
2404 and jwot.status is null;
2405 --dbms_output.put_line('48 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2406 when 49 then
2407 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2408 update JTY_WEBADI_OTH_TERR_INTF jwot
2409 set jwot.terr_qual_id49 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2410 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2411 and jwot.header = p_header
2412 and jwot.user_sequence = p_user_sequence
2413 and jwot.interface_type = p_intf_type
2414 and jwot.status is null;
2415 --dbms_output.put_line('49 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2416 when 50 then
2417 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2418 update JTY_WEBADI_OTH_TERR_INTF jwot
2419 set jwot.terr_qual_id50 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2420 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2421 and jwot.header = p_header
2422 and jwot.user_sequence = p_user_sequence
2423 and jwot.interface_type = p_intf_type
2424 and jwot.status is null;
2425 --dbms_output.put_line('50 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2426 when 51 then
2427 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2428 update JTY_WEBADI_OTH_TERR_INTF jwot
2429 set jwot.terr_qual_id51 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2430 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2431 and jwot.header = p_header
2432 and jwot.user_sequence = p_user_sequence
2433 and jwot.interface_type = p_intf_type
2434 and jwot.status is null;
2435 --dbms_output.put_line('51 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2436 when 52 then
2437 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2438 update JTY_WEBADI_OTH_TERR_INTF jwot
2439 set jwot.terr_qual_id52 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2440 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2441 and jwot.header = p_header
2442 and jwot.user_sequence = p_user_sequence
2443 and jwot.interface_type = p_intf_type
2444 and jwot.status is null;
2445 --dbms_output.put_line('52 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2446 when 53 then
2447 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2448 update JTY_WEBADI_OTH_TERR_INTF jwot
2449 set jwot.terr_qual_id53 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2450 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2451 and jwot.header = p_header
2452 and jwot.user_sequence = p_user_sequence
2453 and jwot.interface_type = p_intf_type
2454 and jwot.status is null;
2455 --dbms_output.put_line('53 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2456 when 54 then
2457 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2458 update JTY_WEBADI_OTH_TERR_INTF jwot
2459 set jwot.terr_qual_id54 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2460 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2461 and jwot.header = p_header
2462 and jwot.user_sequence = p_user_sequence
2463 and jwot.interface_type = p_intf_type
2464 and jwot.status is null;
2465 --dbms_output.put_line('54 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2466 when 55 then
2467 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2468 update JTY_WEBADI_OTH_TERR_INTF jwot
2469 set jwot.terr_qual_id55 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2470 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2471 and jwot.header = p_header
2472 and jwot.user_sequence = p_user_sequence
2473 and jwot.interface_type = p_intf_type
2474 and jwot.status is null;
2475 --dbms_output.put_line('55 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2476 when 56 then
2477 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2478 update JTY_WEBADI_OTH_TERR_INTF jwot
2479 set jwot.terr_qual_id56 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2480 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2481 and jwot.header = p_header
2482 and jwot.user_sequence = p_user_sequence
2483 and jwot.interface_type = p_intf_type
2484 and jwot.status is null;
2485 --dbms_output.put_line('56 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2486 when 57 then
2487 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2488 update JTY_WEBADI_OTH_TERR_INTF jwot
2489 set jwot.terr_qual_id57 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2490 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2491 and jwot.header = p_header
2492 and jwot.user_sequence = p_user_sequence
2493 and jwot.interface_type = p_intf_type
2494 and jwot.status is null;
2495 --dbms_output.put_line('57 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2496 when 58 then
2497 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2498 update JTY_WEBADI_OTH_TERR_INTF jwot
2499 set jwot.terr_qual_id58 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2500 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2501 and jwot.header = p_header
2502 and jwot.user_sequence = p_user_sequence
2503 and jwot.interface_type = p_intf_type
2504 and jwot.status is null;
2505 --dbms_output.put_line('58 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2506 when 59 then
2507 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2508 update JTY_WEBADI_OTH_TERR_INTF jwot
2509 set jwot.terr_qual_id59 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2510 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2511 and jwot.header = p_header
2512 and jwot.user_sequence = p_user_sequence
2513 and jwot.interface_type = p_intf_type
2514 and jwot.status is null;
2515 --dbms_output.put_line('59 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2516 when 60 then
2517 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2518 update JTY_WEBADI_OTH_TERR_INTF jwot
2519 set jwot.terr_qual_id60 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2520 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2521 and jwot.header = p_header
2522 and jwot.user_sequence = p_user_sequence
2523 and jwot.interface_type = p_intf_type
2524 and jwot.status is null;
2525 --dbms_output.put_line('60 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2526 when 61 then
2527 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2528 update JTY_WEBADI_OTH_TERR_INTF jwot
2529 set jwot.terr_qual_id61 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2530 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2531 and jwot.header = p_header
2532 and jwot.user_sequence = p_user_sequence
2533 and jwot.interface_type = p_intf_type
2534 and jwot.status is null;
2535 --dbms_output.put_line('61 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2536 when 62 then
2537 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2538 update JTY_WEBADI_OTH_TERR_INTF jwot
2539 set jwot.terr_qual_id62 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2540 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2541 and jwot.header = p_header
2542 and jwot.user_sequence = p_user_sequence
2543 and jwot.interface_type = p_intf_type
2544 and jwot.status is null;
2545 --dbms_output.put_line('62 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2546 when 63 then
2547 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2548 update JTY_WEBADI_OTH_TERR_INTF jwot
2549 set jwot.terr_qual_id63 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2550 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2551 and jwot.header = p_header
2552 and jwot.user_sequence = p_user_sequence
2553 and jwot.interface_type = p_intf_type
2554 and jwot.status is null;
2555 --dbms_output.put_line('63 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2556 when 64 then
2557 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2558 update JTY_WEBADI_OTH_TERR_INTF jwot
2559 set jwot.terr_qual_id64 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2560 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2561 and jwot.header = p_header
2562 and jwot.user_sequence = p_user_sequence
2563 and jwot.interface_type = p_intf_type
2564 and jwot.status is null;
2565 --dbms_output.put_line('64 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2566 when 65 then
2567 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2568 update JTY_WEBADI_OTH_TERR_INTF jwot
2569 set jwot.terr_qual_id65 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2570 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2571 and jwot.header = p_header
2572 and jwot.user_sequence = p_user_sequence
2573 and jwot.interface_type = p_intf_type
2574 and jwot.status is null;
2575 --dbms_output.put_line('65 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2576 when 66 then
2577 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2578 update JTY_WEBADI_OTH_TERR_INTF jwot
2579 set jwot.terr_qual_id66 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2580 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2581 and jwot.header = p_header
2582 and jwot.user_sequence = p_user_sequence
2583 and jwot.interface_type = p_intf_type
2584 and jwot.status is null;
2585 --dbms_output.put_line('66 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2586 when 67 then
2587 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2588 update JTY_WEBADI_OTH_TERR_INTF jwot
2589 set jwot.terr_qual_id67 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2590 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2591 and jwot.header = p_header
2592 and jwot.user_sequence = p_user_sequence
2593 and jwot.interface_type = p_intf_type
2594 and jwot.status is null;
2595 --dbms_output.put_line('67 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2596 when 68 then
2597 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2598 update JTY_WEBADI_OTH_TERR_INTF jwot
2599 set jwot.terr_qual_id68 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2600 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2601 and jwot.header = p_header
2602 and jwot.user_sequence = p_user_sequence
2603 and jwot.interface_type = p_intf_type
2604 and jwot.status is null;
2605 --dbms_output.put_line('68 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2606 when 69 then
2607 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2608 update JTY_WEBADI_OTH_TERR_INTF jwot
2609 set jwot.terr_qual_id69 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2610 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2611 and jwot.header = p_header
2612 and jwot.user_sequence = p_user_sequence
2613 and jwot.interface_type = p_intf_type
2614 and jwot.status is null;
2615 --dbms_output.put_line('69 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2616
2617 when 70 then
2618 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2619 update JTY_WEBADI_OTH_TERR_INTF jwot
2620 set jwot.terr_qual_id70 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2621 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2622 and jwot.header = p_header
2623 and jwot.user_sequence = p_user_sequence
2624 and jwot.interface_type = p_intf_type
2625 and jwot.status is null;
2626 --dbms_output.put_line('70 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2627 when 71 then
2628 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2629 update JTY_WEBADI_OTH_TERR_INTF jwot
2630 set jwot.terr_qual_id71 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2631 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2632 and jwot.header = p_header
2633 and jwot.user_sequence = p_user_sequence
2634 and jwot.interface_type = p_intf_type
2635 and jwot.status is null;
2636 --dbms_output.put_line('71 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2637 when 72 then
2638 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2639 update JTY_WEBADI_OTH_TERR_INTF jwot
2640 set jwot.terr_qual_id72 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2641 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2642 and jwot.header = p_header
2643 and jwot.user_sequence = p_user_sequence
2644 and jwot.interface_type = p_intf_type
2645 and jwot.status is null;
2646 --dbms_output.put_line('72 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2647 when 73 then
2648 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2649 update JTY_WEBADI_OTH_TERR_INTF jwot
2650 set jwot.terr_qual_id73 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2651 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2652 and jwot.header = p_header
2653 and jwot.user_sequence = p_user_sequence
2654 and jwot.interface_type = p_intf_type
2655 and jwot.status is null;
2656 --dbms_output.put_line('73 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2657 when 74 then
2658 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2659 update JTY_WEBADI_OTH_TERR_INTF jwot
2660 set jwot.terr_qual_id74 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2661 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2662 and jwot.header = p_header
2663 and jwot.user_sequence = p_user_sequence
2664 and jwot.interface_type = p_intf_type
2665 and jwot.status is null;
2666 --dbms_output.put_line('74 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2667 when 75 then
2668 forall j in l_terr_qual_rec.lay_seq_num.first..l_terr_qual_rec.lay_seq_num.last
2669 update JTY_WEBADI_OTH_TERR_INTF jwot
2670 set jwot.terr_qual_id75 = l_Terr_Qual_Rec.TERR_QUAL_ID(j)
2671 where jwot.lay_seq_num = l_terr_qual_rec.lay_seq_num(j)
2672 and jwot.header = p_header
2673 and jwot.user_sequence = p_user_sequence
2674 and jwot.interface_type = p_intf_type
2675 and jwot.status is null;
2676 --dbms_output.put_line('75 Update terr_qual_id, actual row processed: '||SQL%ROWCOUNT);
2677
2678 else null;
2679 end case;
2680 end if;
2681 end loop;
2682
2683 --Bug 7622791 : Updating all the entries (Excpet the first) with action_flag 'C' (Create) to 'U' (Update) will mean the newly created entry needs to be updated.
2684 --This is wrong as update will not happen as its a new entry and need to created (Inserted).
2685 /*
2686 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
2687 SET ACTION_FLAG = 'U'
2688 WHERE LAY_SEQ_NUM not in
2689 ( SELECT MIN(jwot2.LAY_SEQ_NUM)
2690 FROM JTY_WEBADI_OTH_TERR_INTF jwot2
2691 WHERE jwot.ACTION_FLAG = jwot2.ACTION_FLAG
2692 and jwot.header = jwot2.header
2693 AND jwot.USER_SEQUENCE = jwot2.USER_SEQUENCE
2694 AND jwot.interface_type = jwot2.interface_type
2695 AND jwot.ACTION_FLAG = jwot2.action_flag
2696 group by jwot.terr_id)
2697 AND jwot.ACTION_FLAG = 'C'
2698 and jwot.header = p_header
2699 AND jwot.USER_SEQUENCE = p_user_sequence
2700 AND jwot.interface_type = p_intf_type;
2701 */
2702
2703 END UPDATE_TERR_QUAL_ID;
2704
2705 PROCEDURE delete_records(
2706 P_USER_SEQUENCE IN NUMBER,
2707 P_INTF_TYPE IN VARCHAR2,
2708 p_action_flag IN VARCHAR2)
2709 IS
2710
2711 cursor get_del_terr_csr(
2712 v_user_sequence number,
2713 v_action_flag varchar2,
2714 v_intf_type varchar2,
2715 v_header varchar2
2716 ) IS
2717 SELECT TERR_ID, lay_seq_num
2718 FROM JTY_WEBADI_OTH_TERR_INTF
2719 WHERE interface_type = v_intf_type
2720 AND action_flag = v_action_flag
2721 AND user_sequence = v_user_sequence
2722 AND header = v_header
2723 AND status IS NULL;
2724
2725 cursor get_del_qual_csr(
2726 v_user_sequence number,
2727 v_action_flag varchar2,
2728 v_intf_type varchar2,
2729 v_header varchar2
2730 ) IS
2731 select sub.terr_qual_id, sub.lay_seq_num
2732 from ( select terr_qual_id1 terr_qual_id, lay_seq_num
2733 from JTY_WEBADI_OTH_TERR_INTF jwot
2734 WHERE jwot.user_sequence = v_user_sequence
2735 and jwot.action_flag = v_action_flag
2736 and jwot.interface_type = v_intf_type
2737 and jwot.header = v_header
2738 and jwot.qual1_value_id is not null
2739 and jwot.status is null
2740 union all
2741 select terr_qual_id2 terr_qual_id, lay_seq_num
2742 from JTY_WEBADI_OTH_TERR_INTF jwot
2743 WHERE jwot.user_sequence = v_user_sequence
2744 and jwot.action_flag = v_action_flag
2745 and jwot.interface_type = v_intf_type
2746 and jwot.header = v_header
2747 and jwot.qual2_value_id is not null
2748 and jwot.status is null
2749 union all
2750 select terr_qual_id3 terr_qual_id, lay_seq_num
2751 from JTY_WEBADI_OTH_TERR_INTF jwot
2752 WHERE jwot.user_sequence = v_user_sequence
2753 and jwot.action_flag = v_action_flag
2754 and jwot.interface_type = v_intf_type
2755 and jwot.header = v_header
2756 and jwot.qual3_value_id is not null
2757 and jwot.status is null
2758 union all
2759 select terr_qual_id4 terr_qual_id, lay_seq_num
2760 from JTY_WEBADI_OTH_TERR_INTF jwot
2761 WHERE jwot.user_sequence = v_user_sequence
2762 and jwot.action_flag = v_action_flag
2763 and jwot.interface_type = v_intf_type
2764 and jwot.header = v_header
2765 and jwot.qual4_value_id is not null
2766 and jwot.status is null
2767 union all
2768 select terr_qual_id5 terr_qual_id, lay_seq_num
2769 from JTY_WEBADI_OTH_TERR_INTF jwot
2770 WHERE jwot.user_sequence = v_user_sequence
2771 and jwot.action_flag = v_action_flag
2772 and jwot.interface_type = v_intf_type
2773 and jwot.header = v_header
2774 and jwot.qual5_value_id is not null
2775 and jwot.status is null
2776 union all
2777 select terr_qual_id6 terr_qual_id, lay_seq_num
2778 from JTY_WEBADI_OTH_TERR_INTF jwot
2779 WHERE jwot.user_sequence = v_user_sequence
2780 and jwot.action_flag = v_action_flag
2781 and jwot.interface_type = v_intf_type
2782 and jwot.header = v_header
2783 and jwot.qual6_value_id is not null
2784 and jwot.status is null
2785 union all
2786 select terr_qual_id7 terr_qual_id, lay_seq_num
2787 from JTY_WEBADI_OTH_TERR_INTF jwot
2788 WHERE jwot.user_sequence = v_user_sequence
2789 and jwot.action_flag = v_action_flag
2790 and jwot.interface_type = v_intf_type
2791 and jwot.header = v_header
2792 and jwot.qual7_value_id is not null
2793 and jwot.status is null
2794 union all
2795 select terr_qual_id8 terr_qual_id, lay_seq_num
2796 from JTY_WEBADI_OTH_TERR_INTF jwot
2797 WHERE jwot.user_sequence = v_user_sequence
2798 and jwot.action_flag = v_action_flag
2799 and jwot.interface_type = v_intf_type
2800 and jwot.header = v_header
2801 and jwot.qual8_value_id is not null
2802 and jwot.status is null
2803 union all
2804 select terr_qual_id9 terr_qual_id, lay_seq_num
2805 from JTY_WEBADI_OTH_TERR_INTF jwot
2806 WHERE jwot.user_sequence = v_user_sequence
2807 and jwot.action_flag = v_action_flag
2808 and jwot.interface_type = v_intf_type
2809 and jwot.header = v_header
2810 and jwot.qual9_value_id is not null
2811 and jwot.status is null
2812 union all
2813 select terr_qual_id10 terr_qual_id, lay_seq_num
2814 from JTY_WEBADI_OTH_TERR_INTF jwot
2815 WHERE jwot.user_sequence = v_user_sequence
2816 and jwot.action_flag = v_action_flag
2817 and jwot.interface_type = v_intf_type
2818 and jwot.header = v_header
2819 and jwot.qual10_value_id is not null
2820 and jwot.status is null
2821 union all
2822 select terr_qual_id11 terr_qual_id, lay_seq_num
2823 from JTY_WEBADI_OTH_TERR_INTF jwot
2824 WHERE jwot.user_sequence = v_user_sequence
2825 and jwot.action_flag = v_action_flag
2826 and jwot.interface_type = v_intf_type
2827 and jwot.header = v_header
2828 and jwot.qual11_value_id is not null
2829 and jwot.status is null
2830 union all
2831 select terr_qual_id12 terr_qual_id, lay_seq_num
2832 from JTY_WEBADI_OTH_TERR_INTF jwot
2833 WHERE jwot.user_sequence = v_user_sequence
2834 and jwot.action_flag = v_action_flag
2835 and jwot.interface_type = v_intf_type
2836 and jwot.header = v_header
2837 and jwot.qual12_value_id is not null
2838 and jwot.status is null
2839 union all
2840 select terr_qual_id13 terr_qual_id, lay_seq_num
2841 from JTY_WEBADI_OTH_TERR_INTF jwot
2842 WHERE jwot.user_sequence = v_user_sequence
2843 and jwot.action_flag = v_action_flag
2844 and jwot.interface_type = v_intf_type
2845 and jwot.header = v_header
2846 and jwot.qual13_value_id is not null
2847 and jwot.status is null
2848 union all
2849 select terr_qual_id14 terr_qual_id, lay_seq_num
2850 from JTY_WEBADI_OTH_TERR_INTF jwot
2851 WHERE jwot.user_sequence = v_user_sequence
2852 and jwot.action_flag = v_action_flag
2853 and jwot.interface_type = v_intf_type
2854 and jwot.header = v_header
2855 and jwot.qual14_value_id is not null
2856 and jwot.status is null
2857 union all
2858 select terr_qual_id15 terr_qual_id, lay_seq_num
2859 from JTY_WEBADI_OTH_TERR_INTF jwot
2860 WHERE jwot.user_sequence = v_user_sequence
2861 and jwot.action_flag = v_action_flag
2862 and jwot.interface_type = v_intf_type
2863 and jwot.header = v_header
2864 and jwot.qual15_value_id is not null
2865 and jwot.status is null
2866 union all
2867 select terr_qual_id16 terr_qual_id, lay_seq_num
2868 from JTY_WEBADI_OTH_TERR_INTF jwot
2869 WHERE jwot.user_sequence = v_user_sequence
2870 and jwot.action_flag = v_action_flag
2871 and jwot.interface_type = v_intf_type
2872 and jwot.header = v_header
2873 and jwot.qual16_value_id is not null
2874 and jwot.status is null
2875 union all
2876 select terr_qual_id17 terr_qual_id, lay_seq_num
2877 from JTY_WEBADI_OTH_TERR_INTF jwot
2878 WHERE jwot.user_sequence = v_user_sequence
2879 and jwot.action_flag = v_action_flag
2880 and jwot.interface_type = v_intf_type
2881 and jwot.header = v_header
2882 and jwot.qual17_value_id is not null
2883 and jwot.status is null
2884 union all
2885 select terr_qual_id18 terr_qual_id, lay_seq_num
2886 from JTY_WEBADI_OTH_TERR_INTF jwot
2887 WHERE jwot.user_sequence = v_user_sequence
2888 and jwot.action_flag = v_action_flag
2889 and jwot.interface_type = v_intf_type
2890 and jwot.header = v_header
2891 and jwot.qual18_value_id is not null
2892 and jwot.status is null
2893 union all
2894 select terr_qual_id19 terr_qual_id, lay_seq_num
2895 from JTY_WEBADI_OTH_TERR_INTF jwot
2896 WHERE jwot.user_sequence = v_user_sequence
2897 and jwot.action_flag = v_action_flag
2898 and jwot.interface_type = v_intf_type
2899 and jwot.header = v_header
2900 and jwot.qual19_value_id is not null
2901 and jwot.status is null
2902 union all
2903 select terr_qual_id20 terr_qual_id, lay_seq_num
2904 from JTY_WEBADI_OTH_TERR_INTF jwot
2905 WHERE jwot.user_sequence = v_user_sequence
2906 and jwot.action_flag = v_action_flag
2907 and jwot.interface_type = v_intf_type
2908 and jwot.header = v_header
2909 and jwot.qual20_value_id is not null
2910 and jwot.status is null
2911 union all
2912 select terr_qual_id21 terr_qual_id, lay_seq_num
2913 from JTY_WEBADI_OTH_TERR_INTF jwot
2914 WHERE jwot.user_sequence = v_user_sequence
2915 and jwot.action_flag = v_action_flag
2916 and jwot.interface_type = v_intf_type
2917 and jwot.header = v_header
2918 and jwot.qual21_value_id is not null
2919 and jwot.status is null
2920 union all
2921 select terr_qual_id22 terr_qual_id, lay_seq_num
2922 from JTY_WEBADI_OTH_TERR_INTF jwot
2923 WHERE jwot.user_sequence = v_user_sequence
2924 and jwot.action_flag = v_action_flag
2925 and jwot.interface_type = v_intf_type
2926 and jwot.header = v_header
2927 and jwot.qual22_value_id is not null
2928 and jwot.status is null
2929 union all
2930 select terr_qual_id23 terr_qual_id, lay_seq_num
2931 from JTY_WEBADI_OTH_TERR_INTF jwot
2932 WHERE jwot.user_sequence = v_user_sequence
2933 and jwot.action_flag = v_action_flag
2934 and jwot.interface_type = v_intf_type
2935 and jwot.header = v_header
2936 and jwot.qual23_value_id is not null
2937 and jwot.status is null
2938 union all
2939 select terr_qual_id24 terr_qual_id, lay_seq_num
2940 from JTY_WEBADI_OTH_TERR_INTF jwot
2941 WHERE jwot.user_sequence = v_user_sequence
2942 and jwot.action_flag = v_action_flag
2943 and jwot.interface_type = v_intf_type
2944 and jwot.header = v_header
2945 and jwot.qual24_value_id is not null
2946 and jwot.status is null
2947 union all
2948 select terr_qual_id25 terr_qual_id, lay_seq_num
2949 from JTY_WEBADI_OTH_TERR_INTF jwot
2950 WHERE jwot.user_sequence = v_user_sequence
2951 and jwot.action_flag = v_action_flag
2952 and jwot.interface_type = v_intf_type
2953 and jwot.header = v_header
2954 and jwot.qual25_value_id is not null
2955 and jwot.status is null
2956 union all
2957 select terr_qual_id26 terr_qual_id, lay_seq_num
2958 from JTY_WEBADI_OTH_TERR_INTF jwot
2959 WHERE jwot.user_sequence = v_user_sequence
2960 and jwot.action_flag = v_action_flag
2961 and jwot.interface_type = v_intf_type
2962 and jwot.header = v_header
2963 and jwot.qual26_value_id is not null
2964 and jwot.status is null
2965 union all
2966 select terr_qual_id27 terr_qual_id, lay_seq_num
2967 from JTY_WEBADI_OTH_TERR_INTF jwot
2968 WHERE jwot.user_sequence = v_user_sequence
2969 and jwot.action_flag = v_action_flag
2970 and jwot.interface_type = v_intf_type
2971 and jwot.header = v_header
2972 and jwot.qual27_value_id is not null
2973 and jwot.status is null
2974 union all
2975 select terr_qual_id28 terr_qual_id, lay_seq_num
2976 from JTY_WEBADI_OTH_TERR_INTF jwot
2977 WHERE jwot.user_sequence = v_user_sequence
2978 and jwot.action_flag = v_action_flag
2979 and jwot.interface_type = v_intf_type
2980 and jwot.header = v_header
2981 and jwot.qual28_value_id is not null
2982 and jwot.status is null
2983 union all
2984 select terr_qual_id29 terr_qual_id, lay_seq_num
2985 from JTY_WEBADI_OTH_TERR_INTF jwot
2986 WHERE jwot.user_sequence = v_user_sequence
2987 and jwot.action_flag = v_action_flag
2988 and jwot.interface_type = v_intf_type
2989 and jwot.header = v_header
2990 and jwot.qual29_value_id is not null
2991 and jwot.status is null
2992 union all
2993 select terr_qual_id30 terr_qual_id, lay_seq_num
2994 from JTY_WEBADI_OTH_TERR_INTF jwot
2995 WHERE jwot.user_sequence = v_user_sequence
2996 and jwot.action_flag = v_action_flag
2997 and jwot.interface_type = v_intf_type
2998 and jwot.header = v_header
2999 and jwot.qual30_value_id is not null
3000 and jwot.status is null
3001 union all
3002 select terr_qual_id31 terr_qual_id, lay_seq_num
3003 from JTY_WEBADI_OTH_TERR_INTF jwot
3004 WHERE jwot.user_sequence = v_user_sequence
3005 and jwot.action_flag = v_action_flag
3006 and jwot.interface_type = v_intf_type
3007 and jwot.header = v_header
3008 and jwot.qual31_value_id is not null
3009 and jwot.status is null
3010 union all
3011 select terr_qual_id32 terr_qual_id, lay_seq_num
3012 from JTY_WEBADI_OTH_TERR_INTF jwot
3013 WHERE jwot.user_sequence = v_user_sequence
3014 and jwot.action_flag = v_action_flag
3015 and jwot.interface_type = v_intf_type
3016 and jwot.header = v_header
3017 and jwot.qual32_value_id is not null
3018 and jwot.status is null
3019 union all
3020 select terr_qual_id33 terr_qual_id, lay_seq_num
3021 from JTY_WEBADI_OTH_TERR_INTF jwot
3022 WHERE jwot.user_sequence = v_user_sequence
3023 and jwot.action_flag = v_action_flag
3024 and jwot.interface_type = v_intf_type
3025 and jwot.header = v_header
3026 and jwot.qual33_value_id is not null
3027 and jwot.status is null
3028 union all
3029 select terr_qual_id34 terr_qual_id, lay_seq_num
3030 from JTY_WEBADI_OTH_TERR_INTF jwot
3031 WHERE jwot.user_sequence = v_user_sequence
3032 and jwot.action_flag = v_action_flag
3033 and jwot.interface_type = v_intf_type
3034 and jwot.header = v_header
3035 and jwot.qual34_value_id is not null
3036 and jwot.status is null
3037 union all
3038 select terr_qual_id35 terr_qual_id, lay_seq_num
3039 from JTY_WEBADI_OTH_TERR_INTF jwot
3040 WHERE jwot.user_sequence = v_user_sequence
3041 and jwot.action_flag = v_action_flag
3042 and jwot.interface_type = v_intf_type
3043 and jwot.header = v_header
3044 and jwot.qual35_value_id is not null
3045 and jwot.status is null
3046 union all
3047 select terr_qual_id36 terr_qual_id, lay_seq_num
3048 from JTY_WEBADI_OTH_TERR_INTF jwot
3049 WHERE jwot.user_sequence = v_user_sequence
3050 and jwot.action_flag = v_action_flag
3051 and jwot.interface_type = v_intf_type
3052 and jwot.header = v_header
3053 and jwot.qual36_value_id is not null
3054 and jwot.status is null
3055 union all
3056 select terr_qual_id37 terr_qual_id, lay_seq_num
3057 from JTY_WEBADI_OTH_TERR_INTF jwot
3058 WHERE jwot.user_sequence = v_user_sequence
3059 and jwot.action_flag = v_action_flag
3060 and jwot.interface_type = v_intf_type
3061 and jwot.header = v_header
3062 and jwot.qual37_value_id is not null
3063 and jwot.status is null
3064 union all
3065 select terr_qual_id38 terr_qual_id, lay_seq_num
3066 from JTY_WEBADI_OTH_TERR_INTF jwot
3067 WHERE jwot.user_sequence = v_user_sequence
3068 and jwot.action_flag = v_action_flag
3069 and jwot.interface_type = v_intf_type
3070 and jwot.header = v_header
3071 and jwot.qual38_value_id is not null
3072 and jwot.status is null
3073 union all
3074 select terr_qual_id39 terr_qual_id, lay_seq_num
3075 from JTY_WEBADI_OTH_TERR_INTF jwot
3076 WHERE jwot.user_sequence = v_user_sequence
3077 and jwot.action_flag = v_action_flag
3078 and jwot.interface_type = v_intf_type
3079 and jwot.header = v_header
3080 and jwot.qual39_value_id is not null
3081 and jwot.status is null
3082 union all
3083 select terr_qual_id40 terr_qual_id, lay_seq_num
3084 from JTY_WEBADI_OTH_TERR_INTF jwot
3085 WHERE jwot.user_sequence = v_user_sequence
3086 and jwot.action_flag = v_action_flag
3087 and jwot.interface_type = v_intf_type
3088 and jwot.header = v_header
3089 and jwot.qual40_value_id is not null
3090 and jwot.status is null
3091 union all
3092 select terr_qual_id41 terr_qual_id, lay_seq_num
3093 from JTY_WEBADI_OTH_TERR_INTF jwot
3094 WHERE jwot.user_sequence = v_user_sequence
3095 and jwot.action_flag = v_action_flag
3096 and jwot.interface_type = v_intf_type
3097 and jwot.header = v_header
3098 and jwot.qual41_value_id is not null
3099 and jwot.status is null
3100 union all
3101 select terr_qual_id42 terr_qual_id, lay_seq_num
3102 from JTY_WEBADI_OTH_TERR_INTF jwot
3103 WHERE jwot.user_sequence = v_user_sequence
3104 and jwot.action_flag = v_action_flag
3105 and jwot.interface_type = v_intf_type
3106 and jwot.header = v_header
3107 and jwot.qual42_value_id is not null
3108 and jwot.status is null
3109 union all
3110 select terr_qual_id43 terr_qual_id, lay_seq_num
3111 from JTY_WEBADI_OTH_TERR_INTF jwot
3112 WHERE jwot.user_sequence = v_user_sequence
3113 and jwot.action_flag = v_action_flag
3114 and jwot.interface_type = v_intf_type
3115 and jwot.header = v_header
3116 and jwot.qual43_value_id is not null
3117 and jwot.status is null
3118 union all
3119 select terr_qual_id44 terr_qual_id, lay_seq_num
3120 from JTY_WEBADI_OTH_TERR_INTF jwot
3121 WHERE jwot.user_sequence = v_user_sequence
3122 and jwot.action_flag = v_action_flag
3123 and jwot.interface_type = v_intf_type
3124 and jwot.header = v_header
3125 and jwot.qual44_value_id is not null
3126 and jwot.status is null
3127 union all
3128 select terr_qual_id45 terr_qual_id, lay_seq_num
3129 from JTY_WEBADI_OTH_TERR_INTF jwot
3130 WHERE jwot.user_sequence = v_user_sequence
3131 and jwot.action_flag = v_action_flag
3132 and jwot.interface_type = v_intf_type
3133 and jwot.header = v_header
3134 and jwot.qual45_value_id is not null
3135 and jwot.status is null
3136 union all
3137 select terr_qual_id46 terr_qual_id, lay_seq_num
3138 from JTY_WEBADI_OTH_TERR_INTF jwot
3139 WHERE jwot.user_sequence = v_user_sequence
3140 and jwot.action_flag = v_action_flag
3141 and jwot.interface_type = v_intf_type
3142 and jwot.header = v_header
3143 and jwot.qual46_value_id is not null
3144 and jwot.status is null
3145 union all
3146 select terr_qual_id47 terr_qual_id, lay_seq_num
3147 from JTY_WEBADI_OTH_TERR_INTF jwot
3148 WHERE jwot.user_sequence = v_user_sequence
3149 and jwot.action_flag = v_action_flag
3150 and jwot.interface_type = v_intf_type
3151 and jwot.header = v_header
3152 and jwot.qual47_value_id is not null
3153 and jwot.status is null
3154 union all
3155 select terr_qual_id48 terr_qual_id, lay_seq_num
3156 from JTY_WEBADI_OTH_TERR_INTF jwot
3157 WHERE jwot.user_sequence = v_user_sequence
3158 and jwot.action_flag = v_action_flag
3159 and jwot.interface_type = v_intf_type
3160 and jwot.header = v_header
3161 and jwot.qual48_value_id is not null
3162 and jwot.status is null
3163 union all
3164 select terr_qual_id49 terr_qual_id, lay_seq_num
3165 from JTY_WEBADI_OTH_TERR_INTF jwot
3166 WHERE jwot.user_sequence = v_user_sequence
3167 and jwot.action_flag = v_action_flag
3168 and jwot.interface_type = v_intf_type
3169 and jwot.header = v_header
3170 and jwot.qual49_value_id is not null
3171 and jwot.status is null
3172 union all
3173 select terr_qual_id50 terr_qual_id, lay_seq_num
3174 from JTY_WEBADI_OTH_TERR_INTF jwot
3175 WHERE jwot.user_sequence = v_user_sequence
3176 and jwot.action_flag = v_action_flag
3177 and jwot.interface_type = v_intf_type
3178 and jwot.header = v_header
3179 and jwot.qual50_value_id is not null
3180 and jwot.status is null
3181 union all
3182 select terr_qual_id51 terr_qual_id, lay_seq_num
3183 from JTY_WEBADI_OTH_TERR_INTF jwot
3184 WHERE jwot.user_sequence = v_user_sequence
3185 and jwot.action_flag = v_action_flag
3186 and jwot.interface_type = v_intf_type
3187 and jwot.header = v_header
3188 and jwot.qual51_value_id is not null
3189 and jwot.status is null
3190 union all
3191 select terr_qual_id52 terr_qual_id, lay_seq_num
3192 from JTY_WEBADI_OTH_TERR_INTF jwot
3193 WHERE jwot.user_sequence = v_user_sequence
3194 and jwot.action_flag = v_action_flag
3195 and jwot.interface_type = v_intf_type
3196 and jwot.header = v_header
3197 and jwot.qual52_value_id is not null
3198 and jwot.status is null
3199 union all
3200 select terr_qual_id53 terr_qual_id, lay_seq_num
3201 from JTY_WEBADI_OTH_TERR_INTF jwot
3202 WHERE jwot.user_sequence = v_user_sequence
3203 and jwot.action_flag = v_action_flag
3204 and jwot.interface_type = v_intf_type
3205 and jwot.header = v_header
3206 and jwot.qual53_value_id is not null
3207 and jwot.status is null
3208 union all
3209 select terr_qual_id54 terr_qual_id, lay_seq_num
3210 from JTY_WEBADI_OTH_TERR_INTF jwot
3211 WHERE jwot.user_sequence = v_user_sequence
3212 and jwot.action_flag = v_action_flag
3213 and jwot.interface_type = v_intf_type
3214 and jwot.header = v_header
3215 and jwot.qual54_value_id is not null
3216 and jwot.status is null
3217 union all
3218 select terr_qual_id55 terr_qual_id, lay_seq_num
3219 from JTY_WEBADI_OTH_TERR_INTF jwot
3220 WHERE jwot.user_sequence = v_user_sequence
3221 and jwot.action_flag = v_action_flag
3222 and jwot.interface_type = v_intf_type
3223 and jwot.header = v_header
3224 and jwot.qual55_value_id is not null
3225 and jwot.status is null
3226 union all
3227 select terr_qual_id56 terr_qual_id, lay_seq_num
3228 from JTY_WEBADI_OTH_TERR_INTF jwot
3229 WHERE jwot.user_sequence = v_user_sequence
3230 and jwot.action_flag = v_action_flag
3231 and jwot.interface_type = v_intf_type
3232 and jwot.header = v_header
3233 and jwot.qual56_value_id is not null
3234 and jwot.status is null
3235 union all
3236 select terr_qual_id57 terr_qual_id, lay_seq_num
3237 from JTY_WEBADI_OTH_TERR_INTF jwot
3238 WHERE jwot.user_sequence = v_user_sequence
3239 and jwot.action_flag = v_action_flag
3240 and jwot.interface_type = v_intf_type
3241 and jwot.header = v_header
3242 and jwot.qual57_value_id is not null
3243 and jwot.status is null
3244 union all
3245 select terr_qual_id58 terr_qual_id, lay_seq_num
3246 from JTY_WEBADI_OTH_TERR_INTF jwot
3247 WHERE jwot.user_sequence = v_user_sequence
3248 and jwot.action_flag = v_action_flag
3249 and jwot.interface_type = v_intf_type
3250 and jwot.header = v_header
3251 and jwot.qual58_value_id is not null
3252 and jwot.status is null
3253 union all
3254 select terr_qual_id59 terr_qual_id, lay_seq_num
3255 from JTY_WEBADI_OTH_TERR_INTF jwot
3256 WHERE jwot.user_sequence = v_user_sequence
3257 and jwot.action_flag = v_action_flag
3258 and jwot.interface_type = v_intf_type
3259 and jwot.header = v_header
3260 and jwot.qual59_value_id is not null
3261 and jwot.status is null
3262 union all
3263 select terr_qual_id60 terr_qual_id, lay_seq_num
3264 from JTY_WEBADI_OTH_TERR_INTF jwot
3265 WHERE jwot.user_sequence = v_user_sequence
3266 and jwot.action_flag = v_action_flag
3267 and jwot.interface_type = v_intf_type
3268 and jwot.header = v_header
3269 and jwot.qual60_value_id is not null
3270 and jwot.status is null
3271 union all
3272 select terr_qual_id61 terr_qual_id, lay_seq_num
3273 from JTY_WEBADI_OTH_TERR_INTF jwot
3274 WHERE jwot.user_sequence = v_user_sequence
3275 and jwot.action_flag = v_action_flag
3276 and jwot.interface_type = v_intf_type
3277 and jwot.header = v_header
3278 and jwot.qual61_value_id is not null
3279 and jwot.status is null
3280 union all
3281 select terr_qual_id62 terr_qual_id, lay_seq_num
3282 from JTY_WEBADI_OTH_TERR_INTF jwot
3283 WHERE jwot.user_sequence = v_user_sequence
3284 and jwot.action_flag = v_action_flag
3285 and jwot.interface_type = v_intf_type
3286 and jwot.header = v_header
3287 and jwot.qual62_value_id is not null
3288 and jwot.status is null
3289 union all
3290 select terr_qual_id63 terr_qual_id, lay_seq_num
3291 from JTY_WEBADI_OTH_TERR_INTF jwot
3292 WHERE jwot.user_sequence = v_user_sequence
3293 and jwot.action_flag = v_action_flag
3294 and jwot.interface_type = v_intf_type
3295 and jwot.header = v_header
3296 and jwot.qual63_value_id is not null
3297 and jwot.status is null
3298 union all
3299 select terr_qual_id64 terr_qual_id, lay_seq_num
3300 from JTY_WEBADI_OTH_TERR_INTF jwot
3301 WHERE jwot.user_sequence = v_user_sequence
3302 and jwot.action_flag = v_action_flag
3303 and jwot.interface_type = v_intf_type
3304 and jwot.header = v_header
3305 and jwot.qual64_value_id is not null
3306 and jwot.status is null
3307 union all
3308 select terr_qual_id65 terr_qual_id, lay_seq_num
3309 from JTY_WEBADI_OTH_TERR_INTF jwot
3310 WHERE jwot.user_sequence = v_user_sequence
3311 and jwot.action_flag = v_action_flag
3312 and jwot.interface_type = v_intf_type
3313 and jwot.header = v_header
3314 and jwot.qual65_value_id is not null
3315 and jwot.status is null
3316 union all
3317 select terr_qual_id66 terr_qual_id, lay_seq_num
3318 from JTY_WEBADI_OTH_TERR_INTF jwot
3319 WHERE jwot.user_sequence = v_user_sequence
3320 and jwot.action_flag = v_action_flag
3321 and jwot.interface_type = v_intf_type
3322 and jwot.header = v_header
3323 and jwot.qual66_value_id is not null
3324 and jwot.status is null
3325 union all
3326 select terr_qual_id67 terr_qual_id, lay_seq_num
3327 from JTY_WEBADI_OTH_TERR_INTF jwot
3328 WHERE jwot.user_sequence = v_user_sequence
3329 and jwot.action_flag = v_action_flag
3330 and jwot.interface_type = v_intf_type
3331 and jwot.header = v_header
3332 and jwot.qual67_value_id is not null
3333 and jwot.status is null
3334 union all
3335 select terr_qual_id68 terr_qual_id, lay_seq_num
3336 from JTY_WEBADI_OTH_TERR_INTF jwot
3337 WHERE jwot.user_sequence = v_user_sequence
3338 and jwot.action_flag = v_action_flag
3339 and jwot.interface_type = v_intf_type
3340 and jwot.header = v_header
3341 and jwot.qual68_value_id is not null
3342 and jwot.status is null
3343 union all
3344 select terr_qual_id69 terr_qual_id, lay_seq_num
3345 from JTY_WEBADI_OTH_TERR_INTF jwot
3346 WHERE jwot.user_sequence = v_user_sequence
3347 and jwot.action_flag = v_action_flag
3348 and jwot.interface_type = v_intf_type
3349 and jwot.header = v_header
3350 and jwot.qual69_value_id is not null
3351 and jwot.status is null
3352 union all
3353 select terr_qual_id70 terr_qual_id, lay_seq_num
3354 from JTY_WEBADI_OTH_TERR_INTF jwot
3355 WHERE jwot.user_sequence = v_user_sequence
3356 and jwot.action_flag = v_action_flag
3357 and jwot.interface_type = v_intf_type
3358 and jwot.header = v_header
3359 and jwot.qual70_value_id is not null
3360 and jwot.status is null
3361 union all
3362 select terr_qual_id71 terr_qual_id, lay_seq_num
3363 from JTY_WEBADI_OTH_TERR_INTF jwot
3364 WHERE jwot.user_sequence = v_user_sequence
3365 and jwot.action_flag = v_action_flag
3366 and jwot.interface_type = v_intf_type
3367 and jwot.header = v_header
3368 and jwot.qual71_value_id is not null
3369 and jwot.status is null
3370 union all
3371 select terr_qual_id72 terr_qual_id, lay_seq_num
3372 from JTY_WEBADI_OTH_TERR_INTF jwot
3373 WHERE jwot.user_sequence = v_user_sequence
3374 and jwot.action_flag = v_action_flag
3375 and jwot.interface_type = v_intf_type
3376 and jwot.header = v_header
3377 and jwot.qual72_value_id is not null
3378 and jwot.status is null
3379 union all
3380 select terr_qual_id73 terr_qual_id, lay_seq_num
3381 from JTY_WEBADI_OTH_TERR_INTF jwot
3382 WHERE jwot.user_sequence = v_user_sequence
3383 and jwot.action_flag = v_action_flag
3384 and jwot.interface_type = v_intf_type
3385 and jwot.header = v_header
3386 and jwot.qual73_value_id is not null
3387 and jwot.status is null
3388 union all
3389 select terr_qual_id74 terr_qual_id, lay_seq_num
3390 from JTY_WEBADI_OTH_TERR_INTF jwot
3391 WHERE jwot.user_sequence = v_user_sequence
3392 and jwot.action_flag = v_action_flag
3393 and jwot.interface_type = v_intf_type
3394 and jwot.header = v_header
3395 and jwot.qual74_value_id is not null
3396 and jwot.status is null
3397 union all
3398 select terr_qual_id75 terr_qual_id, lay_seq_num
3399 from JTY_WEBADI_OTH_TERR_INTF jwot
3400 WHERE jwot.user_sequence = v_user_sequence
3401 and jwot.action_flag = v_action_flag
3402 and jwot.interface_type = v_intf_type
3403 and jwot.header = v_header
3404 and jwot.qual75_value_id is not null
3405 and jwot.status is null
3406 ) sub;
3407
3408 cursor get_del_qual_val_csr(
3409 v_user_sequence number,
3410 v_action_flag varchar2,
3411 v_intf_type varchar2,
3412 v_header varchar2
3413 ) IS
3414 select sub.qual_value_id, sub.lay_seq_num
3415 from ( select qual1_value_id qual_value_id, lay_seq_num
3416 from JTY_WEBADI_OTH_TERR_INTF jwot
3417 WHERE jwot.user_sequence = v_user_sequence
3418 and jwot.action_flag = v_action_flag
3419 and jwot.interface_type = v_intf_type
3420 and jwot.header = v_header
3421 and jwot.qual1_value_id is not null
3422 and jwot.status is null
3423 union all
3424 select qual2_value_id qual_value_id, lay_seq_num
3425 from JTY_WEBADI_OTH_TERR_INTF jwot
3426 WHERE jwot.user_sequence = v_user_sequence
3427 and jwot.action_flag = v_action_flag
3428 and jwot.interface_type = v_intf_type
3429 and jwot.header = v_header
3430 and jwot.qual2_value_id is not null
3431 and jwot.status is null
3432 union all
3433 select qual3_value_id qual_value_id, lay_seq_num
3434 from JTY_WEBADI_OTH_TERR_INTF jwot
3435 WHERE jwot.user_sequence = v_user_sequence
3436 and jwot.action_flag = v_action_flag
3437 and jwot.interface_type = v_intf_type
3438 and jwot.header = v_header
3439 and jwot.qual3_value_id is not null
3440 and jwot.status is null
3441 union all
3442 select qual4_value_id qual_value_id, lay_seq_num
3443 from JTY_WEBADI_OTH_TERR_INTF jwot
3444 WHERE jwot.user_sequence = v_user_sequence
3445 and jwot.action_flag = v_action_flag
3446 and jwot.interface_type = v_intf_type
3447 and jwot.header = v_header
3448 and jwot.qual4_value_id is not null
3449 and jwot.status is null
3450 union all
3451 select qual5_value_id qual_value_id, lay_seq_num
3452 from JTY_WEBADI_OTH_TERR_INTF jwot
3453 WHERE jwot.user_sequence = v_user_sequence
3454 and jwot.action_flag = v_action_flag
3455 and jwot.interface_type = v_intf_type
3456 and jwot.header = v_header
3457 and jwot.qual5_value_id is not null
3458 and jwot.status is null
3459 union all
3460 select qual6_value_id qual_value_id, lay_seq_num
3461 from JTY_WEBADI_OTH_TERR_INTF jwot
3462 WHERE jwot.user_sequence = v_user_sequence
3463 and jwot.action_flag = v_action_flag
3464 and jwot.interface_type = v_intf_type
3465 and jwot.header = v_header
3466 and jwot.qual6_value_id is not null
3467 and jwot.status is null
3468 union all
3469 select qual7_value_id qual_value_id, lay_seq_num
3470 from JTY_WEBADI_OTH_TERR_INTF jwot
3471 WHERE jwot.user_sequence = v_user_sequence
3472 and jwot.action_flag = v_action_flag
3473 and jwot.interface_type = v_intf_type
3474 and jwot.header = v_header
3475 and jwot.qual7_value_id is not null
3476 and jwot.status is null
3477 union all
3478 select qual8_value_id qual_value_id, lay_seq_num
3479 from JTY_WEBADI_OTH_TERR_INTF jwot
3480 WHERE jwot.user_sequence = v_user_sequence
3481 and jwot.action_flag = v_action_flag
3482 and jwot.interface_type = v_intf_type
3483 and jwot.header = v_header
3484 and jwot.qual8_value_id is not null
3485 and jwot.status is null
3486 union all
3487 select qual9_value_id qual_value_id, lay_seq_num
3488 from JTY_WEBADI_OTH_TERR_INTF jwot
3489 WHERE jwot.user_sequence = v_user_sequence
3490 and jwot.action_flag = v_action_flag
3491 and jwot.interface_type = v_intf_type
3492 and jwot.header = v_header
3493 and jwot.qual9_value_id is not null
3494 and jwot.status is null
3495 union all
3496 select qual10_value_id qual_value_id, lay_seq_num
3497 from JTY_WEBADI_OTH_TERR_INTF jwot
3498 WHERE jwot.user_sequence = v_user_sequence
3499 and jwot.action_flag = v_action_flag
3500 and jwot.interface_type = v_intf_type
3501 and jwot.header = v_header
3502 and jwot.qual10_value_id is not null
3503 and jwot.status is null
3504 union all
3505 select qual11_value_id qual_value_id, lay_seq_num
3506 from JTY_WEBADI_OTH_TERR_INTF jwot
3507 WHERE jwot.user_sequence = v_user_sequence
3508 and jwot.action_flag = v_action_flag
3509 and jwot.interface_type = v_intf_type
3510 and jwot.header = v_header
3511 and jwot.qual11_value_id is not null
3512 and jwot.status is null
3513 union all
3514 select qual12_value_id qual_value_id, lay_seq_num
3515 from JTY_WEBADI_OTH_TERR_INTF jwot
3516 WHERE jwot.user_sequence = v_user_sequence
3517 and jwot.action_flag = v_action_flag
3518 and jwot.interface_type = v_intf_type
3519 and jwot.header = v_header
3520 and jwot.qual12_value_id is not null
3521 and jwot.status is null
3522 union all
3523 select qual13_value_id qual_value_id, lay_seq_num
3524 from JTY_WEBADI_OTH_TERR_INTF jwot
3525 WHERE jwot.user_sequence = v_user_sequence
3526 and jwot.action_flag = v_action_flag
3527 and jwot.interface_type = v_intf_type
3528 and jwot.header = v_header
3529 and jwot.qual13_value_id is not null
3530 and jwot.status is null
3531 union all
3532 select qual14_value_id qual_value_id, lay_seq_num
3533 from JTY_WEBADI_OTH_TERR_INTF jwot
3534 WHERE jwot.user_sequence = v_user_sequence
3535 and jwot.action_flag = v_action_flag
3536 and jwot.interface_type = v_intf_type
3537 and jwot.header = v_header
3538 and jwot.qual14_value_id is not null
3539 and jwot.status is null
3540 union all
3541 select qual15_value_id qual_value_id, lay_seq_num
3542 from JTY_WEBADI_OTH_TERR_INTF jwot
3543 WHERE jwot.user_sequence = v_user_sequence
3544 and jwot.action_flag = v_action_flag
3545 and jwot.interface_type = v_intf_type
3546 and jwot.header = v_header
3547 and jwot.qual15_value_id is not null
3548 and jwot.status is null
3549 union all
3550 select qual16_value_id qual_value_id, lay_seq_num
3551 from JTY_WEBADI_OTH_TERR_INTF jwot
3552 WHERE jwot.user_sequence = v_user_sequence
3553 and jwot.action_flag = v_action_flag
3554 and jwot.interface_type = v_intf_type
3555 and jwot.header = v_header
3556 and jwot.qual16_value_id is not null
3557 and jwot.status is null
3558 union all
3559 select qual17_value_id qual_value_id, lay_seq_num
3560 from JTY_WEBADI_OTH_TERR_INTF jwot
3561 WHERE jwot.user_sequence = v_user_sequence
3562 and jwot.action_flag = v_action_flag
3563 and jwot.interface_type = v_intf_type
3564 and jwot.header = v_header
3565 and jwot.qual17_value_id is not null
3566 and jwot.status is null
3567 union all
3568 select qual18_value_id qual_value_id, lay_seq_num
3569 from JTY_WEBADI_OTH_TERR_INTF jwot
3570 WHERE jwot.user_sequence = v_user_sequence
3571 and jwot.action_flag = v_action_flag
3572 and jwot.interface_type = v_intf_type
3573 and jwot.header = v_header
3574 and jwot.qual18_value_id is not null
3575 and jwot.status is null
3576 union all
3577 select qual19_value_id qual_value_id, lay_seq_num
3578 from JTY_WEBADI_OTH_TERR_INTF jwot
3579 WHERE jwot.user_sequence = v_user_sequence
3580 and jwot.action_flag = v_action_flag
3581 and jwot.interface_type = v_intf_type
3582 and jwot.header = v_header
3583 and jwot.qual19_value_id is not null
3584 and jwot.status is null
3585 union all
3586 select qual20_value_id qual_value_id, lay_seq_num
3587 from JTY_WEBADI_OTH_TERR_INTF jwot
3588 WHERE jwot.user_sequence = v_user_sequence
3589 and jwot.action_flag = v_action_flag
3590 and jwot.interface_type = v_intf_type
3591 and jwot.header = v_header
3592 and jwot.qual20_value_id is not null
3593 and jwot.status is null
3594 union all
3595 select qual21_value_id qual_value_id, lay_seq_num
3596 from JTY_WEBADI_OTH_TERR_INTF jwot
3597 WHERE jwot.user_sequence = v_user_sequence
3598 and jwot.action_flag = v_action_flag
3599 and jwot.interface_type = v_intf_type
3600 and jwot.header = v_header
3601 and jwot.qual21_value_id is not null
3602 and jwot.status is null
3603 union all
3604 select qual22_value_id qual_value_id, lay_seq_num
3605 from JTY_WEBADI_OTH_TERR_INTF jwot
3606 WHERE jwot.user_sequence = v_user_sequence
3607 and jwot.action_flag = v_action_flag
3608 and jwot.interface_type = v_intf_type
3609 and jwot.header = v_header
3610 and jwot.qual22_value_id is not null
3611 and jwot.status is null
3612 union all
3613 select qual23_value_id qual_value_id, lay_seq_num
3614 from JTY_WEBADI_OTH_TERR_INTF jwot
3615 WHERE jwot.user_sequence = v_user_sequence
3616 and jwot.action_flag = v_action_flag
3617 and jwot.interface_type = v_intf_type
3618 and jwot.header = v_header
3619 and jwot.qual23_value_id is not null
3620 and jwot.status is null
3621 union all
3622 select qual24_value_id qual_value_id, lay_seq_num
3623 from JTY_WEBADI_OTH_TERR_INTF jwot
3624 WHERE jwot.user_sequence = v_user_sequence
3625 and jwot.action_flag = v_action_flag
3626 and jwot.interface_type = v_intf_type
3627 and jwot.header = v_header
3628 and jwot.qual24_value_id is not null
3629 and jwot.status is null
3630 union all
3631 select qual25_value_id qual_value_id, lay_seq_num
3632 from JTY_WEBADI_OTH_TERR_INTF jwot
3633 WHERE jwot.user_sequence = v_user_sequence
3634 and jwot.action_flag = v_action_flag
3635 and jwot.interface_type = v_intf_type
3636 and jwot.header = v_header
3637 and jwot.qual25_value_id is not null
3638 and jwot.status is null
3639 union all
3640 select qual26_value_id qual_value_id, lay_seq_num
3641 from JTY_WEBADI_OTH_TERR_INTF jwot
3642 WHERE jwot.user_sequence = v_user_sequence
3643 and jwot.action_flag = v_action_flag
3644 and jwot.interface_type = v_intf_type
3645 and jwot.header = v_header
3646 and jwot.qual26_value_id is not null
3647 and jwot.status is null
3648 union all
3649 select qual27_value_id qual_value_id, lay_seq_num
3650 from JTY_WEBADI_OTH_TERR_INTF jwot
3651 WHERE jwot.user_sequence = v_user_sequence
3652 and jwot.action_flag = v_action_flag
3653 and jwot.interface_type = v_intf_type
3654 and jwot.header = v_header
3655 and jwot.qual27_value_id is not null
3656 and jwot.status is null
3657 union all
3658 select qual28_value_id qual_value_id, lay_seq_num
3659 from JTY_WEBADI_OTH_TERR_INTF jwot
3660 WHERE jwot.user_sequence = v_user_sequence
3661 and jwot.action_flag = v_action_flag
3662 and jwot.interface_type = v_intf_type
3663 and jwot.header = v_header
3664 and jwot.qual28_value_id is not null
3665 and jwot.status is null
3666 union all
3667 select qual29_value_id qual_value_id, lay_seq_num
3668 from JTY_WEBADI_OTH_TERR_INTF jwot
3669 WHERE jwot.user_sequence = v_user_sequence
3670 and jwot.action_flag = v_action_flag
3671 and jwot.interface_type = v_intf_type
3672 and jwot.header = v_header
3673 and jwot.qual29_value_id is not null
3674 and jwot.status is null
3675 union all
3676
3677 select qual30_value_id qual_value_id, lay_seq_num
3678 from JTY_WEBADI_OTH_TERR_INTF jwot
3679 WHERE jwot.user_sequence = v_user_sequence
3680 and jwot.action_flag = v_action_flag
3681 and jwot.interface_type = v_intf_type
3682 and jwot.header = v_header
3683 and jwot.qual30_value_id is not null
3684 and jwot.status is null
3685 union all
3686 select qual31_value_id qual_value_id, lay_seq_num
3687 from JTY_WEBADI_OTH_TERR_INTF jwot
3688 WHERE jwot.user_sequence = v_user_sequence
3689 and jwot.action_flag = v_action_flag
3690 and jwot.interface_type = v_intf_type
3691 and jwot.header = v_header
3692 and jwot.qual31_value_id is not null
3693 and jwot.status is null
3694 union all
3695 select qual32_value_id qual_value_id, lay_seq_num
3696 from JTY_WEBADI_OTH_TERR_INTF jwot
3697 WHERE jwot.user_sequence = v_user_sequence
3698 and jwot.action_flag = v_action_flag
3699 and jwot.interface_type = v_intf_type
3700 and jwot.header = v_header
3701 and jwot.qual32_value_id is not null
3702 and jwot.status is null
3703 union all
3704 select qual33_value_id qual_value_id, lay_seq_num
3705 from JTY_WEBADI_OTH_TERR_INTF jwot
3706 WHERE jwot.user_sequence = v_user_sequence
3707 and jwot.action_flag = v_action_flag
3708 and jwot.interface_type = v_intf_type
3709 and jwot.header = v_header
3710 and jwot.qual33_value_id is not null
3711 and jwot.status is null
3712 union all
3713 select qual34_value_id qual_value_id, lay_seq_num
3714 from JTY_WEBADI_OTH_TERR_INTF jwot
3715 WHERE jwot.user_sequence = v_user_sequence
3716 and jwot.action_flag = v_action_flag
3717 and jwot.interface_type = v_intf_type
3718 and jwot.header = v_header
3719 and jwot.qual34_value_id is not null
3720 and jwot.status is null
3721 union all
3722 select qual35_value_id qual_value_id, lay_seq_num
3723 from JTY_WEBADI_OTH_TERR_INTF jwot
3724 WHERE jwot.user_sequence = v_user_sequence
3725 and jwot.action_flag = v_action_flag
3726 and jwot.interface_type = v_intf_type
3727 and jwot.header = v_header
3728 and jwot.qual35_value_id is not null
3729 and jwot.status is null
3730 union all
3731 select qual36_value_id qual_value_id, lay_seq_num
3732 from JTY_WEBADI_OTH_TERR_INTF jwot
3733 WHERE jwot.user_sequence = v_user_sequence
3734 and jwot.action_flag = v_action_flag
3735 and jwot.interface_type = v_intf_type
3736 and jwot.header = v_header
3737 and jwot.qual36_value_id is not null
3738 and jwot.status is null
3739 union all
3740 select qual37_value_id qual_value_id, lay_seq_num
3741 from JTY_WEBADI_OTH_TERR_INTF jwot
3742 WHERE jwot.user_sequence = v_user_sequence
3743 and jwot.action_flag = v_action_flag
3744 and jwot.interface_type = v_intf_type
3745 and jwot.header = v_header
3746 and jwot.qual37_value_id is not null
3747 and jwot.status is null
3748 union all
3749 select qual38_value_id qual_value_id, lay_seq_num
3750 from JTY_WEBADI_OTH_TERR_INTF jwot
3751 WHERE jwot.user_sequence = v_user_sequence
3752 and jwot.action_flag = v_action_flag
3753 and jwot.interface_type = v_intf_type
3754 and jwot.header = v_header
3755 and jwot.qual38_value_id is not null
3756 and jwot.status is null
3757 union all
3758 select qual39_value_id qual_value_id, lay_seq_num
3759 from JTY_WEBADI_OTH_TERR_INTF jwot
3760 WHERE jwot.user_sequence = v_user_sequence
3761 and jwot.action_flag = v_action_flag
3762 and jwot.interface_type = v_intf_type
3763 and jwot.header = v_header
3764 and jwot.qual39_value_id is not null
3765 and jwot.status is null
3766 union all
3767
3768 select qual40_value_id qual_value_id, lay_seq_num
3769 from JTY_WEBADI_OTH_TERR_INTF jwot
3770 WHERE jwot.user_sequence = v_user_sequence
3771 and jwot.action_flag = v_action_flag
3772 and jwot.interface_type = v_intf_type
3773 and jwot.header = v_header
3774 and jwot.qual40_value_id is not null
3775 and jwot.status is null
3776 union all
3777 select qual41_value_id qual_value_id, lay_seq_num
3778 from JTY_WEBADI_OTH_TERR_INTF jwot
3779 WHERE jwot.user_sequence = v_user_sequence
3780 and jwot.action_flag = v_action_flag
3781 and jwot.interface_type = v_intf_type
3782 and jwot.header = v_header
3783 and jwot.qual41_value_id is not null
3784 and jwot.status is null
3785 union all
3786 select qual42_value_id qual_value_id, lay_seq_num
3787 from JTY_WEBADI_OTH_TERR_INTF jwot
3788 WHERE jwot.user_sequence = v_user_sequence
3789 and jwot.action_flag = v_action_flag
3790 and jwot.interface_type = v_intf_type
3791 and jwot.header = v_header
3792 and jwot.qual42_value_id is not null
3793 and jwot.status is null
3794 union all
3795 select qual43_value_id qual_value_id, lay_seq_num
3796 from JTY_WEBADI_OTH_TERR_INTF jwot
3797 WHERE jwot.user_sequence = v_user_sequence
3798 and jwot.action_flag = v_action_flag
3799 and jwot.interface_type = v_intf_type
3800 and jwot.header = v_header
3801 and jwot.qual43_value_id is not null
3802 and jwot.status is null
3803 union all
3804 select qual44_value_id qual_value_id, lay_seq_num
3805 from JTY_WEBADI_OTH_TERR_INTF jwot
3806 WHERE jwot.user_sequence = v_user_sequence
3807 and jwot.action_flag = v_action_flag
3808 and jwot.interface_type = v_intf_type
3809 and jwot.header = v_header
3810 and jwot.qual44_value_id is not null
3811 and jwot.status is null
3812 union all
3813 select qual45_value_id qual_value_id, lay_seq_num
3814 from JTY_WEBADI_OTH_TERR_INTF jwot
3815 WHERE jwot.user_sequence = v_user_sequence
3816 and jwot.action_flag = v_action_flag
3817 and jwot.interface_type = v_intf_type
3818 and jwot.header = v_header
3819 and jwot.qual45_value_id is not null
3820 and jwot.status is null
3821 union all
3822 select qual46_value_id qual_value_id, lay_seq_num
3823 from JTY_WEBADI_OTH_TERR_INTF jwot
3824 WHERE jwot.user_sequence = v_user_sequence
3825 and jwot.action_flag = v_action_flag
3826 and jwot.interface_type = v_intf_type
3827 and jwot.header = v_header
3828 and jwot.qual46_value_id is not null
3829 and jwot.status is null
3830 union all
3831 select qual47_value_id qual_value_id, lay_seq_num
3832 from JTY_WEBADI_OTH_TERR_INTF jwot
3833 WHERE jwot.user_sequence = v_user_sequence
3834 and jwot.action_flag = v_action_flag
3835 and jwot.interface_type = v_intf_type
3836 and jwot.header = v_header
3837 and jwot.qual47_value_id is not null
3838 and jwot.status is null
3839 union all
3840 select qual48_value_id qual_value_id, lay_seq_num
3841 from JTY_WEBADI_OTH_TERR_INTF jwot
3842 WHERE jwot.user_sequence = v_user_sequence
3843 and jwot.action_flag = v_action_flag
3844 and jwot.interface_type = v_intf_type
3845 and jwot.header = v_header
3846 and jwot.qual48_value_id is not null
3847 and jwot.status is null
3848 union all
3849 select qual49_value_id qual_value_id, lay_seq_num
3850 from JTY_WEBADI_OTH_TERR_INTF jwot
3851 WHERE jwot.user_sequence = v_user_sequence
3852 and jwot.action_flag = v_action_flag
3853 and jwot.interface_type = v_intf_type
3854 and jwot.header = v_header
3855 and jwot.qual49_value_id is not null
3856 and jwot.status is null
3857 union all
3858
3859 select qual50_value_id qual_value_id, lay_seq_num
3860 from JTY_WEBADI_OTH_TERR_INTF jwot
3861 WHERE jwot.user_sequence = v_user_sequence
3862 and jwot.action_flag = v_action_flag
3863 and jwot.interface_type = v_intf_type
3864 and jwot.header = v_header
3865 and jwot.qual50_value_id is not null
3866 and jwot.status is null
3867 union all
3868 select qual51_value_id qual_value_id, lay_seq_num
3869 from JTY_WEBADI_OTH_TERR_INTF jwot
3870 WHERE jwot.user_sequence = v_user_sequence
3871 and jwot.action_flag = v_action_flag
3872 and jwot.interface_type = v_intf_type
3873 and jwot.header = v_header
3874 and jwot.qual51_value_id is not null
3875 and jwot.status is null
3876 union all
3877 select qual52_value_id qual_value_id, lay_seq_num
3878 from JTY_WEBADI_OTH_TERR_INTF jwot
3879 WHERE jwot.user_sequence = v_user_sequence
3880 and jwot.action_flag = v_action_flag
3881 and jwot.interface_type = v_intf_type
3882 and jwot.header = v_header
3883 and jwot.qual52_value_id is not null
3884 and jwot.status is null
3885 union all
3886 select qual53_value_id qual_value_id, lay_seq_num
3887 from JTY_WEBADI_OTH_TERR_INTF jwot
3888 WHERE jwot.user_sequence = v_user_sequence
3889 and jwot.action_flag = v_action_flag
3890 and jwot.interface_type = v_intf_type
3891 and jwot.header = v_header
3892 and jwot.qual53_value_id is not null
3893 and jwot.status is null
3894 union all
3895 select qual54_value_id qual_value_id, lay_seq_num
3896 from JTY_WEBADI_OTH_TERR_INTF jwot
3897 WHERE jwot.user_sequence = v_user_sequence
3898 and jwot.action_flag = v_action_flag
3899 and jwot.interface_type = v_intf_type
3900 and jwot.header = v_header
3901 and jwot.qual54_value_id is not null
3902 and jwot.status is null
3903 union all
3904 select qual55_value_id qual_value_id, lay_seq_num
3905 from JTY_WEBADI_OTH_TERR_INTF jwot
3906 WHERE jwot.user_sequence = v_user_sequence
3907 and jwot.action_flag = v_action_flag
3908 and jwot.interface_type = v_intf_type
3909 and jwot.header = v_header
3910 and jwot.qual55_value_id is not null
3911 and jwot.status is null
3912 union all
3913 select qual56_value_id qual_value_id, lay_seq_num
3914 from JTY_WEBADI_OTH_TERR_INTF jwot
3915 WHERE jwot.user_sequence = v_user_sequence
3916 and jwot.action_flag = v_action_flag
3917 and jwot.interface_type = v_intf_type
3918 and jwot.header = v_header
3919 and jwot.qual56_value_id is not null
3920 and jwot.status is null
3921 union all
3922 select qual57_value_id qual_value_id, lay_seq_num
3923 from JTY_WEBADI_OTH_TERR_INTF jwot
3924 WHERE jwot.user_sequence = v_user_sequence
3925 and jwot.action_flag = v_action_flag
3926 and jwot.interface_type = v_intf_type
3927 and jwot.header = v_header
3928 and jwot.qual57_value_id is not null
3929 and jwot.status is null
3930 union all
3931 select qual58_value_id qual_value_id, lay_seq_num
3932 from JTY_WEBADI_OTH_TERR_INTF jwot
3933 WHERE jwot.user_sequence = v_user_sequence
3934 and jwot.action_flag = v_action_flag
3935 and jwot.interface_type = v_intf_type
3936 and jwot.header = v_header
3937 and jwot.qual58_value_id is not null
3938 and jwot.status is null
3939 union all
3940 select qual59_value_id qual_value_id, lay_seq_num
3941 from JTY_WEBADI_OTH_TERR_INTF jwot
3942 WHERE jwot.user_sequence = v_user_sequence
3943 and jwot.action_flag = v_action_flag
3944 and jwot.interface_type = v_intf_type
3945 and jwot.header = v_header
3946 and jwot.qual59_value_id is not null
3947 and jwot.status is null
3948 union all
3949
3950 select qual60_value_id qual_value_id, lay_seq_num
3951 from JTY_WEBADI_OTH_TERR_INTF jwot
3952 WHERE jwot.user_sequence = v_user_sequence
3953 and jwot.action_flag = v_action_flag
3954 and jwot.interface_type = v_intf_type
3955 and jwot.header = v_header
3956 and jwot.qual60_value_id is not null
3957 and jwot.status is null
3958 union all
3959 select qual61_value_id qual_value_id, lay_seq_num
3960 from JTY_WEBADI_OTH_TERR_INTF jwot
3961 WHERE jwot.user_sequence = v_user_sequence
3962 and jwot.action_flag = v_action_flag
3963 and jwot.interface_type = v_intf_type
3964 and jwot.header = v_header
3965 and jwot.qual61_value_id is not null
3966 and jwot.status is null
3967 union all
3968 select qual62_value_id qual_value_id, lay_seq_num
3969 from JTY_WEBADI_OTH_TERR_INTF jwot
3970 WHERE jwot.user_sequence = v_user_sequence
3971 and jwot.action_flag = v_action_flag
3972 and jwot.interface_type = v_intf_type
3973 and jwot.header = v_header
3974 and jwot.qual62_value_id is not null
3975 and jwot.status is null
3976 union all
3977 select qual63_value_id qual_value_id, lay_seq_num
3978 from JTY_WEBADI_OTH_TERR_INTF jwot
3979 WHERE jwot.user_sequence = v_user_sequence
3980 and jwot.action_flag = v_action_flag
3981 and jwot.interface_type = v_intf_type
3982 and jwot.header = v_header
3983 and jwot.qual63_value_id is not null
3984 and jwot.status is null
3985 union all
3986 select qual64_value_id qual_value_id, lay_seq_num
3987 from JTY_WEBADI_OTH_TERR_INTF jwot
3988 WHERE jwot.user_sequence = v_user_sequence
3989 and jwot.action_flag = v_action_flag
3990 and jwot.interface_type = v_intf_type
3991 and jwot.header = v_header
3992 and jwot.qual64_value_id is not null
3993 and jwot.status is null
3994 union all
3995 select qual65_value_id qual_value_id, lay_seq_num
3996 from JTY_WEBADI_OTH_TERR_INTF jwot
3997 WHERE jwot.user_sequence = v_user_sequence
3998 and jwot.action_flag = v_action_flag
3999 and jwot.interface_type = v_intf_type
4000 and jwot.header = v_header
4001 and jwot.qual65_value_id is not null
4002 and jwot.status is null
4003 union all
4004 select qual66_value_id qual_value_id, lay_seq_num
4005 from JTY_WEBADI_OTH_TERR_INTF jwot
4006 WHERE jwot.user_sequence = v_user_sequence
4007 and jwot.action_flag = v_action_flag
4008 and jwot.interface_type = v_intf_type
4009 and jwot.header = v_header
4010 and jwot.qual66_value_id is not null
4011 and jwot.status is null
4012 union all
4013 select qual67_value_id qual_value_id, lay_seq_num
4014 from JTY_WEBADI_OTH_TERR_INTF jwot
4015 WHERE jwot.user_sequence = v_user_sequence
4016 and jwot.action_flag = v_action_flag
4017 and jwot.interface_type = v_intf_type
4018 and jwot.header = v_header
4019 and jwot.qual67_value_id is not null
4020 and jwot.status is null
4021 union all
4022 select qual68_value_id qual_value_id, lay_seq_num
4023 from JTY_WEBADI_OTH_TERR_INTF jwot
4024 WHERE jwot.user_sequence = v_user_sequence
4025 and jwot.action_flag = v_action_flag
4026 and jwot.interface_type = v_intf_type
4027 and jwot.header = v_header
4028 and jwot.qual68_value_id is not null
4029 and jwot.status is null
4030 union all
4031 select qual69_value_id qual_value_id, lay_seq_num
4032 from JTY_WEBADI_OTH_TERR_INTF jwot
4033 WHERE jwot.user_sequence = v_user_sequence
4034 and jwot.action_flag = v_action_flag
4035 and jwot.interface_type = v_intf_type
4036 and jwot.header = v_header
4037 and jwot.qual69_value_id is not null
4038 and jwot.status is null
4039 union all
4040
4041 select qual70_value_id qual_value_id, lay_seq_num
4042 from JTY_WEBADI_OTH_TERR_INTF jwot
4043 WHERE jwot.user_sequence = v_user_sequence
4044 and jwot.action_flag = v_action_flag
4045 and jwot.interface_type = v_intf_type
4046 and jwot.header = v_header
4047 and jwot.qual70_value_id is not null
4048 and jwot.status is null
4049 union all
4050 select qual71_value_id qual_value_id, lay_seq_num
4051 from JTY_WEBADI_OTH_TERR_INTF jwot
4052 WHERE jwot.user_sequence = v_user_sequence
4053 and jwot.action_flag = v_action_flag
4054 and jwot.interface_type = v_intf_type
4055 and jwot.header = v_header
4056 and jwot.qual71_value_id is not null
4057 and jwot.status is null
4058 union all
4059 select qual72_value_id qual_value_id, lay_seq_num
4060 from JTY_WEBADI_OTH_TERR_INTF jwot
4061 WHERE jwot.user_sequence = v_user_sequence
4062 and jwot.action_flag = v_action_flag
4063 and jwot.interface_type = v_intf_type
4064 and jwot.header = v_header
4065 and jwot.qual72_value_id is not null
4066 and jwot.status is null
4067 union all
4068 select qual73_value_id qual_value_id, lay_seq_num
4069 from JTY_WEBADI_OTH_TERR_INTF jwot
4070 WHERE jwot.user_sequence = v_user_sequence
4071 and jwot.action_flag = v_action_flag
4072 and jwot.interface_type = v_intf_type
4073 and jwot.header = v_header
4074 and jwot.qual73_value_id is not null
4075 and jwot.status is null
4076 union all
4077 select qual74_value_id qual_value_id, lay_seq_num
4078 from JTY_WEBADI_OTH_TERR_INTF jwot
4079 WHERE jwot.user_sequence = v_user_sequence
4080 and jwot.action_flag = v_action_flag
4081 and jwot.interface_type = v_intf_type
4082 and jwot.header = v_header
4083 and jwot.qual74_value_id is not null
4084 and jwot.status is null
4085 union all
4086 select qual75_value_id qual_value_id, lay_seq_num
4087 from JTY_WEBADI_OTH_TERR_INTF jwot
4088 WHERE jwot.user_sequence = v_user_sequence
4089 and jwot.action_flag = v_action_flag
4090 and jwot.interface_type = v_intf_type
4091 and jwot.header = v_header
4092 and jwot.qual75_value_id is not null
4093 and jwot.status is null
4094 ) sub;
4095
4096 cursor get_del_rsc_csr(
4097 v_user_sequence number,
4098 v_action_flag varchar2,
4099 v_intf_type varchar2,
4100 v_header varchar2
4101 ) IS
4102 SELECT jwr.TERR_RSC_ID, jwot.lay_seq_num
4103 FROM JTY_WEBADI_OTH_TERR_INTF jwot,
4104 JTY_WEBADI_RESOURCES jwr
4105 WHERE jwot.lay_seq_num = jwr.lay_seq_num
4106 and jwot.header = jwr.header
4107 and jwot.user_sequence = jwr.user_sequence
4108 AND jwot.interface_type = jwr.interface_type
4109 AND jwot.interface_type = v_intf_type
4110 AND jwot.action_flag = v_action_flag
4111 AND jwot.user_sequence = v_user_sequence
4112 AND jwot.header = v_header
4113 AND jwot.status IS NULL;
4114
4115 TYPE DEL_TERR_REC_TYPE is RECORD
4116 ( terr_id number_tbl_type,
4117 lay_seq_num number_tbl_type);
4118
4119 TYPE DEL_QUAL_REC_TYPE is RECORD
4120 ( terr_qual_id number_tbl_type,
4121 lay_seq_num number_tbl_type);
4122
4123 TYPE DEL_QUAL_VAL_REC_TYPE is RECORD
4124 ( qual_value_id number_tbl_type,
4125 lay_seq_num number_tbl_type);
4126
4127 TYPE DEL_RSC_REC_TYPE is RECORD
4128 ( terr_rsc_id number_tbl_type,
4129 lay_seq_num number_tbl_type);
4130
4131 l_del_terr_rec del_terr_rec_type;
4132 l_del_qual_rec del_qual_rec_type;
4133 l_del_rsc_rec del_rsc_rec_type;
4134 l_del_qual_val_rec del_qual_val_rec_type;
4135
4136 l_header varchar2(15);
4137 l_row_count number;
4138 l_intf_type VARCHAR2(1);
4139 l_count NUMBER;
4140 l_api_version_number CONSTANT NUMBER := 1.0;
4141 x_return_status varchar2(255);
4142 X_Msg_Count number;
4143 X_Msg_Data varchar2(255);
4144 l_qual_values_count number;
4145
4146 BEGIN
4147
4148 -- process territory deletion
4149 x_return_status := FND_API.G_RET_STS_SUCCESS;
4150 l_header := 'TERR';
4151 open get_del_terr_csr(p_user_sequence, p_action_flag, p_intf_type, l_header);
4152 fetch get_del_terr_csr bulk collect into l_del_terr_rec.terr_id, l_del_terr_rec.lay_seq_num;
4153 close get_del_terr_csr;
4154
4155 if l_del_terr_rec.terr_id.count > 0 then
4156 BEGIN
4157 forall i in l_del_terr_rec.terr_id.first..l_del_terr_rec.terr_id.last
4158 --Delete Territory Values
4159 DELETE from JTF_TERR_VALUES_ALL WHERE TERR_QUAL_ID IN
4160 ( SELECT TERR_QUAL_ID FROM JTF_TERR_QUAL_ALL
4161 WHERE TERR_ID = l_del_terr_rec.terr_id(i) );
4162
4163 forall i in l_del_terr_rec.terr_id.first..l_del_terr_rec.terr_id.last
4164 --Delete Territory Qualifer records
4165 DELETE from JTF_TERR_QUAL_ALL WHERE TERR_ID = l_del_terr_rec.terr_id(i);
4166
4167 forall i in l_del_terr_rec.terr_id.first..l_del_terr_rec.terr_id.last
4168 --Delete Territory qual type usgs
4169 DELETE from JTF_TERR_QTYPE_USGS_ALL WHERE TERR_ID = l_del_terr_rec.terr_id(i);
4170
4171 forall i in l_del_terr_rec.terr_id.first..l_del_terr_rec.terr_id.last
4172 --Delete Territory usgs
4173 DELETE from JTF_TERR_USGS_ALL WHERE TERR_ID = l_del_terr_rec.terr_id(i);
4174
4175 forall i in l_del_terr_rec.terr_id.first..l_del_terr_rec.terr_id.last
4176 --Delete Territory Resource Access
4177 DELETE from JTF_TERR_RSC_ACCESS_ALL WHERE TERR_RSC_ID IN
4178 ( SELECT TERR_RSC_ID FROM JTF_TERR_RSC_ALL
4179 WHERE TERR_ID = l_del_terr_rec.terr_id(i) );
4180
4181 forall i in l_del_terr_rec.terr_id.first..l_del_terr_rec.terr_id.last
4182 --Delete the Territory Resource records
4183 DELETE from JTF_TERR_RSC_ALL Where TERR_ID = l_del_terr_rec.terr_id(i);
4184
4185 forall i in l_del_terr_rec.terr_id.first..l_del_terr_rec.terr_id.last
4186 --Delete Territory record
4187 DELETE from JTF_TERR_ALL WHERE TERR_ID = l_del_terr_rec.terr_id(i);
4188
4189 -- update all records including the qual and rsc which will be deleted
4190 forall i in l_del_terr_rec.terr_id.first..l_del_terr_rec.terr_id.last
4191 update JTY_WEBADI_OTH_TERR_INTF
4192 set status = x_return_status
4193 where terr_id = l_del_terr_rec.terr_id(i)
4194 and user_sequence = p_user_sequence
4195 and interface_type = p_intf_type;
4196
4197 EXCEPTION
4198 when others then
4199 x_return_status := FND_API.G_RET_STS_ERROR;
4200 fnd_message.clear;
4201 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_DELETE_TERR');
4202 X_Msg_Data := fnd_message.get();
4203
4204 forall i in l_del_terr_rec.lay_seq_num.first..l_del_terr_rec.lay_seq_num.last
4205 update JTY_WEBADI_OTH_TERR_INTF
4206 set status = x_return_status,
4207 error_msg = x_msg_data
4208 where lay_seq_num = l_del_terr_rec.lay_seq_num(i)
4209 and user_sequence = p_user_sequence
4210 and interface_type = p_intf_type;
4211 END;
4212 end if;
4213
4214 -- process qualifier deletion
4215 x_return_status := FND_API.G_RET_STS_SUCCESS;
4216 l_header := 'QUAL';
4217 open get_del_qual_val_csr(p_user_sequence, p_action_flag, p_intf_type, l_header);
4218 fetch get_del_qual_val_csr bulk collect into
4219 l_del_qual_val_rec.qual_value_id, l_del_qual_val_rec.lay_seq_num;
4220 close get_del_qual_val_csr;
4221
4222 if l_del_qual_val_rec.qual_value_id.count > 0 then
4223 BEGIN
4224 FORALL i in l_del_qual_val_rec.qual_value_id.first..l_del_qual_val_rec.qual_value_id.last
4225 DELETE FROM JTF_TERR_VALUES_ALL
4226 WHERE TERR_VALUE_ID = l_del_qual_val_rec.qual_value_id(i);
4227
4228 FOR l_del_qual_rec in get_del_qual_csr(p_user_sequence, p_action_flag, p_intf_type, l_header)
4229 Loop
4230 SELECT COUNT(*) INTO l_qual_values_count FROM JTF_TERR_VALUES_ALL WHERE TERR_QUAL_ID = l_del_qual_rec.terr_qual_id;
4231 IF l_qual_values_count = 0 THEN
4232 DELETE from JTF_TERR_QUAL_ALL jtq
4233 WHERE jtq.terr_qual_id = l_del_qual_rec.terr_qual_id;
4234 END IF;
4235 END Loop;
4236
4237 forall i in l_del_qual_val_rec.lay_seq_num.first..l_del_qual_val_rec.lay_seq_num.last
4238 update JTY_WEBADI_OTH_TERR_INTF
4239 set status = x_return_status
4240 where lay_seq_num = l_del_qual_val_rec.lay_seq_num(i)
4241 and user_sequence = p_user_sequence
4242 and action_flag = p_action_flag
4243 and header = l_header
4244 and interface_type = p_intf_type;
4245
4246 EXCEPTION
4247 when others then
4248 x_return_status := FND_API.G_RET_STS_ERROR;
4249 fnd_message.clear;
4250 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_DELETE_QUAL');
4251 X_Msg_Data := fnd_message.get();
4252
4253 forall i in l_del_qual_val_rec.lay_seq_num.first..l_del_qual_val_rec.lay_seq_num.last
4254 update JTY_WEBADI_OTH_TERR_INTF
4255 set status = x_return_status,
4256 error_msg = x_msg_data
4257 where lay_seq_num = l_del_qual_val_rec.lay_seq_num(i)
4258 and user_sequence = p_user_sequence
4259 and action_flag = p_action_flag
4260 and header = l_header
4261 and interface_type = p_intf_type;
4262 END;
4263 end if;
4264
4265 x_return_status := FND_API.G_RET_STS_SUCCESS;
4266 l_header := 'RSC';
4267 open get_del_rsc_csr(p_user_sequence, p_action_flag, p_intf_type, l_header);
4268 fetch get_del_rsc_csr bulk collect into
4269 l_del_rsc_rec.terr_rsc_id, l_del_rsc_rec.lay_seq_num;
4270 close get_del_rsc_csr;
4271
4272 if l_del_rsc_rec.terr_rsc_id.count > 0 then
4273 BEGIN
4274 --Delete Territory Resource Access
4275 forall i in l_del_rsc_rec.terr_rsc_id.first..l_del_rsc_rec.terr_rsc_id.last
4276 DELETE FROM JTF_TERR_RSC_ACCESS_ALL
4277 WHERE TERR_RSC_ID = l_del_rsc_rec.terr_rsc_id(i);
4278
4279 -- Delete the Territory Resource records
4280 forall i in l_del_rsc_rec.terr_rsc_id.first..l_del_rsc_rec.terr_rsc_id.last
4281 DELETE FROM JTF_TERR_RSC_ALL
4282 WHERE TERR_RSC_ID = l_del_rsc_rec.terr_rsc_id(i);
4283
4284 forall i in l_del_rsc_rec.lay_seq_num.first..l_del_rsc_rec.lay_seq_num.last
4285 update JTY_WEBADI_OTH_TERR_INTF
4286 set status = x_return_status
4287 where lay_seq_num = l_del_rsc_rec.lay_seq_num(i)
4288 and user_sequence = p_user_sequence
4289 and action_flag = p_action_flag
4290 and header = l_header
4291 and interface_type = p_intf_type;
4292
4293 EXCEPTION
4294 when others then
4295 x_return_status := FND_API.G_RET_STS_ERROR;
4296 fnd_message.clear;
4297 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_DELETE_RSC');
4298 X_Msg_Data := fnd_message.get();
4299
4300 forall i in l_del_rsc_rec.lay_seq_num.first..l_del_rsc_rec.lay_seq_num.last
4301 update JTY_WEBADI_OTH_TERR_INTF
4302 set status = x_return_status,
4303 error_msg = x_msg_data
4304 where lay_seq_num = l_del_rsc_rec.lay_seq_num(i)
4305 and user_sequence = p_user_sequence
4306 and action_flag = p_action_flag
4307 and header = l_header
4308 and interface_type = p_intf_type;
4309 END;
4310 end if;
4311
4312 END delete_records;
4313
4314 PROCEDURE INSERT_TERR_QUAL(
4315 p_terr_qual_rec IN OUT NOCOPY Terr_Qual_Rec_Type,
4316 x_return_status OUT NOCOPY VARCHAR2,
4317 x_msg_data OUT NOCOPY VARCHAR2
4318 ) IS
4319 l_OVERLAP_ALLOWED_FLAG varchar2(1) := 'Y';
4320 l_terr_qual_rec terr_qual_rec_type := p_terr_qual_rec;
4321 BEGIN
4322 --x_return_status := FND_API.G_RET_STS_SUCCESS;
4323 if (l_Terr_Qual_Rec.TERR_ID.count > 0) then
4324 --dbms_output.put_line('U: get_qual_csr: create MA, rowcount: ' || l_Terr_Qual_Rec.TERR_ID.count);
4325 forall i in l_Terr_Qual_Rec.TERR_ID.first..l_Terr_Qual_Rec.TERR_ID.last
4326 INSERT INTO JTF_TERR_QUAL_ALL(
4327 TERR_QUAL_ID,
4328 LAST_UPDATE_DATE,
4329 LAST_UPDATED_BY,
4330 CREATION_DATE,
4331 CREATED_BY,
4332 LAST_UPDATE_LOGIN,
4333 TERR_ID,
4334 QUAL_USG_ID,
4335 ORG_ID,
4336 OVERLAP_ALLOWED_FLAG)
4337 VALUES (
4338 --JTF_TERR_QUAL_s.nextval,
4339 l_Terr_Qual_Rec.TERR_QUAL_ID(i),
4340 l_Terr_Qual_Rec.last_update_date(i),
4341 l_Terr_Qual_Rec.last_updated_by(i),
4342 l_Terr_Qual_Rec.creation_date(i),
4343 l_Terr_Qual_Rec.created_by(i),
4344 l_Terr_Qual_Rec.last_update_login(i),
4345 l_Terr_Qual_Rec.terr_id(i),
4346 l_Terr_Qual_Rec.qual_usg_id(i),
4347 l_Terr_Qual_Rec.org_id(i),
4348 l_OVERLAP_ALLOWED_FLAG );
4349 -- RETURNING TERR_QUAL_ID bulk collect into l_Terr_Qual_Rec.TERR_QUAL_ID;
4350 --dbms_output.put_line(' U: get_qual_csr:MA, actual row processed: '||SQL%ROWCOUNT);
4351
4352 end if; --get_qual_csr
4353
4354 EXCEPTION
4355 WHEN OTHERS THEN
4356 x_return_status := FND_API.G_RET_STS_ERROR;
4357 fnd_message.clear;
4358 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_CREATE_QUAL');
4359 X_Msg_Data := fnd_message.get();
4360
4361 END INSERT_TERR_QUAL;
4362
4363 PROCEDURE check_duplicate_value(
4364 p_Terr_Values_Rec IN Terr_values_rec_type,
4365 x_return_status OUT NOCOPY VARCHAR2,
4366 x_msg_data OUT NOCOPY VARCHAR2)
4367 AS
4368
4369 l_dummy VARCHAR2(5);
4370 l_terr_values_rec terr_values_rec_type := p_terr_values_rec;
4371
4372 BEGIN
4373
4374 x_return_status := fnd_api.g_ret_sts_success;
4375
4376 IF(l_terr_values_rec.terr_qual_id.COUNT > 0) THEN
4377 FOR i IN l_terr_values_rec.terr_qual_id.FIRST .. l_terr_values_rec.terr_qual_id.LAST
4378 LOOP
4379 BEGIN
4380 SELECT 'X'
4381 INTO l_dummy
4382 FROM jtf_terr_values_all
4383 WHERE terr_qual_id = l_terr_values_rec.terr_qual_id(i)
4384 AND nvl(comparison_operator, '-9999') = nvl(l_terr_values_rec.comparison_operator(i), '-9999')
4385 AND nvl(low_value_char, '-9999') = nvl(l_terr_values_rec.low_value_char(i), '-9999')
4386 AND nvl(high_value_char, '-9999') = nvl(l_terr_values_rec.high_value_char(i), '-9999')
4387 AND nvl(low_value_number, -9999) = nvl(l_terr_values_rec.low_value_number(i), -9999)
4388 AND nvl(high_value_number, -9999) = nvl(l_terr_values_rec.high_value_number(i), -9999)
4389 AND nvl(interest_type_id, -9999) = nvl(l_terr_values_rec.interest_type_id(i), -9999)
4390 AND nvl(primary_interest_code_id, -9999) = nvl(l_terr_values_rec.primary_interest_code_id(i), -9999)
4391 AND nvl(secondary_interest_code_id, -9999) = nvl(l_terr_values_rec.secondary_interest_code_id(i), -9999)
4392 AND nvl(currency_code, '-9999') = nvl(l_terr_values_rec.currency_code(i), '-9999')
4393 AND nvl(low_value_char_id, -9999) = nvl(l_terr_values_rec.low_value_char_id(i), -9999)
4394 AND nvl(org_id, -9999) = nvl(l_terr_values_rec.org_id(i), -9999)
4395 AND nvl(value1_id, -9999) = nvl(l_terr_values_rec.value1_id(i), -9999)
4396 AND nvl(value2_id, -9999) = nvl(l_terr_values_rec.value2_id(i), -9999)
4397 AND nvl(value3_id, -9999) = nvl(l_terr_values_rec.value3_id(i), -9999) ;
4398 EXCEPTION
4399 WHEN NO_DATA_FOUND THEN
4400 NULL;
4401 END;
4402 END LOOP;
4403 IF l_dummy = 'X' THEN
4404 fnd_message.clear;
4405 fnd_message.set_name('JTF', 'JTY_DUP_TRANS_ATTR_VAL');
4406 x_msg_data := fnd_message.GET();
4407 x_return_status := fnd_api.g_ret_sts_error;
4408 END IF;
4409 END IF;
4410
4411 EXCEPTION --
4412 WHEN others THEN
4413 x_return_status := fnd_api.g_ret_sts_error;
4414 fnd_message.set_name('JTF', 'JTF_TERR_UNEXPECTED_ERROR');
4415 fnd_message.set_token('PROC_NAME', 'Check_duplicate_Value');
4416 fnd_message.set_token('ERROR', sqlerrm);
4417 x_msg_data := fnd_message.GET();
4418 END;
4419
4420 PROCEDURE check_duplicate_value_update(
4421 p_Terr_Values_Rec IN Terr_values_rec_type,
4422 x_return_status OUT NOCOPY VARCHAR2,
4423 x_msg_data OUT NOCOPY VARCHAR2)
4424 AS
4425
4426 l_dummy VARCHAR2(5) := 'Y';
4427 l_terr_values_rec terr_values_rec_type := p_terr_values_rec;
4428
4429 BEGIN
4430
4431 x_return_status := fnd_api.g_ret_sts_success;
4432 --test('p_terr_values_rec.terr_qual_id.COUNT', p_terr_values_rec.terr_qual_id.COUNT);
4433 IF(l_terr_values_rec.terr_qual_id.COUNT > 0) THEN
4434 FOR i IN l_terr_values_rec.terr_qual_id.FIRST .. l_terr_values_rec.terr_qual_id.LAST
4435 LOOP
4436
4437 Begin
4438 SELECT 'X'
4439 INTO l_dummy
4440 FROM jtf_terr_values_all
4441 WHERE TERR_VALUE_ID <> l_terr_values_rec.TERR_VALUE_ID(i)
4442 AND terr_qual_id = l_terr_values_rec.terr_qual_id(i)
4443 AND nvl(comparison_operator, '-9999') = nvl(l_terr_values_rec.comparison_operator(i), '-9999')
4444 AND nvl(low_value_char, '-9999') = nvl(l_terr_values_rec.low_value_char(i), '-9999')
4445 AND nvl(high_value_char, '-9999') = nvl(l_terr_values_rec.high_value_char(i), '-9999')
4446 AND nvl(low_value_number, -9999) = nvl(l_terr_values_rec.low_value_number(i), -9999)
4447 AND nvl(high_value_number, -9999) = nvl(l_terr_values_rec.high_value_number(i), -9999)
4448 AND nvl(interest_type_id, -9999) = nvl(l_terr_values_rec.interest_type_id(i), -9999)
4449 AND nvl(primary_interest_code_id, -9999) = nvl(l_terr_values_rec.primary_interest_code_id(i), -9999)
4450 AND nvl(secondary_interest_code_id, -9999) = nvl(l_terr_values_rec.secondary_interest_code_id(i), -9999)
4451 AND nvl(currency_code, '-9999') = nvl(l_terr_values_rec.currency_code(i), '-9999')
4452 AND nvl(low_value_char_id, -9999) = nvl(l_terr_values_rec.low_value_char_id(i), -9999)
4453 AND nvl(org_id, -9999) = nvl(l_terr_values_rec.org_id(i), -9999)
4454 AND nvl(value1_id, -9999) = nvl(l_terr_values_rec.value1_id(i), -9999)
4455 AND nvl(value2_id, -9999) = nvl(l_terr_values_rec.value2_id(i), -9999)
4456 AND nvl(value3_id, -9999) = nvl(l_terr_values_rec.value3_id(i), -9999) ;
4457 EXCEPTION
4458 WHEN NO_DATA_FOUND THEN
4459 NULL;
4460 END;
4461 END LOOP;
4462
4463 IF l_dummy = 'X' THEN
4464 fnd_message.clear;
4465 fnd_message.set_name('JTF', 'JTY_DUP_TRANS_ATTR_VAL');
4466 x_msg_data := fnd_message.GET();
4467 x_return_status := fnd_api.g_ret_sts_error;
4468 END IF;
4469 END IF;
4470
4471 EXCEPTION --
4472 WHEN others THEN
4473 x_return_status := fnd_api.g_ret_sts_error;
4474 fnd_message.set_name('JTF', 'JTF_TERR_UNEXPECTED_ERROR');
4475 fnd_message.set_token('PROC_NAME', 'Check_duplicate_Value');
4476 fnd_message.set_token('ERROR', sqlerrm);
4477 x_msg_data := fnd_message.GET();
4478 --test('x_msg_data', x_msg_data);
4479 END check_duplicate_value_update;
4480
4481 PROCEDURE INSERT_TERR_VALUES (
4482 p_terr_qual_rec IN Terr_Qual_Rec_Type,
4483 p_terr_values_out_rec OUT NOCOPY Terr_values_out_rec_type,
4484 x_return_status OUT NOCOPY VARCHAR2,
4485 x_msg_data OUT NOCOPY VARCHAR2
4486 ) IS
4487 l_Terr_Values_Rec Terr_values_rec_type;
4488 l_terr_qual_rec Terr_Qual_Rec_Type := p_terr_qual_rec;
4489
4490 BEGIN
4491 --x_return_status := FND_API.G_RET_STS_SUCCESS;
4492 IF (l_Terr_Qual_Rec.TERR_QUAL_ID.count > 0) THEN
4493 for i in l_Terr_Qual_Rec.TERR_QUAL_ID.first..l_Terr_Qual_Rec.TERR_QUAL_ID.last loop
4494
4495 l_Terr_Values_Rec.LAST_UPDATE_DATE(i) := l_Terr_Qual_Rec.LAST_UPDATE_DATE(i);
4496 l_Terr_Values_Rec.LAST_UPDATED_BY(i) := l_Terr_Qual_Rec.LAST_UPDATED_BY(i);
4497 l_Terr_Values_Rec.CREATION_DATE(i) := l_Terr_Qual_Rec.CREATION_DATE(i);
4498 l_Terr_Values_Rec.CREATED_BY(i) := l_Terr_Qual_Rec.CREATED_BY(i);
4499 l_Terr_Values_Rec.LAST_UPDATE_LOGIN(i) := l_Terr_Qual_Rec.LAST_UPDATE_LOGIN(i);
4500 l_Terr_Values_Rec.TERR_QUAL_ID(i) := l_Terr_Qual_Rec.TERR_QUAL_ID(i);
4501 l_Terr_Values_Rec.COMPARISON_OPERATOR(i) := l_Terr_Qual_Rec.qual_cond(i);
4502 l_Terr_Values_Rec.ID_USED_FLAG(i) := l_Terr_Qual_Rec.CONVERT_TO_ID_FLAG(i);
4503 l_Terr_Values_Rec.ORG_ID(i) := l_Terr_Qual_Rec.ORG_ID(i);
4504 l_Terr_Values_Rec.TERR_VALUE_ID(i) := NULL;
4505 l_Terr_Values_Rec.LOW_VALUE_CHAR(i):= NULL;
4506 l_Terr_Values_Rec.HIGH_VALUE_CHAR(i):= NULL;
4507 l_Terr_Values_Rec.LOW_VALUE_NUMBER(i):= NULL;
4508 l_Terr_Values_Rec.HIGH_VALUE_NUMBER(i):= NULL;
4509 l_Terr_Values_Rec.INTEREST_TYPE_ID(i):= NULL;
4510 l_Terr_Values_Rec.PRIMARY_INTEREST_CODE_ID(i):= NULL;
4511 l_Terr_Values_Rec.SECONDARY_INTEREST_CODE_ID(i):= NULL;
4512 l_Terr_Values_Rec.CURRENCY_CODE(i):= NULL;
4513 -- l_Terr_Values_Rec.ID_USED_FLAG(i):= NULL;
4514 l_Terr_Values_Rec.LOW_VALUE_CHAR_ID(i):= NULL;
4515 -- l_Terr_Values_Rec.ORG_ID(i):= NULL;
4516 l_Terr_Values_Rec.VALUE1_ID(i):= NULL;
4517 l_Terr_Values_Rec.VALUE2_ID(i):= NULL;
4518 l_Terr_Values_Rec.VALUE3_ID(i):= NULL;
4519
4520 case
4521 when l_Terr_Qual_Rec.qual_type(i) = 'CHAR' then
4522 --dbms_output.put_line('in ' || l_Terr_Qual_Rec.qual_type(i));
4523 IF l_Terr_Qual_Rec.CONVERT_TO_ID_FLAG(i) = 'N' then
4524 --dbms_output.put_line('in flag' || l_Terr_Qual_Rec.CONVERT_TO_ID_FLAG(i));
4525 l_Terr_Values_Rec.LOW_VALUE_CHAR(i) := l_Terr_Qual_Rec.qual_value1(i);
4526 if l_Terr_Qual_Rec.qual_value2.count > 0 then
4527 --dbms_output.put_line('in l_Terr_Qual_Rec.qual_value2.count');
4528 l_Terr_Values_Rec.HIGH_VALUE_CHAR(i) := l_Terr_Qual_Rec.qual_value2(i);
4529 --dbms_output.put_line('value: ' || NVL(l_Terr_Values_Rec.HIGH_VALUE_CHAR(i),'ABCDE'));
4530 else l_Terr_Values_Rec.HIGH_VALUE_CHAR(i) := NULL;
4531 end if;
4532 else
4533 l_Terr_Values_Rec.LOW_VALUE_CHAR_ID(i) := l_Terr_Qual_Rec.qual_value1(i);
4534 end if;
4535 when l_Terr_Qual_Rec.qual_type(i) = 'DEP_2FIELDS_1CHAR_1ID' then
4536 l_Terr_Values_Rec.LOW_VALUE_CHAR(i) := l_Terr_Qual_Rec.qual_value1(i);
4537 if l_Terr_Qual_Rec.qual_value2.count > 0 then
4538 l_Terr_Values_Rec.LOW_VALUE_CHAR_ID(i) := l_Terr_Qual_Rec.qual_value2(i);
4539 else l_Terr_Values_Rec.LOW_VALUE_CHAR_ID(i) := NULL;
4540 end if;
4541 when l_Terr_Qual_Rec.qual_type(i) in
4542 ('CHAR_2IDS', 'DEP_2FIELDS', 'DEP_2FIELDS_CHAR_2IDS') then
4543 l_Terr_Values_Rec.VALUE1_ID(i) := l_Terr_Qual_Rec.qual_value1(i);
4544 if l_Terr_Qual_Rec.qual_value2.count > 0 then
4545 l_Terr_Values_Rec.VALUE2_ID(i) := l_Terr_Qual_Rec.qual_value2(i);
4546 else l_Terr_Values_Rec.VALUE2_ID(i) := NULL;
4547 end if;
4548 when l_Terr_Qual_Rec.qual_type(i) = 'DEP_3FIELDS_CHAR_3IDS' then
4549 l_Terr_Values_Rec.VALUE1_ID(i) := l_Terr_Qual_Rec.qual_value1(i);
4550 if l_Terr_Qual_Rec.qual_value2.count > 0 then
4551 l_Terr_Values_Rec.VALUE2_ID(i) := l_Terr_Qual_Rec.qual_value2(i);
4552 else l_Terr_Values_Rec.VALUE2_ID(i) := NULL;
4553 end if;
4554 if l_Terr_Qual_Rec.qual_value3.count > 0 then
4555 l_Terr_Values_Rec.VALUE3_ID(i) := l_Terr_Qual_Rec.qual_value3(i);
4556 else l_Terr_Values_Rec.VALUE3_ID(i) := NULL;
4557 end if;
4558 when l_Terr_Qual_Rec.qual_type(i) = 'INTEREST_TYPE' then
4559 l_Terr_Values_Rec.INTEREST_TYPE_ID(i) := l_Terr_Qual_Rec.qual_value1(i);
4560 if l_Terr_Qual_Rec.qual_value2.count > 0 then
4561 l_Terr_Values_Rec.PRIMARY_INTEREST_CODE_ID(i) := l_Terr_Qual_Rec.qual_value2(i);
4562 else l_Terr_Values_Rec.PRIMARY_INTEREST_CODE_ID(i) := NULL;
4563 end if;
4564 if l_Terr_Qual_Rec.qual_value3.count > 0 then
4565 l_Terr_Values_Rec.SECONDARY_INTEREST_CODE_ID(i) := l_Terr_Qual_Rec.qual_value3(i);
4566 else l_Terr_Values_Rec.SECONDARY_INTEREST_CODE_ID(i) := NULL;
4567 end if;
4568 when l_Terr_Qual_Rec.qual_type(i) = 'NUMERIC' then
4569 l_Terr_Values_Rec.LOW_VALUE_NUMBER(i) := l_Terr_Qual_Rec.qual_value1(i);
4570 if l_Terr_Qual_Rec.qual_value2.count > 0 then
4571 l_Terr_Values_Rec.HIGH_VALUE_NUMBER(i) := l_Terr_Qual_Rec.qual_value2(i);
4572 else l_Terr_Values_Rec.HIGH_VALUE_NUMBER(i) := NULL;
4573 end if;
4574 when l_Terr_Qual_Rec.qual_type(i) = 'CURRENCY' then
4575 l_Terr_Values_Rec.LOW_VALUE_NUMBER(i) := l_Terr_Qual_Rec.qual_value1(i);
4576 if l_Terr_Qual_Rec.qual_value2.count > 0 then
4577 l_Terr_Values_Rec.HIGH_VALUE_NUMBER(i) := l_Terr_Qual_Rec.qual_value2(i);
4578 else l_Terr_Values_Rec.HIGH_VALUE_NUMBER(i) := NULL;
4579 end if;
4580 if l_Terr_Qual_Rec.qual_value3.count > 0 then
4581 l_Terr_Values_Rec.CURRENCY_CODE(i) := l_Terr_Qual_Rec.qual_value3(i);
4582 else l_Terr_Values_Rec.CURRENCY_CODE(i) := NULL;
4583 end if;
4584 else null;
4585 end case;
4586 --dbms_output.put_line('case ended');
4587
4588 end loop;
4589
4590 --dbms_output.put_line('C: get_qual_csr: create TV, rowcount: ' || l_Terr_Values_Rec.TERR_QUAL_ID.count);
4591 /*
4592 for i in l_Terr_Values_Rec.TERR_QUAL_ID.first..l_Terr_Values_Rec.TERR_QUAL_ID.last loop
4593 --dbms_output.put_line(l_Terr_Values_Rec.LAST_UPDATED_BY(i)||', '||
4594 l_Terr_Values_Rec.LAST_UPDATE_DATE(i)||', '||
4595 l_Terr_Values_Rec.CREATED_BY(i)||', '||
4596 l_Terr_Values_Rec.CREATION_DATE(i)||', '||
4597 l_Terr_Values_Rec.LAST_UPDATE_LOGIN(i)||', '||
4598 l_Terr_Values_Rec.TERR_QUAL_ID(i)||', '||
4599 l_Terr_Values_Rec.COMPARISON_OPERATOR(i)||', '||
4600 l_Terr_Values_Rec.LOW_VALUE_CHAR(i)||', '||
4601 l_Terr_Values_Rec.HIGH_VALUE_CHAR(i)||', '||
4602 l_Terr_Values_Rec.LOW_VALUE_NUMBER(i)||', '||
4603 l_Terr_Values_Rec.HIGH_VALUE_NUMBER(i)||', '||
4604 l_Terr_Values_Rec.INTEREST_TYPE_ID(i)||', '||
4605 l_Terr_Values_Rec.PRIMARY_INTEREST_CODE_ID(i)||', '||
4606 l_Terr_Values_Rec.SECONDARY_INTEREST_CODE_ID(i)||', '||
4607 l_Terr_Values_Rec.CURRENCY_CODE(i)||', '||
4608 l_Terr_Values_Rec.ID_USED_FLAG(i)||', '||
4609 l_Terr_Values_Rec.LOW_VALUE_CHAR_ID(i)||', '||
4610 l_Terr_Values_Rec.ORG_ID(i)||', '||
4611 l_Terr_Values_Rec.VALUE1_ID(i)||', '||
4612 l_Terr_Values_Rec.VALUE2_ID(i)||', '||
4613 l_Terr_Values_Rec.VALUE3_ID(i) );
4614 end loop;
4615 */
4616
4617 --Check for duplicate values.
4618 x_return_status := FND_API.G_RET_STS_SUCCESS;
4619
4620 Check_duplicate_Value(
4621 p_Terr_Values_Rec => l_Terr_Values_Rec ,
4622 x_return_status => x_return_status,
4623 x_msg_data => x_msg_data );
4624
4625
4626 IF x_return_status = FND_API.G_RET_STS_SUCCESS THEN
4627 forall i in l_Terr_Values_Rec.TERR_QUAL_ID.first..l_Terr_Values_Rec.TERR_QUAL_ID.last
4628 INSERT INTO JTF_TERR_VALUES_ALL(
4629 TERR_VALUE_ID,
4630 LAST_UPDATED_BY,
4631 LAST_UPDATE_DATE,
4632 CREATED_BY,
4633 CREATION_DATE,
4634 LAST_UPDATE_LOGIN,
4635 TERR_QUAL_ID,
4636 COMPARISON_OPERATOR,
4637 LOW_VALUE_CHAR,
4638 HIGH_VALUE_CHAR,
4639 LOW_VALUE_NUMBER,
4640 HIGH_VALUE_NUMBER,
4641 INTEREST_TYPE_ID,
4642 PRIMARY_INTEREST_CODE_ID,
4643 SECONDARY_INTEREST_CODE_ID,
4644 CURRENCY_CODE,
4645 ID_USED_FLAG,
4646 LOW_VALUE_CHAR_ID,
4647 ORG_ID,
4648 VALUE1_ID,
4649 VALUE2_ID,
4650 VALUE3_ID
4651 )
4652 VALUES (
4653 JTF_TERR_VALUES_s.nextval,
4654 l_Terr_Values_Rec.LAST_UPDATED_BY(i),
4655 l_Terr_Values_Rec.LAST_UPDATE_DATE(i),
4656 l_Terr_Values_Rec.CREATED_BY(i),
4657 l_Terr_Values_Rec.CREATION_DATE(i),
4658 l_Terr_Values_Rec.LAST_UPDATE_LOGIN(i),
4659 l_Terr_Values_Rec.TERR_QUAL_ID(i),
4660 l_Terr_Values_Rec.COMPARISON_OPERATOR(i),
4661 l_Terr_Values_Rec.LOW_VALUE_CHAR(i),
4662 l_Terr_Values_Rec.HIGH_VALUE_CHAR(i),
4663 l_Terr_Values_Rec.LOW_VALUE_NUMBER(i),
4664 l_Terr_Values_Rec.HIGH_VALUE_NUMBER(i),
4665 l_Terr_Values_Rec.INTEREST_TYPE_ID(i),
4666 l_Terr_Values_Rec.PRIMARY_INTEREST_CODE_ID(i),
4667 l_Terr_Values_Rec.SECONDARY_INTEREST_CODE_ID(i),
4668 l_Terr_Values_Rec.CURRENCY_CODE(i),
4669 l_Terr_Values_Rec.ID_USED_FLAG(i),
4670 l_Terr_Values_Rec.LOW_VALUE_CHAR_ID(i),
4671 l_Terr_Values_Rec.ORG_ID(i),
4672 l_Terr_Values_Rec.VALUE1_ID(i),
4673 l_Terr_Values_Rec.VALUE2_ID(i),
4674 l_Terr_Values_Rec.VALUE3_ID(i)
4675 ) RETURNING TERR_VALUE_ID,TERR_QUAL_ID
4676 BULK COLLECT INTO p_terr_values_out_rec.TERR_VALUE_ID,
4677 p_terr_values_out_rec.TERR_QUAL_ID;
4678
4679
4680 forall i in l_terr_qual_rec.TERR_ID.first..l_terr_qual_rec.TERR_ID.last
4681 delete from jtf_terr_qual_all where terr_id = l_terr_qual_rec.TERR_ID(i) and terr_qual_id not in (select terr_qual_id from jtf_terr_values_all);
4682
4683 --dbms_output.put_line(' C: get_qual_csr:TV, actual row processed: '||SQL%ROWCOUNT);
4684
4685 x_return_status := FND_API.G_RET_STS_SUCCESS;
4686 END IF;
4687 END IF; -- TERR_QUAL_ID count
4688 EXCEPTION
4689 WHEN OTHERS THEN
4690 x_return_status := FND_API.G_RET_STS_ERROR;
4691 fnd_message.clear;
4692 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_CREATE_QUAL_VAL');
4693 X_Msg_Data := fnd_message.get();
4694
4695 --dbms_output.put_line(sqlerrm);
4696
4697 END INSERT_TERR_VALUES;
4698
4699 PROCEDURE UPDATE_TERR(
4700 p_user_sequence IN number,
4701 p_action_flag IN varchar2,
4702 x_return_status OUT NOCOPY varchar2,
4703 x_msg_data OUT NOCOPY varchar2
4704 ) IS
4705
4706 CURSOR get_terr_all_csr (
4707 v_user_sequence number,
4708 v_header varchar2,
4709 v_action_flag varchar2,
4710 v_intf_type varchar2) IS
4711 Select
4712 NVL(TERR_ID,JTF_TERR_s.nextval) TERR_ID,
4713 LAST_UPDATE_DATE,
4714 LAST_UPDATED_BY,
4715 CREATION_DATE,
4716 CREATED_BY,
4717 LAST_UPDATE_LOGIN,
4718 'JTF' APPLICATION_SHORT_NAME,
4719 TERR_NAME NAME,
4720 'Y' ENABLED_FLAG,
4721 NVL(TERR_START_DATE,TRUNC(SYSDATE)) START_DATE_ACTIVE,
4722 RANK,
4723 NVL(TERR_END_DATE, ADD_MONTHS(NVL(TERR_START_DATE,TRUNC(SYSDATE)), 12) )END_DATE_ACTIVE,
4724 TERR_NAME DESCRIPTION,
4725 'Y' UPDATE_FLAG,
4726 TERR_TYPE_ID TERRITORY_TYPE_ID,
4727 PARENT_TERR_ID PARENT_TERRITORY_ID,
4728 'N' TEMPLATE_FLAG,
4729 'N' ESCALATION_TERRITORY_FLAG,
4730 ATTRIBUTE_CATEGORY,
4731 ATTRIBUTE1,
4732 ATTRIBUTE2,
4733 ATTRIBUTE3,
4734 ATTRIBUTE4,
4735 ATTRIBUTE5,
4736 ATTRIBUTE6,
4737 ATTRIBUTE7,
4738 ATTRIBUTE8,
4739 ATTRIBUTE9,
4740 ATTRIBUTE10,
4741 ATTRIBUTE11,
4742 ATTRIBUTE12,
4743 ATTRIBUTE13,
4744 ATTRIBUTE14,
4745 ATTRIBUTE15,
4746 ORG_ID,
4747 NUM_WINNERS,
4748 0 NUM_QUAL,
4749 lay_seq_num
4750 , trim(HIERARCHY) terr_hierarchy
4751 from JTY_WEBADI_OTH_TERR_INTF
4752 where header = v_header
4753 and status is null
4754 and USER_SEQUENCE = v_USER_SEQUENCE
4755 and INTERFACE_TYPE = v_intf_type
4756 and action_flag = v_action_flag;
4757
4758 TYPE Terr_All_Rec_Type IS RECORD
4759 (TERR_ID number_tbl_type,
4760 LAST_UPDATE_DATE date_tbl_type,
4761 LAST_UPDATED_BY number_tbl_type,
4762 CREATION_DATE date_tbl_type,
4763 CREATED_BY number_tbl_type,
4764 LAST_UPDATE_LOGIN number_tbl_type,
4765 APPLICATION_SHORT_NAME varchar2_tbl_type,
4766 NAME var_2000_tbl_type,
4767 ENABLED_FLAG var_1_tbl_type,
4768 START_DATE_ACTIVE date_tbl_type,
4769 RANK number_tbl_type,
4770 END_DATE_ACTIVE date_tbl_type,
4771 DESCRIPTION varchar2_tbl_type,
4772 UPDATE_FLAG var_1_tbl_type,
4773 TERRITORY_TYPE_ID number_tbl_type,
4774 PARENT_TERRITORY_ID number_tbl_type,
4775 TEMPLATE_FLAG var_1_tbl_type,
4776 ESCALATION_TERRITORY_FLAG var_1_tbl_type,
4777 ATTRIBUTE_CATEGORY varchar2_tbl_type,
4778 ATTRIBUTE1 varchar2_tbl_type,
4779 ATTRIBUTE2 varchar2_tbl_type,
4780 ATTRIBUTE3 varchar2_tbl_type,
4781 ATTRIBUTE4 varchar2_tbl_type,
4782 ATTRIBUTE5 varchar2_tbl_type,
4783 ATTRIBUTE6 varchar2_tbl_type,
4784 ATTRIBUTE7 varchar2_tbl_type,
4785 ATTRIBUTE8 varchar2_tbl_type,
4786 ATTRIBUTE9 varchar2_tbl_type,
4787 ATTRIBUTE10 varchar2_tbl_type,
4788 ATTRIBUTE11 varchar2_tbl_type,
4789 ATTRIBUTE12 varchar2_tbl_type,
4790 ATTRIBUTE13 varchar2_tbl_type,
4791 ATTRIBUTE14 varchar2_tbl_type,
4792 ATTRIBUTE15 varchar2_tbl_type,
4793 ORG_ID number_tbl_type ,
4794 NUM_WINNERS number_tbl_type,
4795 NUM_QUAL number_tbl_type,
4796 LAY_SEQ_NUM number_tbl_type,
4797 terr_hierarchy varchar2_tbl_type
4798 );
4799
4800 l_terr_all_rec Terr_All_Rec_Type;
4801 l_header varchar2(15) := 'TERR';
4802 l_intf_type varchar2(1) := 'U';
4803
4804 BEGIN
4805
4806 x_return_status := FND_API.G_RET_STS_SUCCESS;
4807
4808 open get_terr_all_csr( p_user_sequence, l_header, p_action_flag, l_intf_type);
4809 fetch get_terr_all_csr bulk collect into l_terr_all_rec.TERR_ID,
4810 l_terr_all_rec.LAST_UPDATE_DATE, l_terr_all_rec.LAST_UPDATED_BY,
4811 l_terr_all_rec.CREATION_DATE, l_terr_all_rec.CREATED_BY,
4812 l_terr_all_rec.LAST_UPDATE_LOGIN, l_terr_all_rec.APPLICATION_SHORT_NAME,
4813 l_terr_all_rec.NAME, l_terr_all_rec.ENABLED_FLAG,
4814 l_terr_all_rec.START_DATE_ACTIVE, l_terr_all_rec.RANK,
4815 l_terr_all_rec.END_DATE_ACTIVE, l_terr_all_rec.DESCRIPTION,
4816 l_terr_all_rec.UPDATE_FLAG, l_terr_all_rec.TERRITORY_TYPE_ID,
4817 l_terr_all_rec.PARENT_TERRITORY_ID, l_terr_all_rec.TEMPLATE_FLAG,
4818 l_terr_all_rec.ESCALATION_TERRITORY_FLAG, l_terr_all_rec.ATTRIBUTE_CATEGORY,
4819 l_terr_all_rec.ATTRIBUTE1, l_terr_all_rec.ATTRIBUTE2, l_terr_all_rec.ATTRIBUTE3,
4820 l_terr_all_rec.ATTRIBUTE4, l_terr_all_rec.ATTRIBUTE5, l_terr_all_rec.ATTRIBUTE6,
4821 l_terr_all_rec.ATTRIBUTE7, l_terr_all_rec.ATTRIBUTE8, l_terr_all_rec.ATTRIBUTE9,
4822 l_terr_all_rec.ATTRIBUTE10,l_terr_all_rec.ATTRIBUTE11,l_terr_all_rec.ATTRIBUTE12,
4823 l_terr_all_rec.ATTRIBUTE13,l_terr_all_rec.ATTRIBUTE14,l_terr_all_rec.ATTRIBUTE15,
4824 l_terr_all_rec.ORG_ID, l_terr_all_rec.NUM_WINNERS, l_terr_all_rec.NUM_QUAL,
4825 l_terr_all_rec.lay_seq_num, l_terr_all_rec.terr_hierarchy;
4826 close get_terr_all_csr;
4827
4828 if (p_action_flag = 'C' and l_terr_all_rec.NAME.count > 0) then
4829 --forall i in l_terr_all_rec.NAME.first..l_terr_all_rec.NAME.last
4830 for i in l_terr_all_rec.NAME.first..l_terr_all_rec.NAME.last LOOP
4831 INSERT INTO JTF_TERR_ALL(
4832 TERR_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY,
4833 CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN,
4834 APPLICATION_SHORT_NAME, NAME, ENABLED_FLAG,
4835 START_DATE_ACTIVE, RANK, END_DATE_ACTIVE, DESCRIPTION,
4836 UPDATE_FLAG, TERRITORY_TYPE_ID, PARENT_TERRITORY_ID,
4837 TEMPLATE_FLAG, ESCALATION_TERRITORY_FLAG, ATTRIBUTE_CATEGORY,
4838 ATTRIBUTE1, ATTRIBUTE2, ATTRIBUTE3,
4839 ATTRIBUTE4, ATTRIBUTE5, ATTRIBUTE6,
4840 ATTRIBUTE7, ATTRIBUTE8, ATTRIBUTE9,
4841 ATTRIBUTE10, ATTRIBUTE11, ATTRIBUTE12,
4842 ATTRIBUTE13, ATTRIBUTE14, ATTRIBUTE15,
4843 ORG_ID, NUM_WINNERS, NUM_QUAL
4844 ) VALUES (
4845 l_terr_all_rec.TERR_ID(i),
4846 l_terr_all_rec.LAST_UPDATE_DATE(i), l_terr_all_rec.LAST_UPDATED_BY(i),
4847 l_terr_all_rec.CREATION_DATE(i), l_terr_all_rec.CREATED_BY(i),
4848 l_terr_all_rec.LAST_UPDATE_LOGIN(i), l_terr_all_rec.APPLICATION_SHORT_NAME(i),
4849 l_terr_all_rec.NAME(i), l_terr_all_rec.ENABLED_FLAG(i),
4850 l_terr_all_rec.START_DATE_ACTIVE(i), l_terr_all_rec.RANK(i),
4851 l_terr_all_rec.END_DATE_ACTIVE(i), l_terr_all_rec.DESCRIPTION(i),
4852 l_terr_all_rec.UPDATE_FLAG(i), l_terr_all_rec.TERRITORY_TYPE_ID(i),
4853 l_terr_all_rec.PARENT_TERRITORY_ID(i), l_terr_all_rec.TEMPLATE_FLAG(i),
4854 l_terr_all_rec.ESCALATION_TERRITORY_FLAG(i), l_terr_all_rec.ATTRIBUTE_CATEGORY(i),
4855 l_terr_all_rec.ATTRIBUTE1(i), l_terr_all_rec.ATTRIBUTE2(i), l_terr_all_rec.ATTRIBUTE3(i),
4856 l_terr_all_rec.ATTRIBUTE4(i), l_terr_all_rec.ATTRIBUTE5(i), l_terr_all_rec.ATTRIBUTE6(i),
4857 l_terr_all_rec.ATTRIBUTE7(i), l_terr_all_rec.ATTRIBUTE8(i), l_terr_all_rec.ATTRIBUTE9(i),
4858 l_terr_all_rec.ATTRIBUTE10(i),l_terr_all_rec.ATTRIBUTE11(i),l_terr_all_rec.ATTRIBUTE12(i),
4859 l_terr_all_rec.ATTRIBUTE13(i),l_terr_all_rec.ATTRIBUTE14(i),l_terr_all_rec.ATTRIBUTE15(i),
4860 l_terr_all_rec.ORG_ID(i), l_terr_all_rec.NUM_WINNERS(i), l_terr_all_rec.NUM_QUAL(i));
4861
4862 if ( l_terr_all_rec.PARENT_TERRITORY_ID(i) = 1 AND l_terr_all_rec.terr_hierarchy(i) IS NOT NULL) THEN
4863 populate_parent_id(
4864 p_user_sequence => p_user_sequence,
4865 p_intf_type => l_intf_type,
4866 p_hierarchy => l_terr_all_rec.terr_hierarchy(i),
4867 p_org_id => l_terr_all_rec.ORG_ID(i),
4868 p_terr_id => l_terr_all_rec.TERR_ID(i),
4869 p_terr_name => l_terr_all_rec.name(i),
4870 x_return_status => x_return_status,
4871 x_msg_data => x_msg_data);
4872 END IF;
4873 END LOOP;
4874
4875 forall i in l_terr_all_rec.TERR_ID.first..l_terr_all_rec.TERR_ID.last
4876 update JTY_WEBADI_OTH_TERR_INTF
4877 set parent_terr_id = l_terr_all_rec.terr_id(i)
4878 where parent_terr_name = l_terr_all_rec.name(i)
4879 and USER_SEQUENCE = P_USER_SEQUENCE
4880 and interface_type = l_intf_type
4881 and parent_terr_id is null;
4882
4883 forall i in l_terr_all_rec.TERR_ID.first..l_terr_all_rec.TERR_ID.last
4884 update JTY_WEBADI_OTH_TERR_INTF
4885 set terr_id = l_terr_all_rec.terr_id(i)
4886 where terr_name = l_terr_all_rec.name(i)
4887 and USER_SEQUENCE = P_USER_SEQUENCE
4888 and interface_type = l_intf_type
4889 and action_flag = p_action_flag;
4890
4891 INSERT INTO JTF_TERR_USGS_ALL(
4892 TERR_USG_ID,
4893 LAST_UPDATE_DATE,
4894 LAST_UPDATED_BY,
4895 CREATION_DATE,
4896 CREATED_BY,
4897 LAST_UPDATE_LOGIN,
4898 TERR_ID,
4899 SOURCE_ID,
4900 ORG_ID
4901 )
4902 SELECT
4903 JTF_TERR_USGS_s.nextval TERR_USG_ID,
4904 LAST_UPDATE_DATE,
4905 LAST_UPDATED_BY,
4906 CREATION_DATE,
4907 CREATED_BY,
4908 LAST_UPDATE_LOGIN,
4909 TERR_ID,
4910 usage_id SOURCE_ID,
4911 ORG_ID
4912 from JTY_WEBADI_OTH_TERR_INTF
4913 where header = l_header
4914 and status is null
4915 and USER_SEQUENCE = p_USER_SEQUENCE
4916 and INTERFACE_TYPE = l_intf_type
4917 and action_flag = p_action_flag;
4918
4919 INSERT INTO JTF_TERR_QTYPE_USGS_ALL(
4920 TERR_QTYPE_USG_ID,
4921 LAST_UPDATED_BY,
4922 LAST_UPDATE_DATE,
4923 CREATED_BY,
4924 CREATION_DATE,
4925 LAST_UPDATE_LOGIN,
4926 TERR_ID,
4927 QUAL_TYPE_USG_ID,
4928 ORG_ID
4929 )
4930 select
4931 JTF_TERR_QTYPE_USGS_s.nextval TERR_QUAL_TYPE_USG_ID,
4932 LAST_UPDATED_BY,
4933 LAST_UPDATE_DATE,
4934 CREATED_BY,
4935 CREATION_DATE,
4936 LAST_UPDATE_LOGIN,
4937 TERR_ID,
4938 QUAL_TYPE_ID QUAL_TYPE_USG_ID,
4939 ORG_ID
4940 from JTY_WEBADI_QUAL_TYPE_HEADER gt,
4941 JTY_WEBADI_OTH_TERR_INTF jut
4942 where jut.header = L_header
4943 and jut.status is null
4944 and jut.USER_SEQUENCE = P_USER_SEQUENCE
4945 and jut.INTERFACE_TYPE = l_intf_type
4946 and jut.action_flag = p_action_flag
4947 and gt.user_sequence = jut.user_sequence;
4948
4949 forall i in l_terr_all_rec.lay_seq_num.first..l_terr_all_rec.lay_seq_num.last
4950 update JTY_WEBADI_OTH_TERR_INTF
4951 set status = x_return_status
4952 , error_msg = X_Msg_Data
4953 where lay_seq_num = l_terr_all_rec.lay_seq_num(i)
4954 and interface_type = l_intf_type
4955 and header = l_header
4956 and user_sequence = p_user_sequence;
4957
4958 end if;
4959
4960 x_return_status := FND_API.G_RET_STS_SUCCESS;
4961 if (p_action_flag = 'U' and l_terr_all_rec.TERR_ID.count > 0) then
4962
4963 forall i in l_terr_all_rec.TERR_ID.first..l_terr_all_rec.TERR_ID.last
4964 Update JTF_TERR_ALL
4965 SET
4966 LAST_UPDATE_DATE = l_terr_all_rec.LAST_UPDATE_DATE(i),
4967 LAST_UPDATED_BY = l_terr_all_rec.LAST_UPDATED_BY(i),
4968 LAST_UPDATE_LOGIN = l_terr_all_rec.LAST_UPDATE_LOGIN(i),
4969 NAME = l_terr_all_rec.NAME(i),
4970 START_DATE_ACTIVE = l_terr_all_rec.START_DATE_ACTIVE(i),
4971 END_DATE_ACTIVE = l_terr_all_rec.END_DATE_ACTIVE(i),
4972 PARENT_TERRITORY_ID = l_terr_all_rec.PARENT_TERRITORY_ID(i),
4973 TERRITORY_TYPE_ID = l_terr_all_rec.TERRITORY_TYPE_ID(i),
4974 RANK = l_terr_all_rec.RANK(i),
4975 DESCRIPTION = l_terr_all_rec.DESCRIPTION(i),
4976 ENABLED_FLAG = l_terr_all_rec.ENABLED_FLAG(i),
4977 ATTRIBUTE_CATEGORY = l_terr_all_rec.ATTRIBUTE_CATEGORY(i),
4978 ATTRIBUTE1 = l_terr_all_rec.ATTRIBUTE1(i),
4979 ATTRIBUTE2 = l_terr_all_rec.ATTRIBUTE2(i),
4980 ATTRIBUTE3 = l_terr_all_rec.ATTRIBUTE3(i),
4981 ATTRIBUTE4 = l_terr_all_rec.ATTRIBUTE4(i),
4982 ATTRIBUTE5 = l_terr_all_rec.ATTRIBUTE5(i),
4983 ATTRIBUTE6 = l_terr_all_rec.ATTRIBUTE6(i),
4984 ATTRIBUTE7 = l_terr_all_rec.ATTRIBUTE7(i),
4985 ATTRIBUTE8 = l_terr_all_rec.ATTRIBUTE8(i),
4986 ATTRIBUTE9 = l_terr_all_rec.ATTRIBUTE9(i),
4987 ATTRIBUTE10 = l_terr_all_rec.ATTRIBUTE10(i),
4988 ATTRIBUTE11 = l_terr_all_rec.ATTRIBUTE11(i),
4989 ATTRIBUTE12 = l_terr_all_rec.ATTRIBUTE12(i),
4990 ATTRIBUTE13 = l_terr_all_rec.ATTRIBUTE13(i),
4991 ATTRIBUTE14 = l_terr_all_rec.ATTRIBUTE14(i),
4992 ATTRIBUTE15 = l_terr_all_rec.ATTRIBUTE15(i),
4993 ORG_ID = l_terr_all_rec.ORG_ID(i),
4994 NUM_WINNERS = l_terr_all_rec.NUM_WINNERS(i)
4995 where terr_id = l_terr_all_rec.Terr_Id(i);
4996
4997 forall i in l_terr_all_rec.lay_seq_num.first..l_terr_all_rec.lay_seq_num.last
4998 update JTY_WEBADI_OTH_TERR_INTF
4999 set status = x_return_status
5000 , error_msg = X_Msg_Data
5001 where lay_seq_num = l_terr_all_rec.lay_seq_num(i)
5002 and interface_type = l_intf_type
5003 and header = l_header
5004 and user_sequence = p_user_sequence;
5005
5006 end if;
5007 EXCEPTION
5008 WHEN OTHERS THEN
5009 X_RETURN_STATUS := FND_API.G_RET_STS_ERROR;
5010
5011 fnd_message.clear;
5012 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_CREATE_TERR');
5013 X_Msg_Data := fnd_message.get();
5014 debugmsg (X_Msg_Data || SQLERRM);
5015
5016 update JTY_WEBADI_OTH_TERR_INTF jwot
5017 set status = x_return_status,
5018 error_msg = X_Msg_Data
5019 where jwot.USER_SEQUENCE = p_user_sequence
5020 and jwot.header = l_header
5021 and jwot.interface_type = l_intf_type
5022 and jwot.action_flag = p_action_flag
5023 and jwot.status is null;
5024
5025
5026 END UPDATE_TERR;
5027
5028 PROCEDURE UPDATE_TERR_QUAL(
5029 P_USER_SEQUENCE IN NUMBER,
5030 -- P_ACTION_FLAG IN VARCHAR2,
5031 x_return_status OUT NOCOPY VARCHAR2,
5032 x_msg_data OUT NOCOPY VARCHAR2
5033 ) IS
5034
5035 CURSOR get_qual_csr(
5036 v_user_sequence number,
5037 v_action_flag varchar2,
5038 v_intf_type varchar2,
5039 v_header varchar2) IS
5040 select JTF_TERR_QUAL_s.nextval TERR_QUAL_ID, sub.terr_id, sub.qual_value_id,
5041 sub.qual_value1, sub.qual_value2, sub.qual_value3,
5042 sub.org_id, sub.last_updated_by, sub.last_update_date,
5043 sub.last_update_login, sub.creation_date, sub.created_by,
5044 jq.qual_usg_id, jq.display_type qual_type, jq.CONVERT_TO_ID_FLAG,
5045 jq.qualifier_num, jq.html_lov_sql1,
5046 (case
5047 when jq.COMPARISON_OPERATOR = '=' then '='
5048 when (jq.COMPARISON_OPERATOR LIKE '%LIKE%') AND (instr(sub.qual_VALUE1,'_') > 0) or (instr(sub.qual_VALUE1,'%') > 0 and sub.qual_VALUE2 is null) then 'LIKE'
5049 when (jq.COMPARISON_OPERATOR LIKE '%BETWEEN%') AND (sub.qual_VALUE1 is not null and sub.qual_VALUE2 is not null) then 'BETWEEN'
5050 else '='
5051 end) qual_cond
5052 from JTY_WEBADI_QUAL_HEADER jq,
5053 (
5054 select terr_id, user_sequence,
5055 1 qual_num, QUAL1_VALUE_ID qual_value_id,
5056 QUAL1_VALUE1 qual_VALUE1,
5057 QUAL1_VALUE2 qual_VALUE2,
5058 QUAL1_VALUE3 qual_VALUE3, ORG_ID,
5059 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5060 CREATED_BY, CREATION_DATE
5061 FROM JTY_WEBADI_OTH_TERR_INTF jut
5062 where jut.USER_SEQUENCE = v_user_sequence
5063 and jut.status is null
5064 and jut.terr_qual_id1 is null
5065 and jut.qual1_value1 is not null
5066 and jut.INTERFACE_TYPE = v_intf_type
5067 AND jut.ACTION_FLAG = v_action_flag
5068 and jut.header = v_header
5069 union all
5070 select terr_id, user_sequence,
5071 2 qual_num, QUAL2_VALUE_ID qual_value_id,
5072 QUAL2_VALUE1 qual_VALUE1,
5073 QUAL2_VALUE2 qual_VALUE2,
5074 QUAL2_VALUE3 qual_VALUE3, ORG_ID,
5075 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5076 CREATED_BY, CREATION_DATE
5077 FROM JTY_WEBADI_OTH_TERR_INTF jut
5078 where jut.USER_SEQUENCE = v_user_sequence
5079 and jut.status is null
5080 and jut.terr_qual_id2 is null
5081 and jut.qual2_value1 is not null
5082 and jut.INTERFACE_TYPE = v_intf_type
5083 AND jut.ACTION_FLAG = v_action_flag
5084 and jut.header = v_header
5085 union all
5086 select terr_id, user_sequence,
5087 3 qual_num, QUAL3_VALUE_ID qual_value_id,
5088 QUAL3_VALUE1 qual_VALUE1,
5089 QUAL3_VALUE2 qual_VALUE2,
5090 QUAL3_VALUE3 qual_VALUE3, ORG_ID,
5091 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5092 CREATED_BY, CREATION_DATE
5093 FROM JTY_WEBADI_OTH_TERR_INTF jut
5094 where jut.USER_SEQUENCE = v_user_sequence
5095 and jut.status is null
5096 and jut.terr_qual_id3 is null
5097 and jut.qual3_value1 is not null
5098 and jut.INTERFACE_TYPE = v_intf_type
5099 AND jut.ACTION_FLAG = v_action_flag
5100 and jut.header = v_header
5101 union all
5102 select terr_id, user_sequence,
5103 4 qual_num, QUAL4_VALUE_ID qual_value_id,
5104 QUAL4_VALUE1 qual_VALUE1,
5105 QUAL4_VALUE2 qual_VALUE2,
5106 QUAL4_VALUE3 qual_VALUE3, ORG_ID,
5107 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5108 CREATED_BY, CREATION_DATE
5109 FROM JTY_WEBADI_OTH_TERR_INTF jut
5110 where jut.USER_SEQUENCE = v_user_sequence
5111 and jut.status is null
5112 and jut.terr_qual_id4 is null
5113 and jut.qual4_value1 is not null
5114 and jut.INTERFACE_TYPE = v_intf_type
5115 AND jut.ACTION_FLAG = v_action_flag
5116 and jut.header = v_header
5117 union all
5118 select terr_id, user_sequence,
5119 5 qual_num, QUAL5_VALUE_ID qual_value_id,
5120 QUAL5_VALUE1 qual_VALUE1,
5121 QUAL5_VALUE2 qual_VALUE2,
5122 QUAL5_VALUE3 qual_VALUE3, ORG_ID,
5123 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5124 CREATED_BY, CREATION_DATE
5125 FROM JTY_WEBADI_OTH_TERR_INTF jut
5126 where jut.USER_SEQUENCE = v_user_sequence
5127 and jut.status is null
5128 and jut.terr_qual_id5 is null
5129 and jut.qual5_value1 is not null
5130 and jut.INTERFACE_TYPE = v_intf_type
5131 AND jut.ACTION_FLAG = v_action_flag
5132 and jut.header = v_header
5133 union all
5134 select terr_id, user_sequence,
5135 6 qual_num, QUAL6_VALUE_ID qual_value_id,
5136 QUAL6_VALUE1 qual_VALUE1,
5137 QUAL6_VALUE2 qual_VALUE2,
5138 QUAL6_VALUE3 qual_VALUE3, ORG_ID,
5139 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5140 CREATED_BY, CREATION_DATE
5141 FROM JTY_WEBADI_OTH_TERR_INTF jut
5142 where jut.USER_SEQUENCE = v_user_sequence
5143 and jut.status is null
5144 and jut.terr_qual_id6 is null
5145 and jut.qual6_value1 is not null
5146 and jut.INTERFACE_TYPE = v_intf_type
5147 AND jut.ACTION_FLAG = v_action_flag
5148 and jut.header = v_header
5149 union all
5150 select terr_id, user_sequence,
5151 7 qual_num, QUAL7_VALUE_ID qual_value_id,
5152 QUAL7_VALUE1 qual_VALUE1,
5153 QUAL7_VALUE2 qual_VALUE2,
5154 QUAL7_VALUE3 qual_VALUE3, ORG_ID,
5155 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5156 CREATED_BY, CREATION_DATE
5157 FROM JTY_WEBADI_OTH_TERR_INTF jut
5158 where jut.USER_SEQUENCE = v_user_sequence
5159 and jut.status is null
5160 and jut.terr_qual_id7 is null
5161 and jut.qual7_value1 is not null
5162 and jut.INTERFACE_TYPE = v_intf_type
5163 AND jut.ACTION_FLAG = v_action_flag
5164 and jut.header = v_header
5165 union all
5166 select terr_id, user_sequence,
5167 8 qual_num, QUAL8_VALUE_ID qual_value_id,
5168 QUAL8_VALUE1 qual_VALUE1,
5169 QUAL8_VALUE2 qual_VALUE2,
5170 QUAL8_VALUE3 qual_VALUE3, ORG_ID,
5171 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5172 CREATED_BY, CREATION_DATE
5173 FROM JTY_WEBADI_OTH_TERR_INTF jut
5174 where jut.USER_SEQUENCE = v_user_sequence
5175 and jut.status is null
5176 and jut.terr_qual_id8 is null
5177 and jut.qual8_value1 is not null
5178 and jut.INTERFACE_TYPE = v_intf_type
5179 AND jut.ACTION_FLAG = v_action_flag
5180 and jut.header = v_header
5181 union all
5182 select terr_id, user_sequence,
5183 9 qual_num, QUAL9_VALUE_ID qual_value_id,
5184 QUAL9_VALUE1 qual_VALUE1,
5185 QUAL9_VALUE2 qual_VALUE2,
5186 QUAL9_VALUE3 qual_VALUE3, ORG_ID,
5187 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5188 CREATED_BY, CREATION_DATE
5189 FROM JTY_WEBADI_OTH_TERR_INTF jut
5190 where jut.USER_SEQUENCE = v_user_sequence
5191 and jut.status is null
5192 and jut.terr_qual_id9 is null
5193 and jut.qual9_value1 is not null
5194 and jut.INTERFACE_TYPE = v_intf_type
5195 AND jut.ACTION_FLAG = v_action_flag
5196 and jut.header = v_header
5197 union all
5198 select terr_id, user_sequence,
5199 10 qual_num, QUAL10_VALUE_ID qual_value_id,
5200 QUAL10_VALUE1 qual_VALUE1,
5201 QUAL10_VALUE2 qual_VALUE2,
5202 QUAL10_VALUE3 qual_VALUE3, ORG_ID,
5203 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5204 CREATED_BY, CREATION_DATE
5205 FROM JTY_WEBADI_OTH_TERR_INTF jut
5206 where jut.USER_SEQUENCE = v_user_sequence
5207 and jut.status is null
5208 and jut.terr_qual_id10 is null
5209 and jut.qual10_value1 is not null
5210 and jut.INTERFACE_TYPE = v_intf_type
5211 AND jut.ACTION_FLAG = v_action_flag
5212 and jut.header = v_header
5213 union all
5214 select terr_id, user_sequence,
5215 11 qual_num, QUAL11_VALUE_ID qual_value_id,
5216 QUAL11_VALUE1 qual_VALUE1,
5217 QUAL11_VALUE2 qual_VALUE2,
5218 QUAL11_VALUE3 qual_VALUE3, ORG_ID,
5219 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5220 CREATED_BY, CREATION_DATE
5221 FROM JTY_WEBADI_OTH_TERR_INTF jut
5222 where jut.USER_SEQUENCE = v_user_sequence
5223 and jut.status is null
5224 and jut.terr_qual_id11 is null
5225 and jut.qual11_value1 is not null
5226 and jut.INTERFACE_TYPE = v_intf_type
5227 AND jut.ACTION_FLAG = v_action_flag
5228 and jut.header = v_header
5229 union all
5230 select terr_id, user_sequence,
5231 12 qual_num, QUAL12_VALUE_ID qual_value_id,
5232 QUAL12_VALUE1 qual_VALUE1,
5233 QUAL12_VALUE2 qual_VALUE2,
5234 QUAL12_VALUE3 qual_VALUE3, ORG_ID,
5235 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5236 CREATED_BY, CREATION_DATE
5237 FROM JTY_WEBADI_OTH_TERR_INTF jut
5238 where jut.USER_SEQUENCE = v_user_sequence
5239 and jut.status is null
5240 and jut.terr_qual_id12 is null
5241 and jut.qual12_value1 is not null
5242 and jut.INTERFACE_TYPE = v_intf_type
5243 AND jut.ACTION_FLAG = v_action_flag
5244 and jut.header = v_header
5245 union all
5246 select terr_id, user_sequence,
5247 13 qual_num, QUAL13_VALUE_ID qual_value_id,
5248 QUAL13_VALUE1 qual_VALUE1,
5249 QUAL13_VALUE2 qual_VALUE2,
5250 QUAL13_VALUE3 qual_VALUE3, ORG_ID,
5251 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5252 CREATED_BY, CREATION_DATE
5253 FROM JTY_WEBADI_OTH_TERR_INTF jut
5254 where jut.USER_SEQUENCE = v_user_sequence
5255 and jut.status is null
5256 and jut.terr_qual_id13 is null
5257 and jut.qual13_value1 is not null
5258 and jut.INTERFACE_TYPE = v_intf_type
5259 AND jut.ACTION_FLAG = v_action_flag
5260 and jut.header = v_header
5261 union all
5262 select terr_id, user_sequence,
5263 14 qual_num, QUAL14_VALUE_ID qual_value_id,
5264 QUAL14_VALUE1 qual_VALUE1,
5265 QUAL14_VALUE2 qual_VALUE2,
5266 QUAL14_VALUE3 qual_VALUE3, ORG_ID,
5267 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5268 CREATED_BY, CREATION_DATE
5269 FROM JTY_WEBADI_OTH_TERR_INTF jut
5270 where jut.USER_SEQUENCE = v_user_sequence
5271 and jut.status is null
5272 and jut.terr_qual_id14 is null
5273 and jut.qual14_value1 is not null
5274 and jut.INTERFACE_TYPE = v_intf_type
5275 AND jut.ACTION_FLAG = v_action_flag
5276 and jut.header = v_header
5277 union all
5278 select terr_id, user_sequence,
5279 15 qual_num, QUAL15_VALUE_ID qual_value_id,
5280 QUAL15_VALUE1 qual_VALUE1,
5281 QUAL15_VALUE2 qual_VALUE2,
5282 QUAL15_VALUE3 qual_VALUE3, ORG_ID,
5283 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5284 CREATED_BY, CREATION_DATE
5285 FROM JTY_WEBADI_OTH_TERR_INTF jut
5286 where jut.USER_SEQUENCE = v_user_sequence
5287 and jut.status is null
5288 and jut.terr_qual_id15 is null
5289 and jut.qual15_value1 is not null
5290 and jut.INTERFACE_TYPE = v_intf_type
5291 AND jut.ACTION_FLAG = v_action_flag
5292 and jut.header = v_header
5293 union all
5294 select terr_id, user_sequence,
5295 16 qual_num, QUAL16_VALUE_ID qual_value_id,
5296 QUAL16_VALUE1 qual_VALUE1,
5297 QUAL16_VALUE2 qual_VALUE2,
5298 QUAL16_VALUE3 qual_VALUE3, ORG_ID,
5299 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5300 CREATED_BY, CREATION_DATE
5301 FROM JTY_WEBADI_OTH_TERR_INTF jut
5302 where jut.USER_SEQUENCE = v_user_sequence
5303 and jut.status is null
5304 and jut.terr_qual_id16 is null
5305 and jut.qual16_value1 is not null
5306 and jut.INTERFACE_TYPE = v_intf_type
5307 AND jut.ACTION_FLAG = v_action_flag
5308 and jut.header = v_header
5309 union all
5310 select terr_id, user_sequence,
5311 17 qual_num, QUAL17_VALUE_ID qual_value_id,
5312 QUAL17_VALUE1 qual_VALUE1,
5313 QUAL17_VALUE2 qual_VALUE2,
5314 QUAL17_VALUE3 qual_VALUE3, ORG_ID,
5315 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5316 CREATED_BY, CREATION_DATE
5317 FROM JTY_WEBADI_OTH_TERR_INTF jut
5318 where jut.USER_SEQUENCE = v_user_sequence
5319 and jut.status is null
5320 and jut.terr_qual_id17 is null
5321 and jut.qual17_value1 is not null
5322 and jut.INTERFACE_TYPE = v_intf_type
5323 AND jut.ACTION_FLAG = v_action_flag
5324 and jut.header = v_header
5325 union all
5326 select terr_id, user_sequence,
5327 18 qual_num, QUAL18_VALUE_ID qual_value_id,
5328 QUAL18_VALUE1 qual_VALUE1,
5329 QUAL18_VALUE2 qual_VALUE2,
5330 QUAL18_VALUE3 qual_VALUE3, ORG_ID,
5331 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5332 CREATED_BY, CREATION_DATE
5333 FROM JTY_WEBADI_OTH_TERR_INTF jut
5334 where jut.USER_SEQUENCE = v_user_sequence
5335 and jut.status is null
5336 and jut.terr_qual_id18 is null
5337 and jut.qual18_value1 is not null
5338 and jut.INTERFACE_TYPE = v_intf_type
5339 AND jut.ACTION_FLAG = v_action_flag
5340 and jut.header = v_header
5341 union all
5342 select terr_id, user_sequence,
5343 19 qual_num, QUAL19_VALUE_ID qual_value_id,
5344 QUAL19_VALUE1 qual_VALUE1,
5345 QUAL19_VALUE2 qual_VALUE2,
5346 QUAL19_VALUE3 qual_VALUE3, ORG_ID,
5347 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5348 CREATED_BY, CREATION_DATE
5349 FROM JTY_WEBADI_OTH_TERR_INTF jut
5350 where jut.USER_SEQUENCE = v_user_sequence
5351 and jut.status is null
5352 and jut.terr_qual_id19 is null
5353 and jut.qual19_value1 is not null
5354 and jut.INTERFACE_TYPE = v_intf_type
5355 AND jut.ACTION_FLAG = v_action_flag
5356 and jut.header = v_header
5357 union all
5358 select terr_id, user_sequence,
5359 20 qual_num, QUAL20_VALUE_ID qual_value_id,
5360 QUAL20_VALUE1 qual_VALUE1,
5361 QUAL20_VALUE2 qual_VALUE2,
5362 QUAL20_VALUE3 qual_VALUE3, ORG_ID,
5363 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5364 CREATED_BY, CREATION_DATE
5365 FROM JTY_WEBADI_OTH_TERR_INTF jut
5366 where jut.USER_SEQUENCE = v_user_sequence
5367 and jut.status is null
5368 and jut.terr_qual_id20 is null
5369 and jut.qual20_value1 is not null
5370 and jut.INTERFACE_TYPE = v_intf_type
5371 AND jut.ACTION_FLAG = v_action_flag
5372 and jut.header = v_header
5373 union all
5374 select terr_id, user_sequence,
5375 21 qual_num, QUAL21_VALUE_ID qual_value_id,
5376 QUAL21_VALUE1 qual_VALUE1,
5377 QUAL21_VALUE2 qual_VALUE2,
5378 QUAL21_VALUE3 qual_VALUE3, ORG_ID,
5379 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5380 CREATED_BY, CREATION_DATE
5381 FROM JTY_WEBADI_OTH_TERR_INTF jut
5382 where jut.USER_SEQUENCE = v_user_sequence
5383 and jut.status is null
5384 and jut.terr_qual_id21 is null
5385 and jut.qual21_value1 is not null
5386 and jut.INTERFACE_TYPE = v_intf_type
5387 AND jut.ACTION_FLAG = v_action_flag
5388 and jut.header = v_header
5389 union all
5390 select terr_id, user_sequence,
5391 22 qual_num, QUAL22_VALUE_ID qual_value_id,
5392 QUAL22_VALUE1 qual_VALUE1,
5393 QUAL22_VALUE2 qual_VALUE2,
5394 QUAL22_VALUE3 qual_VALUE3, ORG_ID,
5395 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5396 CREATED_BY, CREATION_DATE
5397 FROM JTY_WEBADI_OTH_TERR_INTF jut
5398 where jut.USER_SEQUENCE = v_user_sequence
5399 and jut.status is null
5400 and jut.terr_qual_id22 is null
5401 and jut.qual22_value1 is not null
5402 and jut.INTERFACE_TYPE = v_intf_type
5403 AND jut.ACTION_FLAG = v_action_flag
5404 and jut.header = v_header
5405 union all
5406 select terr_id, user_sequence,
5407 23 qual_num, QUAL23_VALUE_ID qual_value_id,
5408 QUAL23_VALUE1 qual_VALUE1,
5409 QUAL23_VALUE2 qual_VALUE2,
5410 QUAL23_VALUE3 qual_VALUE3, ORG_ID,
5411 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5412 CREATED_BY, CREATION_DATE
5413 FROM JTY_WEBADI_OTH_TERR_INTF jut
5414 where jut.USER_SEQUENCE = v_user_sequence
5415 and jut.status is null
5416 and jut.terr_qual_id23 is null
5417 and jut.qual23_value1 is not null
5418 and jut.INTERFACE_TYPE = v_intf_type
5419 AND jut.ACTION_FLAG = v_action_flag
5420 and jut.header = v_header
5421 union all
5422 select terr_id, user_sequence,
5423 24 qual_num, QUAL24_VALUE_ID qual_value_id,
5424 QUAL24_VALUE1 qual_VALUE1,
5425 QUAL24_VALUE2 qual_VALUE2,
5426 QUAL24_VALUE3 qual_VALUE3, ORG_ID,
5427 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5428 CREATED_BY, CREATION_DATE
5429 FROM JTY_WEBADI_OTH_TERR_INTF jut
5430 where jut.USER_SEQUENCE = v_user_sequence
5431 and jut.status is null
5432 and jut.terr_qual_id24 is null
5433 and jut.qual24_value1 is not null
5434 and jut.INTERFACE_TYPE = v_intf_type
5435 AND jut.ACTION_FLAG = v_action_flag
5436 and jut.header = v_header
5437 union all
5438 select terr_id, user_sequence,
5439 25 qual_num, QUAL25_VALUE_ID qual_value_id,
5440 QUAL25_VALUE1 qual_valUE1,
5441 QUAL25_VALUE2 qual_valUE2,
5442 QUAL25_VALUE3 qual_valUE3, ORG_ID,
5443 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5444 CREATED_BY, CREATION_DATE
5445 FROM JTY_WEBADI_OTH_TERR_INTF jut
5446 where jut.USER_SEQUENCE = v_user_sequence
5447 and jut.status is null
5448 and jut.terr_qual_id25 is null
5449 and jut.qual25_value1 is not null
5450 and jut.INTERFACE_TYPE = v_intf_type
5451 AND jut.ACTION_FLAG = v_action_flag
5452 and jut.header = v_header
5453 union all
5454 select terr_id, user_sequence,
5455 26 qual_num, QUAL26_VALUE_ID qual_value_id,
5456 QUAL26_VALUE1 qual_VALUE1,
5457 QUAL26_VALUE2 qual_VALUE2,
5458 QUAL26_VALUE3 qual_VALUE3, ORG_ID,
5459 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5460 CREATED_BY, CREATION_DATE
5461 FROM JTY_WEBADI_OTH_TERR_INTF jut
5462 where jut.USER_SEQUENCE = v_user_sequence
5463 and jut.status is null
5464 and jut.terr_qual_id26 is null
5465 and jut.qual26_value1 is not null
5466 and jut.INTERFACE_TYPE = v_intf_type
5467 AND jut.ACTION_FLAG = v_action_flag
5468 and jut.header = v_header
5469 union all
5470 select terr_id, user_sequence,
5471 27 qual_num, QUAL27_VALUE_ID qual_value_id,
5472 QUAL27_VALUE1 qual_VALUE1,
5473 QUAL27_VALUE2 qual_VALUE2,
5474 QUAL27_VALUE3 qual_VALUE3, ORG_ID,
5475 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5476 CREATED_BY, CREATION_DATE
5477 FROM JTY_WEBADI_OTH_TERR_INTF jut
5478 where jut.USER_SEQUENCE = v_user_sequence
5479 and jut.status is null
5480 and jut.terr_qual_id27 is null
5481 and jut.qual27_value1 is not null
5482 and jut.INTERFACE_TYPE = v_intf_type
5483 AND jut.ACTION_FLAG = v_action_flag
5484 and jut.header = v_header
5485 union all
5486 select terr_id, user_sequence,
5487 28 qual_num, QUAL28_VALUE_ID qual_value_id,
5488 QUAL28_VALUE1 qual_VALUE1,
5489 QUAL28_VALUE2 qual_VALUE2,
5490 QUAL28_VALUE3 qual_VALUE3, ORG_ID,
5491 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5492 CREATED_BY, CREATION_DATE
5493 FROM JTY_WEBADI_OTH_TERR_INTF jut
5494 where jut.USER_SEQUENCE = v_user_sequence
5495 and jut.status is null
5496 and jut.terr_qual_id28 is null
5497 and jut.qual28_value1 is not null
5498 and jut.INTERFACE_TYPE = v_intf_type
5499 AND jut.ACTION_FLAG = v_action_flag
5500 and jut.header = v_header
5501 union all
5502 select terr_id, user_sequence,
5503 29 qual_num, QUAL29_VALUE_ID qual_value_id,
5504 QUAL29_VALUE1 qual_VALUE1,
5505 QUAL29_VALUE2 qual_VALUE2,
5506 QUAL29_VALUE3 qual_VALUE3, ORG_ID,
5507 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5508 CREATED_BY, CREATION_DATE
5509 FROM JTY_WEBADI_OTH_TERR_INTF jut
5510 where jut.USER_SEQUENCE = v_user_sequence
5511 and jut.status is null
5512 and jut.terr_qual_id29 is null
5513 and jut.qual29_value1 is not null
5514 and jut.INTERFACE_TYPE = v_intf_type
5515 AND jut.ACTION_FLAG = v_action_flag
5516 and jut.header = v_header
5517 union all
5518 select terr_id, user_sequence,
5519 30 qual_num, QUAL30_VALUE_ID qual_value_id,
5520 QUAL30_VALUE1 qual_VALUE1,
5521 QUAL30_VALUE2 qual_VALUE2,
5522 QUAL30_VALUE3 qual_VALUE3, ORG_ID,
5523 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5524 CREATED_BY, CREATION_DATE
5525 FROM JTY_WEBADI_OTH_TERR_INTF jut
5526 where jut.USER_SEQUENCE = v_user_sequence
5527 and jut.status is null
5528 and jut.terr_qual_id30 is null
5529 and jut.QUAL30_value1 is not null
5530 and jut.INTERFACE_TYPE = v_intf_type
5531 AND jut.ACTION_FLAG = v_action_flag
5532 and jut.header = v_header
5533 union all
5534 select terr_id, user_sequence,
5535 31 qual_num, QUAL31_VALUE_ID qual_value_id,
5536 QUAL31_VALUE1 qual_VALUE1,
5537 QUAL31_VALUE2 qual_VALUE2,
5538 QUAL31_VALUE3 qual_VALUE3, ORG_ID,
5539 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5540 CREATED_BY, CREATION_DATE
5541 FROM JTY_WEBADI_OTH_TERR_INTF jut
5542 where jut.USER_SEQUENCE = v_user_sequence
5543 and jut.status is null
5544 and jut.terr_qual_id31 is null
5545 and jut.QUAL31_value1 is not null
5546 and jut.INTERFACE_TYPE = v_intf_type
5547 AND jut.ACTION_FLAG = v_action_flag
5548 and jut.header = v_header
5549 union all
5550 select terr_id, user_sequence,
5551 32 qual_num, QUAL32_VALUE_ID qual_value_id,
5552 QUAL32_VALUE1 qual_VALUE1,
5553 QUAL32_VALUE2 qual_VALUE2,
5554 QUAL32_VALUE3 qual_VALUE3, ORG_ID,
5555 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5556 CREATED_BY, CREATION_DATE
5557 FROM JTY_WEBADI_OTH_TERR_INTF jut
5558 where jut.USER_SEQUENCE = v_user_sequence
5559 and jut.status is null
5560 and jut.terr_qual_id32 is null
5561 and jut.QUAL32_value1 is not null
5562 and jut.INTERFACE_TYPE = v_intf_type
5563 AND jut.ACTION_FLAG = v_action_flag
5564 and jut.header = v_header
5565 union all
5566 select terr_id, user_sequence,
5567 33 qual_num, QUAL33_VALUE_ID qual_value_id,
5568 QUAL33_VALUE1 qual_VALUE1,
5569 QUAL33_VALUE2 qual_VALUE2,
5570 QUAL33_VALUE3 qual_VALUE3, ORG_ID,
5571 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5572 CREATED_BY, CREATION_DATE
5573 FROM JTY_WEBADI_OTH_TERR_INTF jut
5574 where jut.USER_SEQUENCE = v_user_sequence
5575 and jut.status is null
5576 and jut.terr_qual_id33 is null
5577 and jut.QUAL33_value1 is not null
5578 and jut.INTERFACE_TYPE = v_intf_type
5579 AND jut.ACTION_FLAG = v_action_flag
5580 and jut.header = v_header
5581 union all
5582 select terr_id, user_sequence,
5583 34 qual_num, QUAL34_VALUE_ID qual_value_id,
5584 QUAL34_VALUE1 qual_VALUE1,
5585 QUAL34_VALUE2 qual_VALUE2,
5586 QUAL34_VALUE3 qual_VALUE3, ORG_ID,
5587 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5588 CREATED_BY, CREATION_DATE
5589 FROM JTY_WEBADI_OTH_TERR_INTF jut
5590 where jut.USER_SEQUENCE = v_user_sequence
5591 and jut.status is null
5592 and jut.terr_qual_id34 is null
5593 and jut.QUAL34_value1 is not null
5594 and jut.INTERFACE_TYPE = v_intf_type
5595 AND jut.ACTION_FLAG = v_action_flag
5596 and jut.header = v_header
5597 union all
5598 select terr_id, user_sequence,
5599 35 qual_num, QUAL35_VALUE_ID qual_value_id,
5600 QUAL35_VALUE1 qual_valUE1,
5601 QUAL35_VALUE2 qual_valUE2,
5602 QUAL35_VALUE3 qual_valUE3, ORG_ID,
5603 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5604 CREATED_BY, CREATION_DATE
5605 FROM JTY_WEBADI_OTH_TERR_INTF jut
5606 where jut.USER_SEQUENCE = v_user_sequence
5607 and jut.status is null
5608 and jut.terr_qual_id35 is null
5609 and jut.QUAL35_value1 is not null
5610 and jut.INTERFACE_TYPE = v_intf_type
5611 AND jut.ACTION_FLAG = v_action_flag
5612 and jut.header = v_header
5613 union all
5614 select terr_id, user_sequence,
5615 36 qual_num, QUAL36_VALUE_ID qual_value_id,
5616 QUAL36_VALUE1 qual_VALUE1,
5617 QUAL36_VALUE2 qual_VALUE2,
5618 QUAL36_VALUE3 qual_VALUE3, ORG_ID,
5619 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5620 CREATED_BY, CREATION_DATE
5621 FROM JTY_WEBADI_OTH_TERR_INTF jut
5622 where jut.USER_SEQUENCE = v_user_sequence
5623 and jut.status is null
5624 and jut.terr_qual_id36 is null
5625 and jut.QUAL36_value1 is not null
5626 and jut.INTERFACE_TYPE = v_intf_type
5627 AND jut.ACTION_FLAG = v_action_flag
5628 and jut.header = v_header
5629 union all
5630 select terr_id, user_sequence,
5631 37 qual_num, QUAL37_VALUE_ID qual_value_id,
5632 QUAL37_VALUE1 qual_VALUE1,
5633 QUAL37_VALUE2 qual_VALUE2,
5634 QUAL37_VALUE3 qual_VALUE3, ORG_ID,
5635 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5636 CREATED_BY, CREATION_DATE
5637 FROM JTY_WEBADI_OTH_TERR_INTF jut
5638 where jut.USER_SEQUENCE = v_user_sequence
5639 and jut.status is null
5640 and jut.terr_qual_id37 is null
5641 and jut.QUAL37_value1 is not null
5642 and jut.INTERFACE_TYPE = v_intf_type
5643 AND jut.ACTION_FLAG = v_action_flag
5644 and jut.header = v_header
5645 union all
5646 select terr_id, user_sequence,
5647 38 qual_num, QUAL38_VALUE_ID qual_value_id,
5648 QUAL38_VALUE1 qual_VALUE1,
5649 QUAL38_VALUE2 qual_VALUE2,
5650 QUAL38_VALUE3 qual_VALUE3, ORG_ID,
5651 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5652 CREATED_BY, CREATION_DATE
5653 FROM JTY_WEBADI_OTH_TERR_INTF jut
5654 where jut.USER_SEQUENCE = v_user_sequence
5655 and jut.status is null
5656 and jut.terr_qual_id38 is null
5657 and jut.QUAL38_value1 is not null
5658 and jut.INTERFACE_TYPE = v_intf_type
5659 AND jut.ACTION_FLAG = v_action_flag
5660 and jut.header = v_header
5661 union all
5662 select terr_id, user_sequence,
5663 39 qual_num, QUAL39_VALUE_ID qual_value_id,
5664 QUAL39_VALUE1 qual_VALUE1,
5665 QUAL39_VALUE2 qual_VALUE2,
5666 QUAL39_VALUE3 qual_VALUE3, ORG_ID,
5667 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5668 CREATED_BY, CREATION_DATE
5669 FROM JTY_WEBADI_OTH_TERR_INTF jut
5670 where jut.USER_SEQUENCE = v_user_sequence
5671 and jut.status is null
5672 and jut.terr_qual_id39 is null
5673 and jut.QUAL39_value1 is not null
5674 and jut.INTERFACE_TYPE = v_intf_type
5675 AND jut.ACTION_FLAG = v_action_flag
5676 and jut.header = v_header
5677 union all
5678 select terr_id, user_sequence,
5679 40 qual_num, QUAL40_VALUE_ID qual_value_id,
5680 QUAL40_VALUE1 qual_VALUE1,
5681 QUAL40_VALUE2 qual_VALUE2,
5682 QUAL40_VALUE3 qual_VALUE3, ORG_ID,
5683 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5684 CREATED_BY, CREATION_DATE
5685 FROM JTY_WEBADI_OTH_TERR_INTF jut
5686 where jut.USER_SEQUENCE = v_user_sequence
5687 and jut.status is null
5688 and jut.terr_qual_id40 is null
5689 and jut.QUAL40_value1 is not null
5690 and jut.INTERFACE_TYPE = v_intf_type
5691 AND jut.ACTION_FLAG = v_action_flag
5692 and jut.header = v_header
5693 union all
5694 select terr_id, user_sequence,
5695 41 qual_num, QUAL41_VALUE_ID qual_value_id,
5696 QUAL41_VALUE1 qual_VALUE1,
5697 QUAL41_VALUE2 qual_VALUE2,
5698 QUAL41_VALUE3 qual_VALUE3, ORG_ID,
5699 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5700 CREATED_BY, CREATION_DATE
5701 FROM JTY_WEBADI_OTH_TERR_INTF jut
5702 where jut.USER_SEQUENCE = v_user_sequence
5703 and jut.status is null
5704 and jut.terr_qual_id41 is null
5705 and jut.QUAL41_value1 is not null
5706 and jut.INTERFACE_TYPE = v_intf_type
5707 AND jut.ACTION_FLAG = v_action_flag
5708 and jut.header = v_header
5709 union all
5710 select terr_id, user_sequence,
5711 42 qual_num, QUAL42_VALUE_ID qual_value_id,
5712 QUAL42_VALUE1 qual_VALUE1,
5713 QUAL42_VALUE2 qual_VALUE2,
5714 QUAL42_VALUE3 qual_VALUE3, ORG_ID,
5715 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5716 CREATED_BY, CREATION_DATE
5717 FROM JTY_WEBADI_OTH_TERR_INTF jut
5718 where jut.USER_SEQUENCE = v_user_sequence
5719 and jut.status is null
5720 and jut.terr_qual_id42 is null
5721 and jut.QUAL42_value1 is not null
5722 and jut.INTERFACE_TYPE = v_intf_type
5723 AND jut.ACTION_FLAG = v_action_flag
5724 and jut.header = v_header
5725 union all
5726 select terr_id, user_sequence,
5727 43 qual_num, QUAL43_VALUE_ID qual_value_id,
5728 QUAL43_VALUE1 qual_VALUE1,
5729 QUAL43_VALUE2 qual_VALUE2,
5730 QUAL43_VALUE3 qual_VALUE3, ORG_ID,
5731 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5732 CREATED_BY, CREATION_DATE
5733 FROM JTY_WEBADI_OTH_TERR_INTF jut
5734 where jut.USER_SEQUENCE = v_user_sequence
5735 and jut.status is null
5736 and jut.terr_qual_id43 is null
5737 and jut.QUAL43_value1 is not null
5738 and jut.INTERFACE_TYPE = v_intf_type
5739 AND jut.ACTION_FLAG = v_action_flag
5740 and jut.header = v_header
5741 union all
5742 select terr_id, user_sequence,
5743 44 qual_num, QUAL44_VALUE_ID qual_value_id,
5744 QUAL44_VALUE1 qual_VALUE1,
5745 QUAL44_VALUE2 qual_VALUE2,
5746 QUAL44_VALUE3 qual_VALUE3, ORG_ID,
5747 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5748 CREATED_BY, CREATION_DATE
5749 FROM JTY_WEBADI_OTH_TERR_INTF jut
5750 where jut.USER_SEQUENCE = v_user_sequence
5751 and jut.status is null
5752 and jut.terr_qual_id44 is null
5753 and jut.QUAL44_value1 is not null
5754 and jut.INTERFACE_TYPE = v_intf_type
5755 AND jut.ACTION_FLAG = v_action_flag
5756 and jut.header = v_header
5757 union all
5758 select terr_id, user_sequence,
5759 45 qual_num, QUAL45_VALUE_ID qual_value_id,
5760 QUAL45_VALUE1 qual_valUE1,
5761 QUAL45_VALUE2 qual_valUE2,
5762 QUAL45_VALUE3 qual_valUE3, ORG_ID,
5763 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5764 CREATED_BY, CREATION_DATE
5765 FROM JTY_WEBADI_OTH_TERR_INTF jut
5766 where jut.USER_SEQUENCE = v_user_sequence
5767 and jut.status is null
5768 and jut.terr_qual_id45 is null
5769 and jut.QUAL45_value1 is not null
5770 and jut.INTERFACE_TYPE = v_intf_type
5771 AND jut.ACTION_FLAG = v_action_flag
5772 and jut.header = v_header
5773 union all
5774 select terr_id, user_sequence,
5775 46 qual_num, QUAL46_VALUE_ID qual_value_id,
5776 QUAL46_VALUE1 qual_VALUE1,
5777 QUAL46_VALUE2 qual_VALUE2,
5778 QUAL46_VALUE3 qual_VALUE3, ORG_ID,
5779 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5780 CREATED_BY, CREATION_DATE
5781 FROM JTY_WEBADI_OTH_TERR_INTF jut
5782 where jut.USER_SEQUENCE = v_user_sequence
5783 and jut.status is null
5784 and jut.terr_qual_id46 is null
5785 and jut.QUAL46_value1 is not null
5786 and jut.INTERFACE_TYPE = v_intf_type
5787 AND jut.ACTION_FLAG = v_action_flag
5788 and jut.header = v_header
5789 union all
5790 select terr_id, user_sequence,
5791 47 qual_num, QUAL47_VALUE_ID qual_value_id,
5792 QUAL47_VALUE1 qual_VALUE1,
5793 QUAL47_VALUE2 qual_VALUE2,
5794 QUAL47_VALUE3 qual_VALUE3, ORG_ID,
5795 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5796 CREATED_BY, CREATION_DATE
5797 FROM JTY_WEBADI_OTH_TERR_INTF jut
5798 where jut.USER_SEQUENCE = v_user_sequence
5799 and jut.status is null
5800 and jut.terr_qual_id47 is null
5801 and jut.QUAL47_value1 is not null
5802 and jut.INTERFACE_TYPE = v_intf_type
5803 AND jut.ACTION_FLAG = v_action_flag
5804 and jut.header = v_header
5805 union all
5806 select terr_id, user_sequence,
5807 48 qual_num, QUAL48_VALUE_ID qual_value_id,
5808 QUAL48_VALUE1 qual_VALUE1,
5809 QUAL48_VALUE2 qual_VALUE2,
5810 QUAL48_VALUE3 qual_VALUE3, ORG_ID,
5811 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5812 CREATED_BY, CREATION_DATE
5813 FROM JTY_WEBADI_OTH_TERR_INTF jut
5814 where jut.USER_SEQUENCE = v_user_sequence
5815 and jut.status is null
5816 and jut.terr_qual_id48 is null
5817 and jut.QUAL48_value1 is not null
5818 and jut.INTERFACE_TYPE = v_intf_type
5819 AND jut.ACTION_FLAG = v_action_flag
5820 and jut.header = v_header
5821 union all
5822 select terr_id, user_sequence,
5823 49 qual_num, QUAL49_VALUE_ID qual_value_id,
5824 QUAL49_VALUE1 qual_VALUE1,
5825 QUAL49_VALUE2 qual_VALUE2,
5826 QUAL49_VALUE3 qual_VALUE3, ORG_ID,
5827 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5828 CREATED_BY, CREATION_DATE
5829 FROM JTY_WEBADI_OTH_TERR_INTF jut
5830 where jut.USER_SEQUENCE = v_user_sequence
5831 and jut.status is null
5832 and jut.terr_qual_id49 is null
5833 and jut.QUAL49_value1 is not null
5834 and jut.INTERFACE_TYPE = v_intf_type
5835 AND jut.ACTION_FLAG = v_action_flag
5836 and jut.header = v_header
5837 union all
5838 select terr_id, user_sequence,
5839 50 qual_num, QUAL50_VALUE_ID qual_value_id,
5840 QUAL50_VALUE1 qual_VALUE1,
5841 QUAL50_VALUE2 qual_VALUE2,
5842 QUAL50_VALUE3 qual_VALUE3, ORG_ID,
5843 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5844 CREATED_BY, CREATION_DATE
5845 FROM JTY_WEBADI_OTH_TERR_INTF jut
5846 where jut.USER_SEQUENCE = v_user_sequence
5847 and jut.status is null
5848 and jut.terr_qual_id50 is null
5849 and jut.QUAL50_value1 is not null
5850 and jut.INTERFACE_TYPE = v_intf_type
5851 AND jut.ACTION_FLAG = v_action_flag
5852 and jut.header = v_header
5853 union all
5854 select terr_id, user_sequence,
5855 51 qual_num, QUAL51_VALUE_ID qual_value_id,
5856 QUAL51_VALUE1 qual_VALUE1,
5857 QUAL51_VALUE2 qual_VALUE2,
5858 QUAL51_VALUE3 qual_VALUE3, ORG_ID,
5859 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5860 CREATED_BY, CREATION_DATE
5861 FROM JTY_WEBADI_OTH_TERR_INTF jut
5862 where jut.USER_SEQUENCE = v_user_sequence
5863 and jut.status is null
5864 and jut.terr_qual_id51 is null
5865 and jut.QUAL51_value1 is not null
5866 and jut.INTERFACE_TYPE = v_intf_type
5867 AND jut.ACTION_FLAG = v_action_flag
5868 and jut.header = v_header
5869 union all
5870 select terr_id, user_sequence,
5871 52 qual_num, QUAL52_VALUE_ID qual_value_id,
5872 QUAL52_VALUE1 qual_VALUE1,
5873 QUAL52_VALUE2 qual_VALUE2,
5874 QUAL52_VALUE3 qual_VALUE3, ORG_ID,
5875 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5876 CREATED_BY, CREATION_DATE
5877 FROM JTY_WEBADI_OTH_TERR_INTF jut
5878 where jut.USER_SEQUENCE = v_user_sequence
5879 and jut.status is null
5880 and jut.terr_qual_id52 is null
5881 and jut.QUAL52_value1 is not null
5882 and jut.INTERFACE_TYPE = v_intf_type
5883 AND jut.ACTION_FLAG = v_action_flag
5884 and jut.header = v_header
5885 union all
5886 select terr_id, user_sequence,
5887 53 qual_num, QUAL53_VALUE_ID qual_value_id,
5888 QUAL53_VALUE1 qual_VALUE1,
5889 QUAL53_VALUE2 qual_VALUE2,
5890 QUAL53_VALUE3 qual_VALUE3, ORG_ID,
5891 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5892 CREATED_BY, CREATION_DATE
5893 FROM JTY_WEBADI_OTH_TERR_INTF jut
5894 where jut.USER_SEQUENCE = v_user_sequence
5895 and jut.status is null
5896 and jut.terr_qual_id53 is null
5897 and jut.QUAL53_value1 is not null
5898 and jut.INTERFACE_TYPE = v_intf_type
5899 AND jut.ACTION_FLAG = v_action_flag
5900 and jut.header = v_header
5901 union all
5902 select terr_id, user_sequence,
5903 54 qual_num, QUAL54_VALUE_ID qual_value_id,
5904 QUAL54_VALUE1 qual_VALUE1,
5905 QUAL54_VALUE2 qual_VALUE2,
5906 QUAL54_VALUE3 qual_VALUE3, ORG_ID,
5907 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5908 CREATED_BY, CREATION_DATE
5909 FROM JTY_WEBADI_OTH_TERR_INTF jut
5910 where jut.USER_SEQUENCE = v_user_sequence
5911 and jut.status is null
5912 and jut.terr_qual_id54 is null
5913 and jut.QUAL54_value1 is not null
5914 and jut.INTERFACE_TYPE = v_intf_type
5915 AND jut.ACTION_FLAG = v_action_flag
5916 and jut.header = v_header
5917 union all
5918 select terr_id, user_sequence,
5919 55 qual_num, QUAL55_VALUE_ID qual_value_id,
5920 QUAL55_VALUE1 qual_valUE1,
5921 QUAL55_VALUE2 qual_valUE2,
5922 QUAL55_VALUE3 qual_valUE3, ORG_ID,
5923 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5924 CREATED_BY, CREATION_DATE
5925 FROM JTY_WEBADI_OTH_TERR_INTF jut
5926 where jut.USER_SEQUENCE = v_user_sequence
5927 and jut.status is null
5928 and jut.terr_qual_id55 is null
5929 and jut.QUAL55_value1 is not null
5930 and jut.INTERFACE_TYPE = v_intf_type
5931 AND jut.ACTION_FLAG = v_action_flag
5932 and jut.header = v_header
5933 union all
5934 select terr_id, user_sequence,
5935 56 qual_num, QUAL56_VALUE_ID qual_value_id,
5936 QUAL56_VALUE1 qual_VALUE1,
5937 QUAL56_VALUE2 qual_VALUE2,
5938 QUAL56_VALUE3 qual_VALUE3, ORG_ID,
5939 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5940 CREATED_BY, CREATION_DATE
5941 FROM JTY_WEBADI_OTH_TERR_INTF jut
5942 where jut.USER_SEQUENCE = v_user_sequence
5943 and jut.status is null
5944 and jut.terr_qual_id56 is null
5945 and jut.QUAL56_value1 is not null
5946 and jut.INTERFACE_TYPE = v_intf_type
5947 AND jut.ACTION_FLAG = v_action_flag
5948 and jut.header = v_header
5949 union all
5950 select terr_id, user_sequence,
5951 57 qual_num, QUAL57_VALUE_ID qual_value_id,
5952 QUAL57_VALUE1 qual_VALUE1,
5953 QUAL57_VALUE2 qual_VALUE2,
5954 QUAL57_VALUE3 qual_VALUE3, ORG_ID,
5955 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5956 CREATED_BY, CREATION_DATE
5957 FROM JTY_WEBADI_OTH_TERR_INTF jut
5958 where jut.USER_SEQUENCE = v_user_sequence
5959 and jut.status is null
5960 and jut.terr_qual_id57 is null
5961 and jut.QUAL57_value1 is not null
5962 and jut.INTERFACE_TYPE = v_intf_type
5963 AND jut.ACTION_FLAG = v_action_flag
5964 and jut.header = v_header
5965 union all
5966 select terr_id, user_sequence,
5967 58 qual_num, QUAL58_VALUE_ID qual_value_id,
5968 QUAL58_VALUE1 qual_VALUE1,
5969 QUAL58_VALUE2 qual_VALUE2,
5970 QUAL58_VALUE3 qual_VALUE3, ORG_ID,
5971 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5972 CREATED_BY, CREATION_DATE
5973 FROM JTY_WEBADI_OTH_TERR_INTF jut
5974 where jut.USER_SEQUENCE = v_user_sequence
5975 and jut.status is null
5976 and jut.terr_qual_id58 is null
5977 and jut.QUAL58_value1 is not null
5978 and jut.INTERFACE_TYPE = v_intf_type
5979 AND jut.ACTION_FLAG = v_action_flag
5980 and jut.header = v_header
5981 union all
5982 select terr_id, user_sequence,
5983 59 qual_num, QUAL59_VALUE_ID qual_value_id,
5984 QUAL59_VALUE1 qual_VALUE1,
5985 QUAL59_VALUE2 qual_VALUE2,
5986 QUAL59_VALUE3 qual_VALUE3, ORG_ID,
5987 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
5988 CREATED_BY, CREATION_DATE
5989 FROM JTY_WEBADI_OTH_TERR_INTF jut
5990 where jut.USER_SEQUENCE = v_user_sequence
5991 and jut.status is null
5992 and jut.terr_qual_id59 is null
5993 and jut.QUAL59_value1 is not null
5994 and jut.INTERFACE_TYPE = v_intf_type
5995 AND jut.ACTION_FLAG = v_action_flag
5996 and jut.header = v_header
5997 union all
5998 select terr_id, user_sequence,
5999 60 qual_num, QUAL60_VALUE_ID qual_value_id,
6000 QUAL60_VALUE1 qual_VALUE1,
6001 QUAL60_VALUE2 qual_VALUE2,
6002 QUAL60_VALUE3 qual_VALUE3, ORG_ID,
6003 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6004 CREATED_BY, CREATION_DATE
6005 FROM JTY_WEBADI_OTH_TERR_INTF jut
6006 where jut.USER_SEQUENCE = v_user_sequence
6007 and jut.status is null
6008 and jut.terr_qual_id60 is null
6009 and jut.QUAL60_value1 is not null
6010 and jut.INTERFACE_TYPE = v_intf_type
6011 AND jut.ACTION_FLAG = v_action_flag
6012 and jut.header = v_header
6013 union all
6014 select terr_id, user_sequence,
6015 61 qual_num, QUAL61_VALUE_ID qual_value_id,
6016 QUAL61_VALUE1 qual_VALUE1,
6017 QUAL61_VALUE2 qual_VALUE2,
6018 QUAL61_VALUE3 qual_VALUE3, ORG_ID,
6019 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6020 CREATED_BY, CREATION_DATE
6021 FROM JTY_WEBADI_OTH_TERR_INTF jut
6022 where jut.USER_SEQUENCE = v_user_sequence
6023 and jut.status is null
6024 and jut.terr_qual_id61 is null
6025 and jut.QUAL61_value1 is not null
6026 and jut.INTERFACE_TYPE = v_intf_type
6027 AND jut.ACTION_FLAG = v_action_flag
6028 and jut.header = v_header
6029 union all
6030 select terr_id, user_sequence,
6031 62 qual_num, QUAL62_VALUE_ID qual_value_id,
6032 QUAL62_VALUE1 qual_VALUE1,
6033 QUAL62_VALUE2 qual_VALUE2,
6034 QUAL62_VALUE3 qual_VALUE3, ORG_ID,
6035 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6036 CREATED_BY, CREATION_DATE
6037 FROM JTY_WEBADI_OTH_TERR_INTF jut
6038 where jut.USER_SEQUENCE = v_user_sequence
6039 and jut.status is null
6040 and jut.terr_qual_id62 is null
6041 and jut.QUAL62_value1 is not null
6042 and jut.INTERFACE_TYPE = v_intf_type
6043 AND jut.ACTION_FLAG = v_action_flag
6044 and jut.header = v_header
6045 union all
6046 select terr_id, user_sequence,
6047 63 qual_num, QUAL63_VALUE_ID qual_value_id,
6048 QUAL63_VALUE1 qual_VALUE1,
6049 QUAL63_VALUE2 qual_VALUE2,
6050 QUAL63_VALUE3 qual_VALUE3, ORG_ID,
6051 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6052 CREATED_BY, CREATION_DATE
6053 FROM JTY_WEBADI_OTH_TERR_INTF jut
6054 where jut.USER_SEQUENCE = v_user_sequence
6055 and jut.status is null
6056 and jut.terr_qual_id63 is null
6057 and jut.QUAL63_value1 is not null
6058 and jut.INTERFACE_TYPE = v_intf_type
6059 AND jut.ACTION_FLAG = v_action_flag
6060 and jut.header = v_header
6061 union all
6062 select terr_id, user_sequence,
6063 64 qual_num, QUAL64_VALUE_ID qual_value_id,
6064 QUAL64_VALUE1 qual_VALUE1,
6065 QUAL64_VALUE2 qual_VALUE2,
6066 QUAL64_VALUE3 qual_VALUE3, ORG_ID,
6067 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6068 CREATED_BY, CREATION_DATE
6069 FROM JTY_WEBADI_OTH_TERR_INTF jut
6070 where jut.USER_SEQUENCE = v_user_sequence
6071 and jut.status is null
6072 and jut.terr_qual_id64 is null
6073 and jut.QUAL64_value1 is not null
6074 and jut.INTERFACE_TYPE = v_intf_type
6075 AND jut.ACTION_FLAG = v_action_flag
6076 and jut.header = v_header
6077 union all
6078 select terr_id, user_sequence,
6079 65 qual_num, QUAL65_VALUE_ID qual_value_id,
6080 QUAL65_VALUE1 qual_valUE1,
6081 QUAL65_VALUE2 qual_valUE2,
6082 QUAL65_VALUE3 qual_valUE3, ORG_ID,
6083 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6084 CREATED_BY, CREATION_DATE
6085 FROM JTY_WEBADI_OTH_TERR_INTF jut
6086 where jut.USER_SEQUENCE = v_user_sequence
6087 and jut.status is null
6088 and jut.terr_qual_id65 is null
6089 and jut.QUAL65_value1 is not null
6090 and jut.INTERFACE_TYPE = v_intf_type
6091 AND jut.ACTION_FLAG = v_action_flag
6092 and jut.header = v_header
6093 union all
6094 select terr_id, user_sequence,
6095 66 qual_num, QUAL66_VALUE_ID qual_value_id,
6096 QUAL66_VALUE1 qual_VALUE1,
6097 QUAL66_VALUE2 qual_VALUE2,
6098 QUAL66_VALUE3 qual_VALUE3, ORG_ID,
6099 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6100 CREATED_BY, CREATION_DATE
6101 FROM JTY_WEBADI_OTH_TERR_INTF jut
6102 where jut.USER_SEQUENCE = v_user_sequence
6103 and jut.status is null
6104 and jut.terr_qual_id66 is null
6105 and jut.QUAL66_value1 is not null
6106 and jut.INTERFACE_TYPE = v_intf_type
6107 AND jut.ACTION_FLAG = v_action_flag
6108 and jut.header = v_header
6109 union all
6110 select terr_id, user_sequence,
6111 67 qual_num, QUAL67_VALUE_ID qual_value_id,
6112 QUAL67_VALUE1 qual_VALUE1,
6113 QUAL67_VALUE2 qual_VALUE2,
6114 QUAL67_VALUE3 qual_VALUE3, ORG_ID,
6115 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6116 CREATED_BY, CREATION_DATE
6117 FROM JTY_WEBADI_OTH_TERR_INTF jut
6118 where jut.USER_SEQUENCE = v_user_sequence
6119 and jut.status is null
6120 and jut.terr_qual_id67 is null
6121 and jut.QUAL67_value1 is not null
6122 and jut.INTERFACE_TYPE = v_intf_type
6123 AND jut.ACTION_FLAG = v_action_flag
6124 and jut.header = v_header
6125 union all
6126 select terr_id, user_sequence,
6127 68 qual_num, QUAL68_VALUE_ID qual_value_id,
6128 QUAL68_VALUE1 qual_VALUE1,
6129 QUAL68_VALUE2 qual_VALUE2,
6130 QUAL68_VALUE3 qual_VALUE3, ORG_ID,
6131 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6132 CREATED_BY, CREATION_DATE
6133 FROM JTY_WEBADI_OTH_TERR_INTF jut
6134 where jut.USER_SEQUENCE = v_user_sequence
6135 and jut.status is null
6136 and jut.terr_qual_id68 is null
6137 and jut.QUAL68_value1 is not null
6138 and jut.INTERFACE_TYPE = v_intf_type
6139 AND jut.ACTION_FLAG = v_action_flag
6140 and jut.header = v_header
6141 union all
6142 select terr_id, user_sequence,
6143 69 qual_num, QUAL69_VALUE_ID qual_value_id,
6144 QUAL69_VALUE1 qual_VALUE1,
6145 QUAL69_VALUE2 qual_VALUE2,
6146 QUAL69_VALUE3 qual_VALUE3, ORG_ID,
6147 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6148 CREATED_BY, CREATION_DATE
6149 FROM JTY_WEBADI_OTH_TERR_INTF jut
6150 where jut.USER_SEQUENCE = v_user_sequence
6151 and jut.status is null
6152 and jut.terr_qual_id69 is null
6153 and jut.QUAL69_value1 is not null
6154 and jut.INTERFACE_TYPE = v_intf_type
6155 AND jut.ACTION_FLAG = v_action_flag
6156 and jut.header = v_header
6157 union all
6158 select terr_id, user_sequence,
6159 70 qual_num, QUAL70_VALUE_ID qual_value_id,
6160 QUAL70_VALUE1 qual_VALUE1,
6161 QUAL70_VALUE2 qual_VALUE2,
6162 QUAL70_VALUE3 qual_VALUE3, ORG_ID,
6163 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6164 CREATED_BY, CREATION_DATE
6165 FROM JTY_WEBADI_OTH_TERR_INTF jut
6166 where jut.USER_SEQUENCE = v_user_sequence
6167 and jut.status is null
6168 and jut.terr_qual_id70 is null
6169 and jut.QUAL70_value1 is not null
6170 and jut.INTERFACE_TYPE = v_intf_type
6171 AND jut.ACTION_FLAG = v_action_flag
6172 and jut.header = v_header
6173 union all
6174 select terr_id, user_sequence,
6175 71 qual_num, QUAL71_VALUE_ID qual_value_id,
6176 QUAL71_VALUE1 qual_VALUE1,
6177 QUAL71_VALUE2 qual_VALUE2,
6178 QUAL71_VALUE3 qual_VALUE3, ORG_ID,
6179 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6180 CREATED_BY, CREATION_DATE
6181 FROM JTY_WEBADI_OTH_TERR_INTF jut
6182 where jut.USER_SEQUENCE = v_user_sequence
6183 and jut.status is null
6184 and jut.terr_qual_id71 is null
6185 and jut.QUAL71_value1 is not null
6186 and jut.INTERFACE_TYPE = v_intf_type
6187 AND jut.ACTION_FLAG = v_action_flag
6188 and jut.header = v_header
6189 union all
6190 select terr_id, user_sequence,
6191 72 qual_num, QUAL72_VALUE_ID qual_value_id,
6192 QUAL72_VALUE1 qual_VALUE1,
6193 QUAL72_VALUE2 qual_VALUE2,
6194 QUAL72_VALUE3 qual_VALUE3, ORG_ID,
6195 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6196 CREATED_BY, CREATION_DATE
6197 FROM JTY_WEBADI_OTH_TERR_INTF jut
6198 where jut.USER_SEQUENCE = v_user_sequence
6199 and jut.status is null
6200 and jut.terr_qual_id72 is null
6201 and jut.QUAL72_value1 is not null
6202 and jut.INTERFACE_TYPE = v_intf_type
6203 AND jut.ACTION_FLAG = v_action_flag
6204 and jut.header = v_header
6205 union all
6206 select terr_id, user_sequence,
6207 73 qual_num, QUAL73_VALUE_ID qual_value_id,
6208 QUAL73_VALUE1 qual_VALUE1,
6209 QUAL73_VALUE2 qual_VALUE2,
6210 QUAL73_VALUE3 qual_VALUE3, ORG_ID,
6211 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6212 CREATED_BY, CREATION_DATE
6213 FROM JTY_WEBADI_OTH_TERR_INTF jut
6214 where jut.USER_SEQUENCE = v_user_sequence
6215 and jut.status is null
6216 and jut.terr_qual_id73 is null
6217 and jut.QUAL73_value1 is not null
6218 and jut.INTERFACE_TYPE = v_intf_type
6219 AND jut.ACTION_FLAG = v_action_flag
6220 and jut.header = v_header
6221 union all
6222 select terr_id, user_sequence,
6223 74 qual_num, QUAL74_VALUE_ID qual_value_id,
6224 QUAL74_VALUE1 qual_VALUE1,
6225 QUAL74_VALUE2 qual_VALUE2,
6226 QUAL74_VALUE3 qual_VALUE3, ORG_ID,
6227 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6228 CREATED_BY, CREATION_DATE
6229 FROM JTY_WEBADI_OTH_TERR_INTF jut
6230 where jut.USER_SEQUENCE = v_user_sequence
6231 and jut.status is null
6232 and jut.terr_qual_id74 is null
6233 and jut.QUAL74_value1 is not null
6234 and jut.INTERFACE_TYPE = v_intf_type
6235 AND jut.ACTION_FLAG = v_action_flag
6236 and jut.header = v_header
6237 union all
6238 select terr_id, user_sequence,
6239 75 qual_num, QUAL75_VALUE_ID qual_value_id,
6240 QUAL75_VALUE1 qual_valUE1,
6241 QUAL75_VALUE2 qual_valUE2,
6242 QUAL75_VALUE3 qual_valUE3, ORG_ID,
6243 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6244 CREATED_BY, CREATION_DATE
6245 FROM JTY_WEBADI_OTH_TERR_INTF jut
6246 where jut.USER_SEQUENCE = v_user_sequence
6247 and jut.status is null
6248 and jut.terr_qual_id75 is null
6249 and jut.QUAL75_value1 is not null
6250 and jut.INTERFACE_TYPE = v_intf_type
6251 AND jut.ACTION_FLAG = v_action_flag
6252 and jut.header = v_header
6253 ) sub
6254 where jq.user_sequence = sub.user_sequence
6255 and jq.qualifier_num = sub.qual_num
6256 ;
6257
6258 CURSOR get_c_terr_value_csr(
6259 v_user_sequence number,
6260 v_intf_type varchar2,
6261 v_header varchar2) IS
6262 select sub.TERR_QUAL_ID, sub.terr_id, sub.qual_value_id,
6263 sub.qual_value1, sub.qual_value2, sub.qual_value3,
6264 sub.org_id, sub.last_updated_by, sub.last_update_date,
6265 sub.last_update_login, sub.creation_date, sub.created_by,
6266 jq.qual_usg_id, jq.display_type qual_type, jq.CONVERT_TO_ID_FLAG,
6267 jq.qualifier_num, jq.html_lov_sql1,
6268 (case
6269 when jq.COMPARISON_OPERATOR = '=' then '='
6270 when (jq.COMPARISON_OPERATOR LIKE '%LIKE%') AND (instr(sub.qual_VALUE1,'_') > 0) or (instr(sub.qual_VALUE1,'%') > 0 and sub.qual_VALUE2 is null) then 'LIKE'
6271 when (jq.COMPARISON_OPERATOR LIKE '%BETWEEN%') AND (sub.qual_VALUE1 is not null and sub.qual_VALUE2 is not null) then 'BETWEEN'
6272 else '='
6273 end) qual_cond
6274 from JTY_WEBADI_QUAL_HEADER jq,
6275 (
6276 select terr_id, user_sequence,
6277 terr_qual_id1 terr_qual_id,
6278 1 qual_num, QUAL1_VALUE_ID qual_value_id,
6279 QUAL1_VALUE1 qual_VALUE1,
6280 QUAL1_VALUE2 qual_VALUE2,
6281 QUAL1_VALUE3 qual_VALUE3, ORG_ID,
6282 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6283 CREATED_BY, CREATION_DATE
6284 FROM JTY_WEBADI_OTH_TERR_INTF jut
6285 where jut.USER_SEQUENCE = v_user_sequence
6286 and jut.status is null
6287 and jut.terr_qual_id1 is not null
6288 and jut.QUAL1_VALUE_ID is null
6289 and jut.qual1_value1 is not null
6290 and jut.INTERFACE_TYPE = v_intf_type
6291 and jut.header = v_header
6292 union all
6293 select terr_id, user_sequence,
6294 terr_qual_id2 terr_qual_id,
6295 2 qual_num, QUAL2_VALUE_ID qual_value_id,
6296 QUAL2_VALUE1 qual_VALUE1,
6297 QUAL2_VALUE2 qual_VALUE2,
6298 QUAL2_VALUE3 qual_VALUE3, ORG_ID,
6299 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6300 CREATED_BY, CREATION_DATE
6301 FROM JTY_WEBADI_OTH_TERR_INTF jut
6302 where jut.USER_SEQUENCE = v_user_sequence
6303 and jut.status is null
6304 and jut.terr_qual_id2 is not null
6305 and jut.QUAL2_VALUE_ID is null
6306 and jut.qual2_value1 is not null
6307 and jut.INTERFACE_TYPE = v_intf_type
6308 and jut.header = v_header
6309 union all
6310 select terr_id, user_sequence,
6311 terr_qual_id3 terr_qual_id,
6312 3 qual_num, QUAL3_VALUE_ID qual_value_id,
6313 QUAL3_VALUE1 qual_VALUE1,
6314 QUAL3_VALUE2 qual_VALUE2,
6315 QUAL3_VALUE3 qual_VALUE3, ORG_ID,
6316 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6317 CREATED_BY, CREATION_DATE
6318 FROM JTY_WEBADI_OTH_TERR_INTF jut
6319 where jut.USER_SEQUENCE = v_user_sequence
6320 and jut.status is null
6321 and jut.terr_qual_id3 is not null
6322 and jut.QUAL3_VALUE_ID is null
6323 and jut.qual3_value1 is not null
6324 and jut.INTERFACE_TYPE = v_intf_type
6325 and jut.header = v_header
6326 union all
6327 select terr_id, user_sequence,
6328 terr_qual_id4 terr_qual_id,
6329 4 qual_num, QUAL4_VALUE_ID qual_value_id,
6330 QUAL4_VALUE1 qual_VALUE1,
6331 QUAL4_VALUE2 qual_VALUE2,
6332 QUAL4_VALUE3 qual_VALUE3, ORG_ID,
6333 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6334 CREATED_BY, CREATION_DATE
6335 FROM JTY_WEBADI_OTH_TERR_INTF jut
6336 where jut.USER_SEQUENCE = v_user_sequence
6337 and jut.status is null
6338 and jut.terr_qual_id4 is not null
6339 and jut.QUAL4_VALUE_ID is null
6340 and jut.qual4_value1 is not null
6341 and jut.INTERFACE_TYPE = v_intf_type
6342 and jut.header = v_header
6343 union all
6344 select terr_id, user_sequence,
6345 terr_qual_id5 terr_qual_id,
6346 5 qual_num, QUAL5_VALUE_ID qual_value_id,
6347 QUAL5_VALUE1 qual_VALUE1,
6348 QUAL5_VALUE2 qual_VALUE2,
6349 QUAL5_VALUE3 qual_VALUE3, ORG_ID,
6350 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6351 CREATED_BY, CREATION_DATE
6352 FROM JTY_WEBADI_OTH_TERR_INTF jut
6353 where jut.USER_SEQUENCE = v_user_sequence
6354 and jut.status is null
6355 and jut.terr_qual_id5 is not null
6356 and jut.QUAL5_VALUE_ID is null
6357 and jut.qual5_value1 is not null
6358 and jut.INTERFACE_TYPE = v_intf_type
6359 and jut.header = v_header
6360 union all
6361 select terr_id, user_sequence,
6362 terr_qual_id6 terr_qual_id,
6363 6 qual_num, QUAL6_VALUE_ID qual_value_id,
6364 QUAL6_VALUE1 qual_VALUE1,
6365 QUAL6_VALUE2 qual_VALUE2,
6366 QUAL6_VALUE3 qual_VALUE3, ORG_ID,
6367 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6368 CREATED_BY, CREATION_DATE
6369 FROM JTY_WEBADI_OTH_TERR_INTF jut
6370 where jut.USER_SEQUENCE = v_user_sequence
6371 and jut.status is null
6372 and jut.terr_qual_id6 is not null
6373 and jut.QUAL6_VALUE_ID is null
6374 and jut.qual6_value1 is not null
6375 and jut.INTERFACE_TYPE = v_intf_type
6376 and jut.header = v_header
6377 union all
6378 select terr_id, user_sequence,
6379 terr_qual_id7 terr_qual_id,
6380 7 qual_num, QUAL7_VALUE_ID qual_value_id,
6381 QUAL7_VALUE1 qual_VALUE1,
6382 QUAL7_VALUE2 qual_VALUE2,
6383 QUAL7_VALUE3 qual_VALUE3, ORG_ID,
6384 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6385 CREATED_BY, CREATION_DATE
6386 FROM JTY_WEBADI_OTH_TERR_INTF jut
6387 where jut.USER_SEQUENCE = v_user_sequence
6388 and jut.status is null
6389 and jut.terr_qual_id7 is not null
6390 and jut.QUAL7_VALUE_ID is null
6391 and jut.qual7_value1 is not null
6392 and jut.INTERFACE_TYPE = v_intf_type
6393 and jut.header = v_header
6394 union all
6395 select terr_id, user_sequence,
6396 terr_qual_id8 terr_qual_id,
6397 8 qual_num, QUAL8_VALUE_ID qual_value_id,
6398 QUAL8_VALUE1 qual_VALUE1,
6399 QUAL8_VALUE2 qual_VALUE2,
6400 QUAL8_VALUE3 qual_VALUE3, ORG_ID,
6401 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6402 CREATED_BY, CREATION_DATE
6403 FROM JTY_WEBADI_OTH_TERR_INTF jut
6404 where jut.USER_SEQUENCE = v_user_sequence
6405 and jut.status is null
6406 and jut.terr_qual_id8 is not null
6407 and jut.QUAL8_VALUE_ID is null
6408 and jut.qual8_value1 is not null
6409 and jut.INTERFACE_TYPE = v_intf_type
6410 and jut.header = v_header
6411 union all
6412 select terr_id, user_sequence,
6413 terr_qual_id9 terr_qual_id,
6414 9 qual_num, QUAL9_VALUE_ID qual_value_id,
6415 QUAL9_VALUE1 qual_VALUE1,
6416 QUAL9_VALUE2 qual_VALUE2,
6417 QUAL9_VALUE3 qual_VALUE3, ORG_ID,
6418 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6419 CREATED_BY, CREATION_DATE
6420 FROM JTY_WEBADI_OTH_TERR_INTF jut
6421 where jut.USER_SEQUENCE = v_user_sequence
6422 and jut.status is null
6423 and jut.terr_qual_id9 is not null
6424 and jut.QUAL9_VALUE_ID is null
6425 and jut.qual9_value1 is not null
6426 and jut.INTERFACE_TYPE = v_intf_type
6427 and jut.header = v_header
6428 union all
6429 select terr_id, user_sequence,
6430 terr_qual_id10 terr_qual_id,
6431 10 qual_num, QUAL10_VALUE_ID qual_value_id,
6432 QUAL10_VALUE1 qual_VALUE1,
6433 QUAL10_VALUE2 qual_VALUE2,
6434 QUAL10_VALUE3 qual_VALUE3, ORG_ID,
6435 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6436 CREATED_BY, CREATION_DATE
6437 FROM JTY_WEBADI_OTH_TERR_INTF jut
6438 where jut.USER_SEQUENCE = v_user_sequence
6439 and jut.status is null
6440 and jut.terr_qual_id10 is not null
6441 and jut.QUAL10_VALUE_ID is null
6442 and jut.qual10_value1 is not null
6443 and jut.INTERFACE_TYPE = v_intf_type
6444 and jut.header = v_header
6445 union all
6446 select terr_id, user_sequence,
6447 terr_qual_id11 terr_qual_id,
6448 11 qual_num, QUAL11_VALUE_ID qual_value_id,
6449 QUAL11_VALUE1 qual_VALUE1,
6450 QUAL11_VALUE2 qual_VALUE2,
6451 QUAL11_VALUE3 qual_VALUE3, ORG_ID,
6452 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6453 CREATED_BY, CREATION_DATE
6454 FROM JTY_WEBADI_OTH_TERR_INTF jut
6455 where jut.USER_SEQUENCE = v_user_sequence
6456 and jut.status is null
6457 and jut.terr_qual_id11 is not null
6458 and jut.QUAL11_VALUE_ID is null
6459 and jut.qual11_value1 is not null
6460 and jut.INTERFACE_TYPE = v_intf_type
6461 and jut.header = v_header
6462 union all
6463 select terr_id, user_sequence,
6464 terr_qual_id12 terr_qual_id,
6465 12 qual_num, QUAL12_VALUE_ID qual_value_id,
6466 QUAL12_VALUE1 qual_VALUE1,
6467 QUAL12_VALUE2 qual_VALUE2,
6468 QUAL12_VALUE3 qual_VALUE3, ORG_ID,
6469 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6470 CREATED_BY, CREATION_DATE
6471 FROM JTY_WEBADI_OTH_TERR_INTF jut
6472 where jut.USER_SEQUENCE = v_user_sequence
6473 and jut.status is null
6474 and jut.terr_qual_id12 is not null
6475 and jut.QUAL12_VALUE_ID is null
6476 and jut.qual12_value1 is not null
6477 and jut.INTERFACE_TYPE = v_intf_type
6478 and jut.header = v_header
6479 union all
6480 select terr_id, user_sequence,
6481 terr_qual_id13 terr_qual_id,
6482 13 qual_num, QUAL13_VALUE_ID qual_value_id,
6483 QUAL13_VALUE1 qual_VALUE1,
6484 QUAL13_VALUE2 qual_VALUE2,
6485 QUAL13_VALUE3 qual_VALUE3, ORG_ID,
6486 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6487 CREATED_BY, CREATION_DATE
6488 FROM JTY_WEBADI_OTH_TERR_INTF jut
6489 where jut.USER_SEQUENCE = v_user_sequence
6490 and jut.status is null
6491 and jut.terr_qual_id13 is not null
6492 and jut.QUAL13_VALUE_ID is null
6493 and jut.qual13_value1 is not null
6494 and jut.INTERFACE_TYPE = v_intf_type
6495 and jut.header = v_header
6496 union all
6497 select terr_id, user_sequence,
6498 terr_qual_id14 terr_qual_id,
6499 14 qual_num, QUAL14_VALUE_ID qual_value_id,
6500 QUAL14_VALUE1 qual_VALUE1,
6501 QUAL14_VALUE2 qual_VALUE2,
6502 QUAL14_VALUE3 qual_VALUE3, ORG_ID,
6503 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6504 CREATED_BY, CREATION_DATE
6505 FROM JTY_WEBADI_OTH_TERR_INTF jut
6506 where jut.USER_SEQUENCE = v_user_sequence
6507 and jut.status is null
6508 and jut.terr_qual_id14 is not null
6509 and jut.QUAL14_VALUE_ID is null
6510 and jut.qual14_value1 is not null
6511 and jut.INTERFACE_TYPE = v_intf_type
6512 and jut.header = v_header
6513 union all
6514 select terr_id, user_sequence,
6515 terr_qual_id15 terr_qual_id,
6516 15 qual_num, QUAL15_VALUE_ID qual_value_id,
6517 QUAL15_VALUE1 qual_VALUE1,
6518 QUAL15_VALUE2 qual_VALUE2,
6519 QUAL15_VALUE3 qual_VALUE3, ORG_ID,
6520 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6521 CREATED_BY, CREATION_DATE
6522 FROM JTY_WEBADI_OTH_TERR_INTF jut
6523 where jut.USER_SEQUENCE = v_user_sequence
6524 and jut.status is null
6525 and jut.terr_qual_id15 is not null
6526 and jut.QUAL15_VALUE_ID is null
6527 and jut.qual15_value1 is not null
6528 and jut.INTERFACE_TYPE = v_intf_type
6529 and jut.header = v_header
6530 union all
6531 select terr_id, user_sequence,
6532 terr_qual_id16 terr_qual_id,
6533 16 qual_num, QUAL16_VALUE_ID qual_value_id,
6534 QUAL16_VALUE1 qual_VALUE1,
6535 QUAL16_VALUE2 qual_VALUE2,
6536 QUAL16_VALUE3 qual_VALUE3, ORG_ID,
6537 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6538 CREATED_BY, CREATION_DATE
6539 FROM JTY_WEBADI_OTH_TERR_INTF jut
6540 where jut.USER_SEQUENCE = v_user_sequence
6541 and jut.status is null
6542 and jut.terr_qual_id16 is not null
6543 and jut.QUAL16_VALUE_ID is null
6544 and jut.qual16_value1 is not null
6545 and jut.INTERFACE_TYPE = v_intf_type
6546 and jut.header = v_header
6547 union all
6548 select terr_id, user_sequence,
6549 terr_qual_id17 terr_qual_id,
6550 17 qual_num, QUAL17_VALUE_ID qual_value_id,
6551 QUAL17_VALUE1 qual_VALUE1,
6552 QUAL17_VALUE2 qual_VALUE2,
6553 QUAL17_VALUE3 qual_VALUE3, ORG_ID,
6554 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6555 CREATED_BY, CREATION_DATE
6556 FROM JTY_WEBADI_OTH_TERR_INTF jut
6557 where jut.USER_SEQUENCE = v_user_sequence
6558 and jut.status is null
6559 and jut.terr_qual_id17 is not null
6560 and jut.QUAL17_VALUE_ID is null
6561 and jut.qual17_value1 is not null
6562 and jut.INTERFACE_TYPE = v_intf_type
6563 and jut.header = v_header
6564 union all
6565 select terr_id, user_sequence,
6566 terr_qual_id18 terr_qual_id,
6567 18 qual_num, QUAL18_VALUE_ID qual_value_id,
6568 QUAL18_VALUE1 qual_VALUE1,
6569 QUAL18_VALUE2 qual_VALUE2,
6570 QUAL18_VALUE3 qual_VALUE3, ORG_ID,
6571 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6572 CREATED_BY, CREATION_DATE
6573 FROM JTY_WEBADI_OTH_TERR_INTF jut
6574 where jut.USER_SEQUENCE = v_user_sequence
6575 and jut.status is null
6576 and jut.terr_qual_id18 is not null
6577 and jut.QUAL18_VALUE_ID is null
6578 and jut.qual18_value1 is not null
6579 and jut.INTERFACE_TYPE = v_intf_type
6580 and jut.header = v_header
6581 union all
6582 select terr_id, user_sequence,
6583 terr_qual_id19 terr_qual_id,
6584 19 qual_num, QUAL19_VALUE_ID qual_value_id,
6585 QUAL19_VALUE1 qual_VALUE1,
6586 QUAL19_VALUE2 qual_VALUE2,
6587 QUAL19_VALUE3 qual_VALUE3, ORG_ID,
6588 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6589 CREATED_BY, CREATION_DATE
6590 FROM JTY_WEBADI_OTH_TERR_INTF jut
6591 where jut.USER_SEQUENCE = v_user_sequence
6592 and jut.status is null
6593 and jut.terr_qual_id19 is not null
6594 and jut.QUAL19_VALUE_ID is null
6595 and jut.qual19_value1 is not null
6596 and jut.INTERFACE_TYPE = v_intf_type
6597 and jut.header = v_header
6598 union all
6599 select terr_id, user_sequence,
6600 terr_qual_id20 terr_qual_id,
6601 20 qual_num, QUAL20_VALUE_ID qual_value_id,
6602 QUAL20_VALUE1 qual_VALUE1,
6603 QUAL20_VALUE2 qual_VALUE2,
6604 QUAL20_VALUE3 qual_VALUE3, ORG_ID,
6605 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6606 CREATED_BY, CREATION_DATE
6607 FROM JTY_WEBADI_OTH_TERR_INTF jut
6608 where jut.USER_SEQUENCE = v_user_sequence
6609 and jut.status is null
6610 and jut.terr_qual_id20 is not null
6611 and jut.QUAL20_VALUE_ID is null
6612 and jut.qual20_value1 is not null
6613 and jut.INTERFACE_TYPE = v_intf_type
6614 and jut.header = v_header
6615 union all
6616 select terr_id, user_sequence,
6617 terr_qual_id21 terr_qual_id,
6618 21 qual_num, QUAL21_VALUE_ID qual_value_id,
6619 QUAL21_VALUE1 qual_VALUE1,
6620 QUAL21_VALUE2 qual_VALUE2,
6621 QUAL21_VALUE3 qual_VALUE3, ORG_ID,
6622 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6623 CREATED_BY, CREATION_DATE
6624 FROM JTY_WEBADI_OTH_TERR_INTF jut
6625 where jut.USER_SEQUENCE = v_user_sequence
6626 and jut.status is null
6627 and jut.terr_qual_id21 is not null
6628 and jut.QUAL21_VALUE_ID is null
6629 and jut.qual21_value1 is not null
6630 and jut.INTERFACE_TYPE = v_intf_type
6631 and jut.header = v_header
6632 union all
6633 select terr_id, user_sequence,
6634 terr_qual_id22 terr_qual_id,
6635 22 qual_num, QUAL22_VALUE_ID qual_value_id,
6636 QUAL22_VALUE1 qual_VALUE1,
6637 QUAL22_VALUE2 qual_VALUE2,
6638 QUAL22_VALUE3 qual_VALUE3, ORG_ID,
6639 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6640 CREATED_BY, CREATION_DATE
6641 FROM JTY_WEBADI_OTH_TERR_INTF jut
6642 where jut.USER_SEQUENCE = v_user_sequence
6643 and jut.status is null
6644 and jut.terr_qual_id22 is not null
6645 and jut.QUAL22_VALUE_ID is null
6646 and jut.qual22_value1 is not null
6647 and jut.INTERFACE_TYPE = v_intf_type
6648 and jut.header = v_header
6649 union all
6650 select terr_id, user_sequence,
6651 terr_qual_id23 terr_qual_id,
6652 23 qual_num, QUAL23_VALUE_ID qual_value_id,
6653 QUAL23_VALUE1 qual_VALUE1,
6654 QUAL23_VALUE2 qual_VALUE2,
6655 QUAL23_VALUE3 qual_VALUE3, ORG_ID,
6656 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6657 CREATED_BY, CREATION_DATE
6658 FROM JTY_WEBADI_OTH_TERR_INTF jut
6659 where jut.USER_SEQUENCE = v_user_sequence
6660 and jut.status is null
6661 and jut.terr_qual_id23 is not null
6662 and jut.QUAL23_VALUE_ID is null
6663 and jut.qual23_value1 is not null
6664 and jut.INTERFACE_TYPE = v_intf_type
6665 and jut.header = v_header
6666 union all
6667 select terr_id, user_sequence,
6668 terr_qual_id24 terr_qual_id,
6669 24 qual_num, QUAL24_VALUE_ID qual_value_id,
6670 QUAL24_VALUE1 qual_VALUE1,
6671 QUAL24_VALUE2 qual_VALUE2,
6672 QUAL24_VALUE3 qual_VALUE3, ORG_ID,
6673 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6674 CREATED_BY, CREATION_DATE
6675 FROM JTY_WEBADI_OTH_TERR_INTF jut
6676 where jut.USER_SEQUENCE = v_user_sequence
6677 and jut.status is null
6678 and jut.terr_qual_id24 is not null
6679 and jut.QUAL24_VALUE_ID is null
6680 and jut.qual24_value1 is not null
6681 and jut.INTERFACE_TYPE = v_intf_type
6682 and jut.header = v_header
6683 union all
6684 select terr_id, user_sequence,
6685 terr_qual_id25 terr_qual_id,
6686 25 qual_num, QUAL25_VALUE_ID qual_value_id,
6687 QUAL25_VALUE1 qual_valUE1,
6688 QUAL25_VALUE2 qual_valUE2,
6689 QUAL25_VALUE3 qual_valUE3, ORG_ID,
6690 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6691 CREATED_BY, CREATION_DATE
6692 FROM JTY_WEBADI_OTH_TERR_INTF jut
6693 where jut.USER_SEQUENCE = v_user_sequence
6694 and jut.status is null
6695 and jut.terr_qual_id25 is not null
6696 and jut.QUAL25_VALUE_ID is null
6697 and jut.qual25_value1 is not null
6698 and jut.INTERFACE_TYPE = v_intf_type
6699 and jut.header = v_header
6700 union all
6701 select terr_id, user_sequence,
6702 terr_qual_id26 terr_qual_id,
6703 26 qual_num, QUAL26_VALUE_ID qual_value_id,
6704 QUAL26_VALUE1 qual_VALUE1,
6705 QUAL26_VALUE2 qual_VALUE2,
6706 QUAL26_VALUE3 qual_VALUE3, ORG_ID,
6707 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6708 CREATED_BY, CREATION_DATE
6709 FROM JTY_WEBADI_OTH_TERR_INTF jut
6710 where jut.USER_SEQUENCE = v_user_sequence
6711 and jut.status is null
6712 and jut.terr_qual_id26 is not null
6713 and jut.QUAL26_VALUE_ID is null
6714 and jut.QUAL26_value1 is not null
6715 and jut.INTERFACE_TYPE = v_intf_type
6716 and jut.header = v_header
6717 union all
6718 select terr_id, user_sequence,
6719 terr_qual_id27 terr_qual_id,
6720 27 qual_num, QUAL27_VALUE_ID qual_value_id,
6721 QUAL27_VALUE1 qual_VALUE1,
6722 QUAL27_VALUE2 qual_VALUE2,
6723 QUAL27_VALUE3 qual_VALUE3, ORG_ID,
6724 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6725 CREATED_BY, CREATION_DATE
6726 FROM JTY_WEBADI_OTH_TERR_INTF jut
6727 where jut.USER_SEQUENCE = v_user_sequence
6728 and jut.status is null
6729 and jut.terr_qual_id27 is not null
6730 and jut.QUAL27_VALUE_ID is null
6731 and jut.QUAL27_value1 is not null
6732 and jut.INTERFACE_TYPE = v_intf_type
6733 and jut.header = v_header
6734 union all
6735 select terr_id, user_sequence,
6736 terr_qual_id28 terr_qual_id,
6737 28 qual_num, QUAL28_VALUE_ID qual_value_id,
6738 QUAL28_VALUE1 qual_VALUE1,
6739 QUAL28_VALUE2 qual_VALUE2,
6740 QUAL28_VALUE3 qual_VALUE3, ORG_ID,
6741 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6742 CREATED_BY, CREATION_DATE
6743 FROM JTY_WEBADI_OTH_TERR_INTF jut
6744 where jut.USER_SEQUENCE = v_user_sequence
6745 and jut.status is null
6746 and jut.terr_qual_id28 is not null
6747 and jut.QUAL28_VALUE_ID is null
6748 and jut.QUAL28_value1 is not null
6749 and jut.INTERFACE_TYPE = v_intf_type
6750 and jut.header = v_header
6751 union all
6752 select terr_id, user_sequence,
6753 terr_qual_id29 terr_qual_id,
6754 29 qual_num, QUAL29_VALUE_ID qual_value_id,
6755 QUAL29_VALUE1 qual_VALUE1,
6756 QUAL29_VALUE2 qual_VALUE2,
6757 QUAL29_VALUE3 qual_VALUE3, ORG_ID,
6758 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6759 CREATED_BY, CREATION_DATE
6760 FROM JTY_WEBADI_OTH_TERR_INTF jut
6761 where jut.USER_SEQUENCE = v_user_sequence
6762 and jut.status is null
6763 and jut.terr_qual_id29 is not null
6764 and jut.QUAL29_VALUE_ID is null
6765 and jut.QUAL29_value1 is not null
6766 and jut.INTERFACE_TYPE = v_intf_type
6767 and jut.header = v_header
6768 union all
6769 select terr_id, user_sequence,
6770 terr_qual_id30 terr_qual_id,
6771 30 qual_num, QUAL30_VALUE_ID qual_value_id,
6772 QUAL30_VALUE1 qual_VALUE1,
6773 QUAL30_VALUE2 qual_VALUE2,
6774 QUAL30_VALUE3 qual_VALUE3, ORG_ID,
6775 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6776 CREATED_BY, CREATION_DATE
6777 FROM JTY_WEBADI_OTH_TERR_INTF jut
6778 where jut.USER_SEQUENCE = v_user_sequence
6779 and jut.status is null
6780 and jut.terr_qual_id30 is not null
6781 and jut.QUAL30_VALUE_ID is null
6782 and jut.QUAL30_value1 is not null
6783 and jut.INTERFACE_TYPE = v_intf_type
6784 and jut.header = v_header
6785 union all
6786 select terr_id, user_sequence,
6787 terr_qual_id31 terr_qual_id,
6788 31 qual_num, QUAL31_VALUE_ID qual_value_id,
6789 QUAL31_VALUE1 qual_VALUE1,
6790 QUAL31_VALUE2 qual_VALUE2,
6791 QUAL31_VALUE3 qual_VALUE3, ORG_ID,
6792 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6793 CREATED_BY, CREATION_DATE
6794 FROM JTY_WEBADI_OTH_TERR_INTF jut
6795 where jut.USER_SEQUENCE = v_user_sequence
6796 and jut.status is null
6797 and jut.terr_qual_id31 is not null
6798 and jut.QUAL31_VALUE_ID is null
6799 and jut.QUAL31_value1 is not null
6800 and jut.INTERFACE_TYPE = v_intf_type
6801 and jut.header = v_header
6802 union all
6803 select terr_id, user_sequence,
6804 terr_qual_id32 terr_qual_id,
6805 32 qual_num, QUAL32_VALUE_ID qual_value_id,
6806 QUAL32_VALUE1 qual_VALUE1,
6807 QUAL32_VALUE2 qual_VALUE2,
6808 QUAL32_VALUE3 qual_VALUE3, ORG_ID,
6809 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6810 CREATED_BY, CREATION_DATE
6811 FROM JTY_WEBADI_OTH_TERR_INTF jut
6812 where jut.USER_SEQUENCE = v_user_sequence
6813 and jut.status is null
6814 and jut.terr_qual_id32 is not null
6815 and jut.QUAL32_VALUE_ID is null
6816 and jut.QUAL32_value1 is not null
6817 and jut.INTERFACE_TYPE = v_intf_type
6818 and jut.header = v_header
6819 union all
6820 select terr_id, user_sequence,
6821 terr_qual_id33 terr_qual_id,
6822 33 qual_num, QUAL33_VALUE_ID qual_value_id,
6823 QUAL33_VALUE1 qual_VALUE1,
6824 QUAL33_VALUE2 qual_VALUE2,
6825 QUAL33_VALUE3 qual_VALUE3, ORG_ID,
6826 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6827 CREATED_BY, CREATION_DATE
6828 FROM JTY_WEBADI_OTH_TERR_INTF jut
6829 where jut.USER_SEQUENCE = v_user_sequence
6830 and jut.status is null
6831 and jut.terr_qual_id33 is not null
6832 and jut.QUAL33_VALUE_ID is null
6833 and jut.QUAL33_value1 is not null
6834 and jut.INTERFACE_TYPE = v_intf_type
6835 and jut.header = v_header
6836 union all
6837 select terr_id, user_sequence,
6838 terr_qual_id34 terr_qual_id,
6839 34 qual_num, QUAL34_VALUE_ID qual_value_id,
6840 QUAL34_VALUE1 qual_VALUE1,
6841 QUAL34_VALUE2 qual_VALUE2,
6842 QUAL34_VALUE3 qual_VALUE3, ORG_ID,
6843 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6844 CREATED_BY, CREATION_DATE
6845 FROM JTY_WEBADI_OTH_TERR_INTF jut
6846 where jut.USER_SEQUENCE = v_user_sequence
6847 and jut.status is null
6848 and jut.terr_qual_id34 is not null
6849 and jut.QUAL34_VALUE_ID is null
6850 and jut.QUAL34_value1 is not null
6851 and jut.INTERFACE_TYPE = v_intf_type
6852 and jut.header = v_header
6853 union all
6854 select terr_id, user_sequence,
6855 terr_qual_id35 terr_qual_id,
6856 35 qual_num, QUAL35_VALUE_ID qual_value_id,
6857 QUAL35_VALUE1 qual_valUE1,
6858 QUAL35_VALUE2 qual_valUE2,
6859 QUAL35_VALUE3 qual_valUE3, ORG_ID,
6860 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6861 CREATED_BY, CREATION_DATE
6862 FROM JTY_WEBADI_OTH_TERR_INTF jut
6863 where jut.USER_SEQUENCE = v_user_sequence
6864 and jut.status is null
6865 and jut.terr_qual_id35 is not null
6866 and jut.QUAL35_VALUE_ID is null
6867 and jut.QUAL35_value1 is not null
6868 and jut.INTERFACE_TYPE = v_intf_type
6869 and jut.header = v_header
6870 union all
6871 select terr_id, user_sequence,
6872 terr_qual_id36 terr_qual_id,
6873 36 qual_num, QUAL36_VALUE_ID qual_value_id,
6874 QUAL36_VALUE1 qual_VALUE1,
6875 QUAL36_VALUE2 qual_VALUE2,
6876 QUAL36_VALUE3 qual_VALUE3, ORG_ID,
6877 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6878 CREATED_BY, CREATION_DATE
6879 FROM JTY_WEBADI_OTH_TERR_INTF jut
6880 where jut.USER_SEQUENCE = v_user_sequence
6881 and jut.status is null
6882 and jut.terr_qual_id36 is not null
6883 and jut.QUAL36_VALUE_ID is null
6884 and jut.QUAL36_value1 is not null
6885 and jut.INTERFACE_TYPE = v_intf_type
6886 and jut.header = v_header
6887 union all
6888 select terr_id, user_sequence,
6889 terr_qual_id37 terr_qual_id,
6890 37 qual_num, QUAL37_VALUE_ID qual_value_id,
6891 QUAL37_VALUE1 qual_VALUE1,
6892 QUAL37_VALUE2 qual_VALUE2,
6893 QUAL37_VALUE3 qual_VALUE3, ORG_ID,
6894 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6895 CREATED_BY, CREATION_DATE
6896 FROM JTY_WEBADI_OTH_TERR_INTF jut
6897 where jut.USER_SEQUENCE = v_user_sequence
6898 and jut.status is null
6899 and jut.terr_qual_id37 is not null
6900 and jut.QUAL37_VALUE_ID is null
6901 and jut.QUAL37_value1 is not null
6902 and jut.INTERFACE_TYPE = v_intf_type
6903 and jut.header = v_header
6904 union all
6905 select terr_id, user_sequence,
6906 terr_qual_id38 terr_qual_id,
6907 38 qual_num, QUAL38_VALUE_ID qual_value_id,
6908 QUAL38_VALUE1 qual_VALUE1,
6909 QUAL38_VALUE2 qual_VALUE2,
6910 QUAL38_VALUE3 qual_VALUE3, ORG_ID,
6911 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6912 CREATED_BY, CREATION_DATE
6913 FROM JTY_WEBADI_OTH_TERR_INTF jut
6914 where jut.USER_SEQUENCE = v_user_sequence
6915 and jut.status is null
6916 and jut.terr_qual_id38 is not null
6917 and jut.QUAL38_VALUE_ID is null
6918 and jut.QUAL38_value1 is not null
6919 and jut.INTERFACE_TYPE = v_intf_type
6920 and jut.header = v_header
6921 union all
6922 select terr_id, user_sequence,
6923 terr_qual_id39 terr_qual_id,
6924 39 qual_num, QUAL39_VALUE_ID qual_value_id,
6925 QUAL39_VALUE1 qual_VALUE1,
6926 QUAL39_VALUE2 qual_VALUE2,
6927 QUAL39_VALUE3 qual_VALUE3, ORG_ID,
6928 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6929 CREATED_BY, CREATION_DATE
6930 FROM JTY_WEBADI_OTH_TERR_INTF jut
6931 where jut.USER_SEQUENCE = v_user_sequence
6932 and jut.status is null
6933 and jut.terr_qual_id39 is not null
6934 and jut.QUAL39_VALUE_ID is null
6935 and jut.QUAL39_value1 is not null
6936 and jut.INTERFACE_TYPE = v_intf_type
6937 and jut.header = v_header
6938 union all
6939 select terr_id, user_sequence,
6940 terr_qual_id40 terr_qual_id,
6941 40 qual_num, QUAL40_VALUE_ID qual_value_id,
6942 QUAL40_VALUE1 qual_VALUE1,
6943 QUAL40_VALUE2 qual_VALUE2,
6944 QUAL40_VALUE3 qual_VALUE3, ORG_ID,
6945 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6946 CREATED_BY, CREATION_DATE
6947 FROM JTY_WEBADI_OTH_TERR_INTF jut
6948 where jut.USER_SEQUENCE = v_user_sequence
6949 and jut.status is null
6950 and jut.terr_qual_id40 is not null
6951 and jut.QUAL40_VALUE_ID is null
6952 and jut.QUAL40_value1 is not null
6953 and jut.INTERFACE_TYPE = v_intf_type
6954 and jut.header = v_header
6955 union all
6956 select terr_id, user_sequence,
6957 terr_qual_id41 terr_qual_id,
6958 41 qual_num, QUAL41_VALUE_ID qual_value_id,
6959 QUAL41_VALUE1 qual_VALUE1,
6960 QUAL41_VALUE2 qual_VALUE2,
6961 QUAL41_VALUE3 qual_VALUE3, ORG_ID,
6962 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6963 CREATED_BY, CREATION_DATE
6964 FROM JTY_WEBADI_OTH_TERR_INTF jut
6965 where jut.USER_SEQUENCE = v_user_sequence
6966 and jut.status is null
6967 and jut.terr_qual_id41 is not null
6968 and jut.QUAL41_VALUE_ID is null
6969 and jut.QUAL41_value1 is not null
6970 and jut.INTERFACE_TYPE = v_intf_type
6971 and jut.header = v_header
6972 union all
6973 select terr_id, user_sequence,
6974 terr_qual_id42 terr_qual_id,
6975 42 qual_num, QUAL42_VALUE_ID qual_value_id,
6976 QUAL42_VALUE1 qual_VALUE1,
6977 QUAL42_VALUE2 qual_VALUE2,
6978 QUAL42_VALUE3 qual_VALUE3, ORG_ID,
6979 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6980 CREATED_BY, CREATION_DATE
6981 FROM JTY_WEBADI_OTH_TERR_INTF jut
6982 where jut.USER_SEQUENCE = v_user_sequence
6983 and jut.status is null
6984 and jut.terr_qual_id42 is not null
6985 and jut.QUAL42_VALUE_ID is null
6986 and jut.QUAL42_value1 is not null
6987 and jut.INTERFACE_TYPE = v_intf_type
6988 and jut.header = v_header
6989 union all
6990 select terr_id, user_sequence,
6991 terr_qual_id43 terr_qual_id,
6992 43 qual_num, QUAL43_VALUE_ID qual_value_id,
6993 QUAL43_VALUE1 qual_VALUE1,
6994 QUAL43_VALUE2 qual_VALUE2,
6995 QUAL43_VALUE3 qual_VALUE3, ORG_ID,
6996 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
6997 CREATED_BY, CREATION_DATE
6998 FROM JTY_WEBADI_OTH_TERR_INTF jut
6999 where jut.USER_SEQUENCE = v_user_sequence
7000 and jut.status is null
7001 and jut.terr_qual_id43 is not null
7002 and jut.QUAL43_VALUE_ID is null
7003 and jut.QUAL43_value1 is not null
7004 and jut.INTERFACE_TYPE = v_intf_type
7005 and jut.header = v_header
7006 union all
7007 select terr_id, user_sequence,
7008 terr_qual_id44 terr_qual_id,
7009 44 qual_num, QUAL44_VALUE_ID qual_value_id,
7010 QUAL44_VALUE1 qual_VALUE1,
7011 QUAL44_VALUE2 qual_VALUE2,
7012 QUAL44_VALUE3 qual_VALUE3, ORG_ID,
7013 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7014 CREATED_BY, CREATION_DATE
7015 FROM JTY_WEBADI_OTH_TERR_INTF jut
7016 where jut.USER_SEQUENCE = v_user_sequence
7017 and jut.status is null
7018 and jut.terr_qual_id44 is not null
7019 and jut.QUAL44_VALUE_ID is null
7020 and jut.QUAL44_value1 is not null
7021 and jut.INTERFACE_TYPE = v_intf_type
7022 and jut.header = v_header
7023 union all
7024 select terr_id, user_sequence,
7025 terr_qual_id45 terr_qual_id,
7026 45 qual_num, QUAL45_VALUE_ID qual_value_id,
7027 QUAL45_VALUE1 qual_valUE1,
7028 QUAL45_VALUE2 qual_valUE2,
7029 QUAL45_VALUE3 qual_valUE3, ORG_ID,
7030 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7031 CREATED_BY, CREATION_DATE
7032 FROM JTY_WEBADI_OTH_TERR_INTF jut
7033 where jut.USER_SEQUENCE = v_user_sequence
7034 and jut.status is null
7035 and jut.terr_qual_id45 is not null
7036 and jut.QUAL45_VALUE_ID is null
7037 and jut.QUAL45_value1 is not null
7038 and jut.INTERFACE_TYPE = v_intf_type
7039 and jut.header = v_header
7040 union all
7041 select terr_id, user_sequence,
7042 terr_qual_id46 terr_qual_id,
7043 46 qual_num, QUAL46_VALUE_ID qual_value_id,
7044 QUAL46_VALUE1 qual_VALUE1,
7045 QUAL46_VALUE2 qual_VALUE2,
7046 QUAL46_VALUE3 qual_VALUE3, ORG_ID,
7047 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7048 CREATED_BY, CREATION_DATE
7049 FROM JTY_WEBADI_OTH_TERR_INTF jut
7050 where jut.USER_SEQUENCE = v_user_sequence
7051 and jut.status is null
7052 and jut.terr_qual_id46 is not null
7053 and jut.QUAL46_VALUE_ID is null
7054 and jut.QUAL46_value1 is not null
7055 and jut.INTERFACE_TYPE = v_intf_type
7056 and jut.header = v_header
7057 union all
7058 select terr_id, user_sequence,
7059 terr_qual_id47 terr_qual_id,
7060 47 qual_num, QUAL47_VALUE_ID qual_value_id,
7061 QUAL47_VALUE1 qual_VALUE1,
7062 QUAL47_VALUE2 qual_VALUE2,
7063 QUAL47_VALUE3 qual_VALUE3, ORG_ID,
7064 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7065 CREATED_BY, CREATION_DATE
7066 FROM JTY_WEBADI_OTH_TERR_INTF jut
7067 where jut.USER_SEQUENCE = v_user_sequence
7068 and jut.status is null
7069 and jut.terr_qual_id47 is not null
7070 and jut.QUAL47_VALUE_ID is null
7071 and jut.QUAL47_value1 is not null
7072 and jut.INTERFACE_TYPE = v_intf_type
7073 and jut.header = v_header
7074 union all
7075 select terr_id, user_sequence,
7076 terr_qual_id48 terr_qual_id,
7077 48 qual_num, QUAL48_VALUE_ID qual_value_id,
7078 QUAL48_VALUE1 qual_VALUE1,
7079 QUAL48_VALUE2 qual_VALUE2,
7080 QUAL48_VALUE3 qual_VALUE3, ORG_ID,
7081 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7082 CREATED_BY, CREATION_DATE
7083 FROM JTY_WEBADI_OTH_TERR_INTF jut
7084 where jut.USER_SEQUENCE = v_user_sequence
7085 and jut.status is null
7086 and jut.terr_qual_id48 is not null
7087 and jut.QUAL48_VALUE_ID is null
7088 and jut.QUAL48_value1 is not null
7089 and jut.INTERFACE_TYPE = v_intf_type
7090 and jut.header = v_header
7091 union all
7092 select terr_id, user_sequence,
7093 terr_qual_id49 terr_qual_id,
7094 49 qual_num, QUAL49_VALUE_ID qual_value_id,
7095 QUAL49_VALUE1 qual_VALUE1,
7096 QUAL49_VALUE2 qual_VALUE2,
7097 QUAL49_VALUE3 qual_VALUE3, ORG_ID,
7098 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7099 CREATED_BY, CREATION_DATE
7100 FROM JTY_WEBADI_OTH_TERR_INTF jut
7101 where jut.USER_SEQUENCE = v_user_sequence
7102 and jut.status is null
7103 and jut.terr_qual_id49 is not null
7104 and jut.QUAL49_VALUE_ID is null
7105 and jut.QUAL49_value1 is not null
7106 and jut.INTERFACE_TYPE = v_intf_type
7107 and jut.header = v_header
7108 union all
7109 select terr_id, user_sequence,
7110 terr_qual_id50 terr_qual_id,
7111 50 qual_num, QUAL50_VALUE_ID qual_value_id,
7112 QUAL50_VALUE1 qual_VALUE1,
7113 QUAL50_VALUE2 qual_VALUE2,
7114 QUAL50_VALUE3 qual_VALUE3, ORG_ID,
7115 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7116 CREATED_BY, CREATION_DATE
7117 FROM JTY_WEBADI_OTH_TERR_INTF jut
7118 where jut.USER_SEQUENCE = v_user_sequence
7119 and jut.status is null
7120 and jut.terr_qual_id50 is not null
7121 and jut.QUAL50_VALUE_ID is null
7122 and jut.QUAL50_value1 is not null
7123 and jut.INTERFACE_TYPE = v_intf_type
7124 and jut.header = v_header
7125 union all
7126 select terr_id, user_sequence,
7127 terr_qual_id51 terr_qual_id,
7128 51 qual_num, QUAL51_VALUE_ID qual_value_id,
7129 QUAL51_VALUE1 qual_VALUE1,
7130 QUAL51_VALUE2 qual_VALUE2,
7131 QUAL51_VALUE3 qual_VALUE3, ORG_ID,
7132 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7133 CREATED_BY, CREATION_DATE
7134 FROM JTY_WEBADI_OTH_TERR_INTF jut
7135 where jut.USER_SEQUENCE = v_user_sequence
7136 and jut.status is null
7137 and jut.terr_qual_id51 is not null
7138 and jut.QUAL51_VALUE_ID is null
7139 and jut.QUAL51_value1 is not null
7140 and jut.INTERFACE_TYPE = v_intf_type
7141 and jut.header = v_header
7142 union all
7143 select terr_id, user_sequence,
7144 terr_qual_id52 terr_qual_id,
7145 52 qual_num, QUAL52_VALUE_ID qual_value_id,
7146 QUAL52_VALUE1 qual_VALUE1,
7147 QUAL52_VALUE2 qual_VALUE2,
7148 QUAL52_VALUE3 qual_VALUE3, ORG_ID,
7149 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7150 CREATED_BY, CREATION_DATE
7151 FROM JTY_WEBADI_OTH_TERR_INTF jut
7152 where jut.USER_SEQUENCE = v_user_sequence
7153 and jut.status is null
7154 and jut.terr_qual_id52 is not null
7155 and jut.QUAL52_VALUE_ID is null
7156 and jut.QUAL52_value1 is not null
7157 and jut.INTERFACE_TYPE = v_intf_type
7158 and jut.header = v_header
7159 union all
7160 select terr_id, user_sequence,
7161 terr_qual_id53 terr_qual_id,
7162 53 qual_num, QUAL53_VALUE_ID qual_value_id,
7163 QUAL53_VALUE1 qual_VALUE1,
7164 QUAL53_VALUE2 qual_VALUE2,
7165 QUAL53_VALUE3 qual_VALUE3, ORG_ID,
7166 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7167 CREATED_BY, CREATION_DATE
7168 FROM JTY_WEBADI_OTH_TERR_INTF jut
7169 where jut.USER_SEQUENCE = v_user_sequence
7170 and jut.status is null
7171 and jut.terr_qual_id53 is not null
7172 and jut.QUAL53_VALUE_ID is null
7173 and jut.QUAL53_value1 is not null
7174 and jut.INTERFACE_TYPE = v_intf_type
7175 and jut.header = v_header
7176 union all
7177 select terr_id, user_sequence,
7178 terr_qual_id54 terr_qual_id,
7179 54 qual_num, QUAL54_VALUE_ID qual_value_id,
7180 QUAL54_VALUE1 qual_VALUE1,
7181 QUAL54_VALUE2 qual_VALUE2,
7182 QUAL54_VALUE3 qual_VALUE3, ORG_ID,
7183 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7184 CREATED_BY, CREATION_DATE
7185 FROM JTY_WEBADI_OTH_TERR_INTF jut
7186 where jut.USER_SEQUENCE = v_user_sequence
7187 and jut.status is null
7188 and jut.terr_qual_id54 is not null
7189 and jut.QUAL54_VALUE_ID is null
7190 and jut.QUAL54_value1 is not null
7191 and jut.INTERFACE_TYPE = v_intf_type
7192 and jut.header = v_header
7193 union all
7194 select terr_id, user_sequence,
7195 terr_qual_id55 terr_qual_id,
7196 55 qual_num, QUAL55_VALUE_ID qual_value_id,
7197 QUAL55_VALUE1 qual_valUE1,
7198 QUAL55_VALUE2 qual_valUE2,
7199 QUAL55_VALUE3 qual_valUE3, ORG_ID,
7200 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7201 CREATED_BY, CREATION_DATE
7202 FROM JTY_WEBADI_OTH_TERR_INTF jut
7203 where jut.USER_SEQUENCE = v_user_sequence
7204 and jut.status is null
7205 and jut.terr_qual_id55 is not null
7206 and jut.QUAL55_VALUE_ID is null
7207 and jut.QUAL55_value1 is not null
7208 and jut.INTERFACE_TYPE = v_intf_type
7209 and jut.header = v_header
7210 union all
7211 select terr_id, user_sequence,
7212 terr_qual_id56 terr_qual_id,
7213 56 qual_num, QUAL56_VALUE_ID qual_value_id,
7214 QUAL56_VALUE1 qual_VALUE1,
7215 QUAL56_VALUE2 qual_VALUE2,
7216 QUAL56_VALUE3 qual_VALUE3, ORG_ID,
7217 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7218 CREATED_BY, CREATION_DATE
7219 FROM JTY_WEBADI_OTH_TERR_INTF jut
7220 where jut.USER_SEQUENCE = v_user_sequence
7221 and jut.status is null
7222 and jut.terr_qual_id56 is not null
7223 and jut.QUAL56_VALUE_ID is null
7224 and jut.QUAL56_value1 is not null
7225 and jut.INTERFACE_TYPE = v_intf_type
7226 and jut.header = v_header
7227 union all
7228 select terr_id, user_sequence,
7229 terr_qual_id57 terr_qual_id,
7230 57 qual_num, QUAL57_VALUE_ID qual_value_id,
7231 QUAL57_VALUE1 qual_VALUE1,
7232 QUAL57_VALUE2 qual_VALUE2,
7233 QUAL57_VALUE3 qual_VALUE3, ORG_ID,
7234 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7235 CREATED_BY, CREATION_DATE
7236 FROM JTY_WEBADI_OTH_TERR_INTF jut
7237 where jut.USER_SEQUENCE = v_user_sequence
7238 and jut.status is null
7239 and jut.terr_qual_id57 is not null
7240 and jut.QUAL57_VALUE_ID is null
7241 and jut.QUAL57_value1 is not null
7242 and jut.INTERFACE_TYPE = v_intf_type
7243 and jut.header = v_header
7244 union all
7245 select terr_id, user_sequence,
7246 terr_qual_id58 terr_qual_id,
7247 58 qual_num, QUAL58_VALUE_ID qual_value_id,
7248 QUAL58_VALUE1 qual_VALUE1,
7249 QUAL58_VALUE2 qual_VALUE2,
7250 QUAL58_VALUE3 qual_VALUE3, ORG_ID,
7251 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7252 CREATED_BY, CREATION_DATE
7253 FROM JTY_WEBADI_OTH_TERR_INTF jut
7254 where jut.USER_SEQUENCE = v_user_sequence
7255 and jut.status is null
7256 and jut.terr_qual_id58 is not null
7257 and jut.QUAL58_VALUE_ID is null
7258 and jut.QUAL58_value1 is not null
7259 and jut.INTERFACE_TYPE = v_intf_type
7260 and jut.header = v_header
7261 union all
7262 select terr_id, user_sequence,
7263 terr_qual_id59 terr_qual_id,
7264 59 qual_num, QUAL59_VALUE_ID qual_value_id,
7265 QUAL59_VALUE1 qual_VALUE1,
7266 QUAL59_VALUE2 qual_VALUE2,
7267 QUAL59_VALUE3 qual_VALUE3, ORG_ID,
7268 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7269 CREATED_BY, CREATION_DATE
7270 FROM JTY_WEBADI_OTH_TERR_INTF jut
7271 where jut.USER_SEQUENCE = v_user_sequence
7272 and jut.status is null
7273 and jut.terr_qual_id59 is not null
7274 and jut.QUAL59_VALUE_ID is null
7275 and jut.QUAL59_value1 is not null
7276 and jut.INTERFACE_TYPE = v_intf_type
7277 and jut.header = v_header
7278 union all
7279 select terr_id, user_sequence,
7280 terr_qual_id60 terr_qual_id,
7281 60 qual_num, QUAL60_VALUE_ID qual_value_id,
7282 QUAL60_VALUE1 qual_VALUE1,
7283 QUAL60_VALUE2 qual_VALUE2,
7284 QUAL60_VALUE3 qual_VALUE3, ORG_ID,
7285 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7286 CREATED_BY, CREATION_DATE
7287 FROM JTY_WEBADI_OTH_TERR_INTF jut
7288 where jut.USER_SEQUENCE = v_user_sequence
7289 and jut.status is null
7290 and jut.terr_qual_id60 is not null
7291 and jut.QUAL60_VALUE_ID is null
7292 and jut.QUAL60_value1 is not null
7293 and jut.INTERFACE_TYPE = v_intf_type
7294 and jut.header = v_header
7295 union all
7296 select terr_id, user_sequence,
7297 terr_qual_id61 terr_qual_id,
7298 61 qual_num, QUAL61_VALUE_ID qual_value_id,
7299 QUAL61_VALUE1 qual_VALUE1,
7300 QUAL61_VALUE2 qual_VALUE2,
7301 QUAL61_VALUE3 qual_VALUE3, ORG_ID,
7302 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7303 CREATED_BY, CREATION_DATE
7304 FROM JTY_WEBADI_OTH_TERR_INTF jut
7305 where jut.USER_SEQUENCE = v_user_sequence
7306 and jut.status is null
7307 and jut.terr_qual_id61 is not null
7308 and jut.QUAL61_VALUE_ID is null
7309 and jut.QUAL61_value1 is not null
7310 and jut.INTERFACE_TYPE = v_intf_type
7311 and jut.header = v_header
7312 union all
7313 select terr_id, user_sequence,
7314 terr_qual_id62 terr_qual_id,
7315 62 qual_num, QUAL62_VALUE_ID qual_value_id,
7316 QUAL62_VALUE1 qual_VALUE1,
7317 QUAL62_VALUE2 qual_VALUE2,
7318 QUAL62_VALUE3 qual_VALUE3, ORG_ID,
7319 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7320 CREATED_BY, CREATION_DATE
7321 FROM JTY_WEBADI_OTH_TERR_INTF jut
7322 where jut.USER_SEQUENCE = v_user_sequence
7323 and jut.status is null
7324 and jut.terr_qual_id62 is not null
7325 and jut.QUAL62_VALUE_ID is null
7326 and jut.QUAL62_value1 is not null
7327 and jut.INTERFACE_TYPE = v_intf_type
7328 and jut.header = v_header
7329 union all
7330 select terr_id, user_sequence,
7331 terr_qual_id63 terr_qual_id,
7332 63 qual_num, QUAL63_VALUE_ID qual_value_id,
7333 QUAL63_VALUE1 qual_VALUE1,
7334 QUAL63_VALUE2 qual_VALUE2,
7335 QUAL63_VALUE3 qual_VALUE3, ORG_ID,
7336 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7337 CREATED_BY, CREATION_DATE
7338 FROM JTY_WEBADI_OTH_TERR_INTF jut
7339 where jut.USER_SEQUENCE = v_user_sequence
7340 and jut.status is null
7341 and jut.terr_qual_id63 is not null
7342 and jut.QUAL63_VALUE_ID is null
7343 and jut.QUAL63_value1 is not null
7344 and jut.INTERFACE_TYPE = v_intf_type
7345 and jut.header = v_header
7346 union all
7347 select terr_id, user_sequence,
7348 terr_qual_id64 terr_qual_id,
7349 64 qual_num, QUAL64_VALUE_ID qual_value_id,
7350 QUAL64_VALUE1 qual_VALUE1,
7351 QUAL64_VALUE2 qual_VALUE2,
7352 QUAL64_VALUE3 qual_VALUE3, ORG_ID,
7353 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7354 CREATED_BY, CREATION_DATE
7355 FROM JTY_WEBADI_OTH_TERR_INTF jut
7356 where jut.USER_SEQUENCE = v_user_sequence
7357 and jut.status is null
7358 and jut.terr_qual_id64 is not null
7359 and jut.QUAL64_VALUE_ID is null
7360 and jut.QUAL64_value1 is not null
7361 and jut.INTERFACE_TYPE = v_intf_type
7362 and jut.header = v_header
7363 union all
7364 select terr_id, user_sequence,
7365 terr_qual_id65 terr_qual_id,
7366 65 qual_num, QUAL65_VALUE_ID qual_value_id,
7367 QUAL65_VALUE1 qual_valUE1,
7368 QUAL65_VALUE2 qual_valUE2,
7369 QUAL65_VALUE3 qual_valUE3, ORG_ID,
7370 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7371 CREATED_BY, CREATION_DATE
7372 FROM JTY_WEBADI_OTH_TERR_INTF jut
7373 where jut.USER_SEQUENCE = v_user_sequence
7374 and jut.status is null
7375 and jut.terr_qual_id65 is not null
7376 and jut.QUAL65_VALUE_ID is null
7377 and jut.QUAL65_value1 is not null
7378 and jut.INTERFACE_TYPE = v_intf_type
7379 and jut.header = v_header
7380 union all
7381 select terr_id, user_sequence,
7382 terr_qual_id66 terr_qual_id,
7383 66 qual_num, QUAL66_VALUE_ID qual_value_id,
7384 QUAL66_VALUE1 qual_VALUE1,
7385 QUAL66_VALUE2 qual_VALUE2,
7386 QUAL66_VALUE3 qual_VALUE3, ORG_ID,
7387 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7388 CREATED_BY, CREATION_DATE
7389 FROM JTY_WEBADI_OTH_TERR_INTF jut
7390 where jut.USER_SEQUENCE = v_user_sequence
7391 and jut.status is null
7392 and jut.terr_qual_id66 is not null
7393 and jut.QUAL66_VALUE_ID is null
7394 and jut.QUAL66_value1 is not null
7395 and jut.INTERFACE_TYPE = v_intf_type
7396 and jut.header = v_header
7397 union all
7398 select terr_id, user_sequence,
7399 terr_qual_id67 terr_qual_id,
7400 67 qual_num, QUAL67_VALUE_ID qual_value_id,
7401 QUAL67_VALUE1 qual_VALUE1,
7402 QUAL67_VALUE2 qual_VALUE2,
7403 QUAL67_VALUE3 qual_VALUE3, ORG_ID,
7404 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7405 CREATED_BY, CREATION_DATE
7406 FROM JTY_WEBADI_OTH_TERR_INTF jut
7407 where jut.USER_SEQUENCE = v_user_sequence
7408 and jut.status is null
7409 and jut.terr_qual_id67 is not null
7410 and jut.QUAL67_VALUE_ID is null
7411 and jut.QUAL67_value1 is not null
7412 and jut.INTERFACE_TYPE = v_intf_type
7413 and jut.header = v_header
7414 union all
7415 select terr_id, user_sequence,
7416 terr_qual_id68 terr_qual_id,
7417 68 qual_num, QUAL68_VALUE_ID qual_value_id,
7418 QUAL68_VALUE1 qual_VALUE1,
7419 QUAL68_VALUE2 qual_VALUE2,
7420 QUAL68_VALUE3 qual_VALUE3, ORG_ID,
7421 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7422 CREATED_BY, CREATION_DATE
7423 FROM JTY_WEBADI_OTH_TERR_INTF jut
7424 where jut.USER_SEQUENCE = v_user_sequence
7425 and jut.status is null
7426 and jut.terr_qual_id68 is not null
7427 and jut.QUAL68_VALUE_ID is null
7428 and jut.QUAL68_value1 is not null
7429 and jut.INTERFACE_TYPE = v_intf_type
7430 and jut.header = v_header
7431 union all
7432 select terr_id, user_sequence,
7433 terr_qual_id69 terr_qual_id,
7434 69 qual_num, QUAL69_VALUE_ID qual_value_id,
7435 QUAL69_VALUE1 qual_VALUE1,
7436 QUAL69_VALUE2 qual_VALUE2,
7437 QUAL69_VALUE3 qual_VALUE3, ORG_ID,
7438 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7439 CREATED_BY, CREATION_DATE
7440 FROM JTY_WEBADI_OTH_TERR_INTF jut
7441 where jut.USER_SEQUENCE = v_user_sequence
7442 and jut.status is null
7443 and jut.terr_qual_id69 is not null
7444 and jut.QUAL69_VALUE_ID is null
7445 and jut.QUAL69_value1 is not null
7446 and jut.INTERFACE_TYPE = v_intf_type
7447 and jut.header = v_header
7448 union all
7449 select terr_id, user_sequence,
7450 terr_qual_id70 terr_qual_id,
7451 70 qual_num, QUAL70_VALUE_ID qual_value_id,
7452 QUAL70_VALUE1 qual_VALUE1,
7453 QUAL70_VALUE2 qual_VALUE2,
7454 QUAL70_VALUE3 qual_VALUE3, ORG_ID,
7455 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7456 CREATED_BY, CREATION_DATE
7457 FROM JTY_WEBADI_OTH_TERR_INTF jut
7458 where jut.USER_SEQUENCE = v_user_sequence
7459 and jut.status is null
7460 and jut.terr_qual_id70 is not null
7461 and jut.QUAL70_VALUE_ID is null
7462 and jut.QUAL70_value1 is not null
7463 and jut.INTERFACE_TYPE = v_intf_type
7464 and jut.header = v_header
7465 union all
7466 select terr_id, user_sequence,
7467 terr_qual_id71 terr_qual_id,
7468 71 qual_num, QUAL71_VALUE_ID qual_value_id,
7469 QUAL71_VALUE1 qual_VALUE1,
7470 QUAL71_VALUE2 qual_VALUE2,
7471 QUAL71_VALUE3 qual_VALUE3, ORG_ID,
7472 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7473 CREATED_BY, CREATION_DATE
7474 FROM JTY_WEBADI_OTH_TERR_INTF jut
7475 where jut.USER_SEQUENCE = v_user_sequence
7476 and jut.status is null
7477 and jut.terr_qual_id71 is not null
7478 and jut.QUAL71_VALUE_ID is null
7479 and jut.QUAL71_value1 is not null
7480 and jut.INTERFACE_TYPE = v_intf_type
7481 and jut.header = v_header
7482 union all
7483 select terr_id, user_sequence,
7484 terr_qual_id72 terr_qual_id,
7485 72 qual_num, QUAL72_VALUE_ID qual_value_id,
7486 QUAL72_VALUE1 qual_VALUE1,
7487 QUAL72_VALUE2 qual_VALUE2,
7488 QUAL72_VALUE3 qual_VALUE3, ORG_ID,
7489 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7490 CREATED_BY, CREATION_DATE
7491 FROM JTY_WEBADI_OTH_TERR_INTF jut
7492 where jut.USER_SEQUENCE = v_user_sequence
7493 and jut.status is null
7494 and jut.terr_qual_id72 is not null
7495 and jut.QUAL72_VALUE_ID is null
7496 and jut.QUAL72_value1 is not null
7497 and jut.INTERFACE_TYPE = v_intf_type
7498 and jut.header = v_header
7499 union all
7500 select terr_id, user_sequence,
7501 terr_qual_id73 terr_qual_id,
7502 73 qual_num, QUAL73_VALUE_ID qual_value_id,
7503 QUAL73_VALUE1 qual_VALUE1,
7504 QUAL73_VALUE2 qual_VALUE2,
7505 QUAL73_VALUE3 qual_VALUE3, ORG_ID,
7506 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7507 CREATED_BY, CREATION_DATE
7508 FROM JTY_WEBADI_OTH_TERR_INTF jut
7509 where jut.USER_SEQUENCE = v_user_sequence
7510 and jut.status is null
7511 and jut.terr_qual_id73 is not null
7512 and jut.QUAL73_VALUE_ID is null
7513 and jut.QUAL73_value1 is not null
7514 and jut.INTERFACE_TYPE = v_intf_type
7515 and jut.header = v_header
7516 union all
7517 select terr_id, user_sequence,
7518 terr_qual_id74 terr_qual_id,
7519 74 qual_num, QUAL74_VALUE_ID qual_value_id,
7520 QUAL74_VALUE1 qual_VALUE1,
7521 QUAL74_VALUE2 qual_VALUE2,
7522 QUAL74_VALUE3 qual_VALUE3, ORG_ID,
7523 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7524 CREATED_BY, CREATION_DATE
7525 FROM JTY_WEBADI_OTH_TERR_INTF jut
7526 where jut.USER_SEQUENCE = v_user_sequence
7527 and jut.status is null
7528 and jut.terr_qual_id74 is not null
7529 and jut.QUAL74_VALUE_ID is null
7530 and jut.QUAL74_value1 is not null
7531 and jut.INTERFACE_TYPE = v_intf_type
7532 and jut.header = v_header
7533 union all
7534 select terr_id, user_sequence,
7535 terr_qual_id75 terr_qual_id,
7536 75 qual_num, QUAL75_VALUE_ID qual_value_id,
7537 QUAL75_VALUE1 qual_valUE1,
7538 QUAL75_VALUE2 qual_valUE2,
7539 QUAL75_VALUE3 qual_valUE3, ORG_ID,
7540 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7541 CREATED_BY, CREATION_DATE
7542 FROM JTY_WEBADI_OTH_TERR_INTF jut
7543 where jut.USER_SEQUENCE = v_user_sequence
7544 and jut.status is null
7545 and jut.terr_qual_id75 is not null
7546 and jut.QUAL75_VALUE_ID is null
7547 and jut.QUAL75_value1 is not null
7548 and jut.INTERFACE_TYPE = v_intf_type
7549 and jut.header = v_header
7550 ) sub
7551 where jq.user_sequence = sub.user_sequence
7552 and jq.qualifier_num = sub.qual_num;
7553
7554 CURSOR get_u_terr_value_csr(
7555 v_user_sequence number,
7556 v_action_flag varchar2,
7557 v_intf_type varchar2,
7558 v_header varchar2) IS
7559 select sub.TERR_QUAL_ID, sub.terr_id, sub.qual_value_id,
7560 sub.qual_value1, sub.qual_value2, sub.qual_value3,
7561 sub.org_id, sub.last_updated_by, sub.last_update_date,
7562 sub.last_update_login, sub.creation_date, sub.created_by,
7563 jq.qual_usg_id, jq.display_type qual_type, jq.CONVERT_TO_ID_FLAG,
7564 jq.qualifier_num, jq.html_lov_sql1,
7565 (case
7566 when jq.COMPARISON_OPERATOR = '=' then '='
7567 when (jq.COMPARISON_OPERATOR LIKE '%LIKE%') AND (instr(sub.qual_VALUE1,'_') > 0) or (instr(sub.qual_VALUE1,'%') > 0 and sub.qual_VALUE2 is null) then 'LIKE'
7568 when (jq.COMPARISON_OPERATOR LIKE '%BETWEEN%') AND (sub.qual_VALUE1 is not null and sub.qual_VALUE2 is not null) then 'BETWEEN'
7569 else '='
7570 end) qual_cond
7571 from JTY_WEBADI_QUAL_HEADER jq,
7572 (
7573 select terr_id, user_sequence,
7574 terr_qual_id1 terr_qual_id,
7575 1 qual_num, QUAL1_VALUE_ID qual_value_id,
7576 QUAL1_VALUE1 qual_VALUE1,
7577 QUAL1_VALUE2 qual_VALUE2,
7578 QUAL1_VALUE3 qual_VALUE3, ORG_ID,
7579 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7580 CREATED_BY, CREATION_DATE
7581 FROM JTY_WEBADI_OTH_TERR_INTF jut
7582 where jut.USER_SEQUENCE = v_user_sequence
7583 and jut.status is null
7584 and jut.terr_qual_id1 is not null
7585 and jut.QUAL1_VALUE_ID is not null
7586 and jut.qual1_value1 is not null
7587 and jut.INTERFACE_TYPE = v_intf_type
7588 AND jut.ACTION_FLAG = v_action_flag
7589 and jut.header = v_header
7590 union all
7591 select terr_id, user_sequence,
7592 terr_qual_id2 terr_qual_id,
7593 2 qual_num, QUAL2_VALUE_ID qual_value_id,
7594 QUAL2_VALUE1 qual_VALUE1,
7595 QUAL2_VALUE2 qual_VALUE2,
7596 QUAL2_VALUE3 qual_VALUE3, ORG_ID,
7597 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7598 CREATED_BY, CREATION_DATE
7599 FROM JTY_WEBADI_OTH_TERR_INTF jut
7600 where jut.USER_SEQUENCE = v_user_sequence
7601 and jut.status is null
7602 and jut.terr_qual_id2 is not null
7603 and jut.QUAL2_VALUE_ID is not null
7604 and jut.qual2_value1 is not null
7605 and jut.INTERFACE_TYPE = v_intf_type
7606 AND jut.ACTION_FLAG = v_action_flag
7607 and jut.header = v_header
7608 union all
7609 select terr_id, user_sequence,
7610 terr_qual_id3 terr_qual_id,
7611 3 qual_num, QUAL3_VALUE_ID qual_value_id,
7612 QUAL3_VALUE1 qual_VALUE1,
7613 QUAL3_VALUE2 qual_VALUE2,
7614 QUAL3_VALUE3 qual_VALUE3, ORG_ID,
7615 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7616 CREATED_BY, CREATION_DATE
7617 FROM JTY_WEBADI_OTH_TERR_INTF jut
7618 where jut.USER_SEQUENCE = v_user_sequence
7619 and jut.status is null
7620 and jut.terr_qual_id3 is not null
7621 and jut.QUAL3_VALUE_ID is not null
7622 and jut.qual3_value1 is not null
7623 and jut.INTERFACE_TYPE = v_intf_type
7624 AND jut.ACTION_FLAG = v_action_flag
7625 and jut.header = v_header
7626 union all
7627 select terr_id, user_sequence,
7628 terr_qual_id4 terr_qual_id,
7629 4 qual_num, QUAL4_VALUE_ID qual_value_id,
7630 QUAL4_VALUE1 qual_VALUE1,
7631 QUAL4_VALUE2 qual_VALUE2,
7632 QUAL4_VALUE3 qual_VALUE3, ORG_ID,
7633 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7634 CREATED_BY, CREATION_DATE
7635 FROM JTY_WEBADI_OTH_TERR_INTF jut
7636 where jut.USER_SEQUENCE = v_user_sequence
7637 and jut.status is null
7638 and jut.terr_qual_id4 is not null
7639 and jut.QUAL4_VALUE_ID is not null
7640 and jut.qual4_value1 is not null
7641 and jut.INTERFACE_TYPE = v_intf_type
7642 AND jut.ACTION_FLAG = v_action_flag
7643 and jut.header = v_header
7644 union all
7645 select terr_id, user_sequence,
7646 terr_qual_id5 terr_qual_id,
7647 5 qual_num, QUAL5_VALUE_ID qual_value_id,
7648 QUAL5_VALUE1 qual_VALUE1,
7649 QUAL5_VALUE2 qual_VALUE2,
7650 QUAL5_VALUE3 qual_VALUE3, ORG_ID,
7651 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7652 CREATED_BY, CREATION_DATE
7653 FROM JTY_WEBADI_OTH_TERR_INTF jut
7654 where jut.USER_SEQUENCE = v_user_sequence
7655 and jut.status is null
7656 and jut.terr_qual_id5 is not null
7657 and jut.QUAL5_VALUE_ID is not null
7658 and jut.qual5_value1 is not null
7659 and jut.INTERFACE_TYPE = v_intf_type
7660 AND jut.ACTION_FLAG = v_action_flag
7661 and jut.header = v_header
7662 union all
7663 select terr_id, user_sequence,
7664 terr_qual_id6 terr_qual_id,
7665 6 qual_num, QUAL6_VALUE_ID qual_value_id,
7666 QUAL6_VALUE1 qual_VALUE1,
7667 QUAL6_VALUE2 qual_VALUE2,
7668 QUAL6_VALUE3 qual_VALUE3, ORG_ID,
7669 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7670 CREATED_BY, CREATION_DATE
7671 FROM JTY_WEBADI_OTH_TERR_INTF jut
7672 where jut.USER_SEQUENCE = v_user_sequence
7673 and jut.status is null
7674 and jut.terr_qual_id6 is not null
7675 and jut.QUAL6_VALUE_ID is not null
7676 and jut.qual6_value1 is not null
7677 and jut.INTERFACE_TYPE = v_intf_type
7678 AND jut.ACTION_FLAG = v_action_flag
7679 and jut.header = v_header
7680 union all
7681 select terr_id, user_sequence,
7682 terr_qual_id7 terr_qual_id,
7683 7 qual_num, QUAL7_VALUE_ID qual_value_id,
7684 QUAL7_VALUE1 qual_VALUE1,
7685 QUAL7_VALUE2 qual_VALUE2,
7686 QUAL7_VALUE3 qual_VALUE3, ORG_ID,
7687 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7688 CREATED_BY, CREATION_DATE
7689 FROM JTY_WEBADI_OTH_TERR_INTF jut
7690 where jut.USER_SEQUENCE = v_user_sequence
7691 and jut.status is null
7692 and jut.terr_qual_id7 is not null
7693 and jut.QUAL7_VALUE_ID is not null
7694 and jut.qual7_value1 is not null
7695 and jut.INTERFACE_TYPE = v_intf_type
7696 AND jut.ACTION_FLAG = v_action_flag
7697 and jut.header = v_header
7698 union all
7699 select terr_id, user_sequence,
7700 terr_qual_id8 terr_qual_id,
7701 8 qual_num, QUAL8_VALUE_ID qual_value_id,
7702 QUAL8_VALUE1 qual_VALUE1,
7703 QUAL8_VALUE2 qual_VALUE2,
7704 QUAL8_VALUE3 qual_VALUE3, ORG_ID,
7705 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7706 CREATED_BY, CREATION_DATE
7707 FROM JTY_WEBADI_OTH_TERR_INTF jut
7708 where jut.USER_SEQUENCE = v_user_sequence
7709 and jut.status is null
7710 and jut.terr_qual_id8 is not null
7711 and jut.QUAL8_VALUE_ID is not null
7712 and jut.qual8_value1 is not null
7713 and jut.INTERFACE_TYPE = v_intf_type
7714 AND jut.ACTION_FLAG = v_action_flag
7715 and jut.header = v_header
7716 union all
7717 select terr_id, user_sequence,
7718 terr_qual_id9 terr_qual_id,
7719 9 qual_num, QUAL9_VALUE_ID qual_value_id,
7720 QUAL9_VALUE1 qual_VALUE1,
7721 QUAL9_VALUE2 qual_VALUE2,
7722 QUAL9_VALUE3 qual_VALUE3, ORG_ID,
7723 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7724 CREATED_BY, CREATION_DATE
7725 FROM JTY_WEBADI_OTH_TERR_INTF jut
7726 where jut.USER_SEQUENCE = v_user_sequence
7727 and jut.status is null
7728 and jut.terr_qual_id9 is not null
7729 and jut.QUAL9_VALUE_ID is not null
7730 and jut.qual9_value1 is not null
7731 and jut.INTERFACE_TYPE = v_intf_type
7732 AND jut.ACTION_FLAG = v_action_flag
7733 and jut.header = v_header
7734 union all
7735 select terr_id, user_sequence,
7736 terr_qual_id10 terr_qual_id,
7737 10 qual_num, QUAL10_VALUE_ID qual_value_id,
7738 QUAL10_VALUE1 qual_VALUE1,
7739 QUAL10_VALUE2 qual_VALUE2,
7740 QUAL10_VALUE3 qual_VALUE3, ORG_ID,
7741 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7742 CREATED_BY, CREATION_DATE
7743 FROM JTY_WEBADI_OTH_TERR_INTF jut
7744 where jut.USER_SEQUENCE = v_user_sequence
7745 and jut.status is null
7746 and jut.terr_qual_id10 is not null
7747 and jut.QUAL10_VALUE_ID is not null
7748 and jut.qual10_value1 is not null
7749 and jut.INTERFACE_TYPE = v_intf_type
7750 AND jut.ACTION_FLAG = v_action_flag
7751 and jut.header = v_header
7752 union all
7753 select terr_id, user_sequence,
7754 terr_qual_id11 terr_qual_id,
7755 11 qual_num, QUAL11_VALUE_ID qual_value_id,
7756 QUAL11_VALUE1 qual_VALUE1,
7757 QUAL11_VALUE2 qual_VALUE2,
7758 QUAL11_VALUE3 qual_VALUE3, ORG_ID,
7759 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7760 CREATED_BY, CREATION_DATE
7761 FROM JTY_WEBADI_OTH_TERR_INTF jut
7762 where jut.USER_SEQUENCE = v_user_sequence
7763 and jut.status is null
7764 and jut.terr_qual_id11 is not null
7765 and jut.QUAL11_VALUE_ID is not null
7766 and jut.qual11_value1 is not null
7767 and jut.INTERFACE_TYPE = v_intf_type
7768 AND jut.ACTION_FLAG = v_action_flag
7769 and jut.header = v_header
7770 union all
7771 select terr_id, user_sequence,
7772 terr_qual_id12 terr_qual_id,
7773 12 qual_num, QUAL12_VALUE_ID qual_value_id,
7774 QUAL12_VALUE1 qual_VALUE1,
7775 QUAL12_VALUE2 qual_VALUE2,
7776 QUAL12_VALUE3 qual_VALUE3, ORG_ID,
7777 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7778 CREATED_BY, CREATION_DATE
7779 FROM JTY_WEBADI_OTH_TERR_INTF jut
7780 where jut.USER_SEQUENCE = v_user_sequence
7781 and jut.status is null
7782 and jut.terr_qual_id12 is not null
7783 and jut.QUAL12_VALUE_ID is not null
7784 and jut.qual12_value1 is not null
7785 and jut.INTERFACE_TYPE = v_intf_type
7786 AND jut.ACTION_FLAG = v_action_flag
7787 and jut.header = v_header
7788 union all
7789 select terr_id, user_sequence,
7790 terr_qual_id13 terr_qual_id,
7791 13 qual_num, QUAL13_VALUE_ID qual_value_id,
7792 QUAL13_VALUE1 qual_VALUE1,
7793 QUAL13_VALUE2 qual_VALUE2,
7794 QUAL13_VALUE3 qual_VALUE3, ORG_ID,
7795 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7796 CREATED_BY, CREATION_DATE
7797 FROM JTY_WEBADI_OTH_TERR_INTF jut
7798 where jut.USER_SEQUENCE = v_user_sequence
7799 and jut.status is null
7800 and jut.terr_qual_id13 is not null
7801 and jut.QUAL13_VALUE_ID is not null
7802 and jut.qual13_value1 is not null
7803 and jut.INTERFACE_TYPE = v_intf_type
7804 AND jut.ACTION_FLAG = v_action_flag
7805 and jut.header = v_header
7806 union all
7807 select terr_id, user_sequence,
7808 terr_qual_id14 terr_qual_id,
7809 14 qual_num, QUAL14_VALUE_ID qual_value_id,
7810 QUAL14_VALUE1 qual_VALUE1,
7811 QUAL14_VALUE2 qual_VALUE2,
7812 QUAL14_VALUE3 qual_VALUE3, ORG_ID,
7813 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7814 CREATED_BY, CREATION_DATE
7815 FROM JTY_WEBADI_OTH_TERR_INTF jut
7816 where jut.USER_SEQUENCE = v_user_sequence
7817 and jut.status is null
7818 and jut.terr_qual_id14 is not null
7819 and jut.QUAL14_VALUE_ID is not null
7820 and jut.qual14_value1 is not null
7821 and jut.INTERFACE_TYPE = v_intf_type
7822 AND jut.ACTION_FLAG = v_action_flag
7823 and jut.header = v_header
7824 union all
7825 select terr_id, user_sequence,
7826 terr_qual_id15 terr_qual_id,
7827 15 qual_num, QUAL15_VALUE_ID qual_value_id,
7828 QUAL15_VALUE1 qual_VALUE1,
7829 QUAL15_VALUE2 qual_VALUE2,
7830 QUAL15_VALUE3 qual_VALUE3, ORG_ID,
7831 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7832 CREATED_BY, CREATION_DATE
7833 FROM JTY_WEBADI_OTH_TERR_INTF jut
7834 where jut.USER_SEQUENCE = v_user_sequence
7835 and jut.status is null
7836 and jut.terr_qual_id15 is not null
7837 and jut.QUAL15_VALUE_ID is not null
7838 and jut.qual15_value1 is not null
7839 and jut.INTERFACE_TYPE = v_intf_type
7840 AND jut.ACTION_FLAG = v_action_flag
7841 and jut.header = v_header
7842 union all
7843 select terr_id, user_sequence,
7844 terr_qual_id16 terr_qual_id,
7845 16 qual_num, QUAL16_VALUE_ID qual_value_id,
7846 QUAL16_VALUE1 qual_VALUE1,
7847 QUAL16_VALUE2 qual_VALUE2,
7848 QUAL16_VALUE3 qual_VALUE3, ORG_ID,
7849 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7850 CREATED_BY, CREATION_DATE
7851 FROM JTY_WEBADI_OTH_TERR_INTF jut
7852 where jut.USER_SEQUENCE = v_user_sequence
7853 and jut.status is null
7854 and jut.terr_qual_id16 is not null
7855 and jut.QUAL16_VALUE_ID is not null
7856 and jut.qual16_value1 is not null
7857 and jut.INTERFACE_TYPE = v_intf_type
7858 AND jut.ACTION_FLAG = v_action_flag
7859 and jut.header = v_header
7860 union all
7861 select terr_id, user_sequence,
7862 terr_qual_id17 terr_qual_id,
7863 17 qual_num, QUAL17_VALUE_ID qual_value_id,
7864 QUAL17_VALUE1 qual_VALUE1,
7865 QUAL17_VALUE2 qual_VALUE2,
7866 QUAL17_VALUE3 qual_VALUE3, ORG_ID,
7867 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7868 CREATED_BY, CREATION_DATE
7869 FROM JTY_WEBADI_OTH_TERR_INTF jut
7870 where jut.USER_SEQUENCE = v_user_sequence
7871 and jut.status is null
7872 and jut.terr_qual_id17 is not null
7873 and jut.QUAL17_VALUE_ID is not null
7874 and jut.qual17_value1 is not null
7875 and jut.INTERFACE_TYPE = v_intf_type
7876 AND jut.ACTION_FLAG = v_action_flag
7877 and jut.header = v_header
7878 union all
7879 select terr_id, user_sequence,
7880 terr_qual_id18 terr_qual_id,
7881 18 qual_num, QUAL18_VALUE_ID qual_value_id,
7882 QUAL18_VALUE1 qual_VALUE1,
7883 QUAL18_VALUE2 qual_VALUE2,
7884 QUAL18_VALUE3 qual_VALUE3, ORG_ID,
7885 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7886 CREATED_BY, CREATION_DATE
7887 FROM JTY_WEBADI_OTH_TERR_INTF jut
7888 where jut.USER_SEQUENCE = v_user_sequence
7889 and jut.status is null
7890 and jut.terr_qual_id18 is not null
7891 and jut.QUAL18_VALUE_ID is not null
7892 and jut.qual18_value1 is not null
7893 and jut.INTERFACE_TYPE = v_intf_type
7894 AND jut.ACTION_FLAG = v_action_flag
7895 and jut.header = v_header
7896 union all
7897 select terr_id, user_sequence,
7898 terr_qual_id19 terr_qual_id,
7899 19 qual_num, QUAL19_VALUE_ID qual_value_id,
7900 QUAL19_VALUE1 qual_VALUE1,
7901 QUAL19_VALUE2 qual_VALUE2,
7902 QUAL19_VALUE3 qual_VALUE3, ORG_ID,
7903 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7904 CREATED_BY, CREATION_DATE
7905 FROM JTY_WEBADI_OTH_TERR_INTF jut
7906 where jut.USER_SEQUENCE = v_user_sequence
7907 and jut.status is null
7908 and jut.terr_qual_id19 is not null
7909 and jut.QUAL19_VALUE_ID is not null
7910 and jut.qual19_value1 is not null
7911 and jut.INTERFACE_TYPE = v_intf_type
7912 AND jut.ACTION_FLAG = v_action_flag
7913 and jut.header = v_header
7914 union all
7915 select terr_id, user_sequence,
7916 terr_qual_id20 terr_qual_id,
7917 20 qual_num, QUAL20_VALUE_ID qual_value_id,
7918 QUAL20_VALUE1 qual_VALUE1,
7919 QUAL20_VALUE2 qual_VALUE2,
7920 QUAL20_VALUE3 qual_VALUE3, ORG_ID,
7921 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7922 CREATED_BY, CREATION_DATE
7923 FROM JTY_WEBADI_OTH_TERR_INTF jut
7924 where jut.USER_SEQUENCE = v_user_sequence
7925 and jut.status is null
7926 and jut.terr_qual_id20 is not null
7927 and jut.QUAL20_VALUE_ID is not null
7928 and jut.qual20_value1 is not null
7929 and jut.INTERFACE_TYPE = v_intf_type
7930 AND jut.ACTION_FLAG = v_action_flag
7931 and jut.header = v_header
7932 union all
7933 select terr_id, user_sequence,
7934 terr_qual_id21 terr_qual_id,
7935 21 qual_num, QUAL21_VALUE_ID qual_value_id,
7936 QUAL21_VALUE1 qual_VALUE1,
7937 QUAL21_VALUE2 qual_VALUE2,
7938 QUAL21_VALUE3 qual_VALUE3, ORG_ID,
7939 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7940 CREATED_BY, CREATION_DATE
7941 FROM JTY_WEBADI_OTH_TERR_INTF jut
7942 where jut.USER_SEQUENCE = v_user_sequence
7943 and jut.status is null
7944 and jut.terr_qual_id21 is not null
7945 and jut.QUAL21_VALUE_ID is not null
7946 and jut.qual21_value1 is not null
7947 and jut.INTERFACE_TYPE = v_intf_type
7948 AND jut.ACTION_FLAG = v_action_flag
7949 and jut.header = v_header
7950 union all
7951 select terr_id, user_sequence,
7952 terr_qual_id22 terr_qual_id,
7953 22 qual_num, QUAL22_VALUE_ID qual_value_id,
7954 QUAL22_VALUE1 qual_VALUE1,
7955 QUAL22_VALUE2 qual_VALUE2,
7956 QUAL22_VALUE3 qual_VALUE3, ORG_ID,
7957 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7958 CREATED_BY, CREATION_DATE
7959 FROM JTY_WEBADI_OTH_TERR_INTF jut
7960 where jut.USER_SEQUENCE = v_user_sequence
7961 and jut.status is null
7962 and jut.terr_qual_id22 is not null
7963 and jut.QUAL22_VALUE_ID is not null
7964 and jut.qual22_value1 is not null
7965 and jut.INTERFACE_TYPE = v_intf_type
7966 AND jut.ACTION_FLAG = v_action_flag
7967 and jut.header = v_header
7968 union all
7969 select terr_id, user_sequence,
7970 terr_qual_id23 terr_qual_id,
7971 23 qual_num, QUAL23_VALUE_ID qual_value_id,
7972 QUAL23_VALUE1 qual_VALUE1,
7973 QUAL23_VALUE2 qual_VALUE2,
7974 QUAL23_VALUE3 qual_VALUE3, ORG_ID,
7975 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7976 CREATED_BY, CREATION_DATE
7977 FROM JTY_WEBADI_OTH_TERR_INTF jut
7978 where jut.USER_SEQUENCE = v_user_sequence
7979 and jut.status is null
7980 and jut.terr_qual_id23 is not null
7981 and jut.QUAL23_VALUE_ID is not null
7982 and jut.qual23_value1 is not null
7983 and jut.INTERFACE_TYPE = v_intf_type
7984 AND jut.ACTION_FLAG = v_action_flag
7985 and jut.header = v_header
7986 union all
7987 select terr_id, user_sequence,
7988 terr_qual_id24 terr_qual_id,
7989 24 qual_num, QUAL24_VALUE_ID qual_value_id,
7990 QUAL24_VALUE1 qual_VALUE1,
7991 QUAL24_VALUE2 qual_VALUE2,
7992 QUAL24_VALUE3 qual_VALUE3, ORG_ID,
7993 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
7994 CREATED_BY, CREATION_DATE
7995 FROM JTY_WEBADI_OTH_TERR_INTF jut
7996 where jut.USER_SEQUENCE = v_user_sequence
7997 and jut.status is null
7998 and jut.terr_qual_id24 is not null
7999 and jut.QUAL24_VALUE_ID is not null
8000 and jut.qual24_value1 is not null
8001 and jut.INTERFACE_TYPE = v_intf_type
8002 AND jut.ACTION_FLAG = v_action_flag
8003 and jut.header = v_header
8004 union all
8005 select terr_id, user_sequence,
8006 terr_qual_id25 terr_qual_id,
8007 25 qual_num, QUAL25_VALUE_ID qual_value_id,
8008 QUAL25_VALUE1 qual_valUE1,
8009 QUAL25_VALUE2 qual_valUE2,
8010 QUAL25_VALUE3 qual_valUE3, ORG_ID,
8011 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8012 CREATED_BY, CREATION_DATE
8013 FROM JTY_WEBADI_OTH_TERR_INTF jut
8014 where jut.USER_SEQUENCE = v_user_sequence
8015 and jut.status is null
8016 and jut.terr_qual_id25 is not null
8017 and jut.QUAL25_VALUE_ID is not null
8018 and jut.qual25_value1 is not null
8019 and jut.INTERFACE_TYPE = v_intf_type
8020 AND jut.ACTION_FLAG = v_action_flag
8021 and jut.header = v_header
8022 union all
8023 select terr_id, user_sequence,
8024 terr_qual_id26 terr_qual_id,
8025 26 qual_num, QUAL26_VALUE_ID qual_value_id,
8026 QUAL26_VALUE1 qual_VALUE1,
8027 QUAL26_VALUE2 qual_VALUE2,
8028 QUAL26_VALUE3 qual_VALUE3, ORG_ID,
8029 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8030 CREATED_BY, CREATION_DATE
8031 FROM JTY_WEBADI_OTH_TERR_INTF jut
8032 where jut.USER_SEQUENCE = v_user_sequence
8033 and jut.status is null
8034 and jut.terr_qual_id26 is not null
8035 and jut.QUAL26_VALUE_ID is not null
8036 and jut.QUAL26_value1 is not null
8037 and jut.INTERFACE_TYPE = v_intf_type
8038 AND jut.ACTION_FLAG = v_action_flag
8039 and jut.header = v_header
8040 union all
8041 select terr_id, user_sequence,
8042 terr_qual_id27 terr_qual_id,
8043 27 qual_num, QUAL27_VALUE_ID qual_value_id,
8044 QUAL27_VALUE1 qual_VALUE1,
8045 QUAL27_VALUE2 qual_VALUE2,
8046 QUAL27_VALUE3 qual_VALUE3, ORG_ID,
8047 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8048 CREATED_BY, CREATION_DATE
8049 FROM JTY_WEBADI_OTH_TERR_INTF jut
8050 where jut.USER_SEQUENCE = v_user_sequence
8051 and jut.status is null
8052 and jut.terr_qual_id27 is not null
8053 and jut.QUAL27_VALUE_ID is not null
8054 and jut.QUAL27_value1 is not null
8055 and jut.INTERFACE_TYPE = v_intf_type
8056 AND jut.ACTION_FLAG = v_action_flag
8057 and jut.header = v_header
8058 union all
8059 select terr_id, user_sequence,
8060 terr_qual_id28 terr_qual_id,
8061 28 qual_num, QUAL28_VALUE_ID qual_value_id,
8062 QUAL28_VALUE1 qual_VALUE1,
8063 QUAL28_VALUE2 qual_VALUE2,
8064 QUAL28_VALUE3 qual_VALUE3, ORG_ID,
8065 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8066 CREATED_BY, CREATION_DATE
8067 FROM JTY_WEBADI_OTH_TERR_INTF jut
8068 where jut.USER_SEQUENCE = v_user_sequence
8069 and jut.status is null
8070 and jut.terr_qual_id28 is not null
8071 and jut.QUAL28_VALUE_ID is not null
8072 and jut.QUAL28_value1 is not null
8073 and jut.INTERFACE_TYPE = v_intf_type
8074 AND jut.ACTION_FLAG = v_action_flag
8075 and jut.header = v_header
8076 union all
8077 select terr_id, user_sequence,
8078 terr_qual_id29 terr_qual_id,
8079 29 qual_num, QUAL29_VALUE_ID qual_value_id,
8080 QUAL29_VALUE1 qual_VALUE1,
8081 QUAL29_VALUE2 qual_VALUE2,
8082 QUAL29_VALUE3 qual_VALUE3, ORG_ID,
8083 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8084 CREATED_BY, CREATION_DATE
8085 FROM JTY_WEBADI_OTH_TERR_INTF jut
8086 where jut.USER_SEQUENCE = v_user_sequence
8087 and jut.status is null
8088 and jut.terr_qual_id29 is not null
8089 and jut.QUAL29_VALUE_ID is not null
8090 and jut.QUAL29_value1 is not null
8091 and jut.INTERFACE_TYPE = v_intf_type
8092 AND jut.ACTION_FLAG = v_action_flag
8093 and jut.header = v_header
8094 union all
8095 select terr_id, user_sequence,
8096 terr_qual_id30 terr_qual_id,
8097 30 qual_num, QUAL30_VALUE_ID qual_value_id,
8098 QUAL30_VALUE1 qual_VALUE1,
8099 QUAL30_VALUE2 qual_VALUE2,
8100 QUAL30_VALUE3 qual_VALUE3, ORG_ID,
8101 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8102 CREATED_BY, CREATION_DATE
8103 FROM JTY_WEBADI_OTH_TERR_INTF jut
8104 where jut.USER_SEQUENCE = v_user_sequence
8105 and jut.status is null
8106 and jut.terr_qual_id30 is not null
8107 and jut.QUAL30_VALUE_ID is not null
8108 and jut.QUAL30_value1 is not null
8109 and jut.INTERFACE_TYPE = v_intf_type
8110 AND jut.ACTION_FLAG = v_action_flag
8111 and jut.header = v_header
8112 union all
8113 select terr_id, user_sequence,
8114 terr_qual_id31 terr_qual_id,
8115 31 qual_num, QUAL31_VALUE_ID qual_value_id,
8116 QUAL31_VALUE1 qual_VALUE1,
8117 QUAL31_VALUE2 qual_VALUE2,
8118 QUAL31_VALUE3 qual_VALUE3, ORG_ID,
8119 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8120 CREATED_BY, CREATION_DATE
8121 FROM JTY_WEBADI_OTH_TERR_INTF jut
8122 where jut.USER_SEQUENCE = v_user_sequence
8123 and jut.status is null
8124 and jut.terr_qual_id31 is not null
8125 and jut.QUAL31_VALUE_ID is not null
8126 and jut.QUAL31_value1 is not null
8127 and jut.INTERFACE_TYPE = v_intf_type
8128 AND jut.ACTION_FLAG = v_action_flag
8129 and jut.header = v_header
8130 union all
8131 select terr_id, user_sequence,
8132 terr_qual_id32 terr_qual_id,
8133 32 qual_num, QUAL32_VALUE_ID qual_value_id,
8134 QUAL32_VALUE1 qual_VALUE1,
8135 QUAL32_VALUE2 qual_VALUE2,
8136 QUAL32_VALUE3 qual_VALUE3, ORG_ID,
8137 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8138 CREATED_BY, CREATION_DATE
8139 FROM JTY_WEBADI_OTH_TERR_INTF jut
8140 where jut.USER_SEQUENCE = v_user_sequence
8141 and jut.status is null
8142 and jut.terr_qual_id32 is not null
8143 and jut.QUAL32_VALUE_ID is not null
8144 and jut.QUAL32_value1 is not null
8145 and jut.INTERFACE_TYPE = v_intf_type
8146 AND jut.ACTION_FLAG = v_action_flag
8147 and jut.header = v_header
8148 union all
8149 select terr_id, user_sequence,
8150 terr_qual_id33 terr_qual_id,
8151 33 qual_num, QUAL33_VALUE_ID qual_value_id,
8152 QUAL33_VALUE1 qual_VALUE1,
8153 QUAL33_VALUE2 qual_VALUE2,
8154 QUAL33_VALUE3 qual_VALUE3, ORG_ID,
8155 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8156 CREATED_BY, CREATION_DATE
8157 FROM JTY_WEBADI_OTH_TERR_INTF jut
8158 where jut.USER_SEQUENCE = v_user_sequence
8159 and jut.status is null
8160 and jut.terr_qual_id33 is not null
8161 and jut.QUAL33_VALUE_ID is not null
8162 and jut.QUAL33_value1 is not null
8163 and jut.INTERFACE_TYPE = v_intf_type
8164 AND jut.ACTION_FLAG = v_action_flag
8165 and jut.header = v_header
8166 union all
8167 select terr_id, user_sequence,
8168 terr_qual_id34 terr_qual_id,
8169 34 qual_num, QUAL34_VALUE_ID qual_value_id,
8170 QUAL34_VALUE1 qual_VALUE1,
8171 QUAL34_VALUE2 qual_VALUE2,
8172 QUAL34_VALUE3 qual_VALUE3, ORG_ID,
8173 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8174 CREATED_BY, CREATION_DATE
8175 FROM JTY_WEBADI_OTH_TERR_INTF jut
8176 where jut.USER_SEQUENCE = v_user_sequence
8177 and jut.status is null
8178 and jut.terr_qual_id34 is not null
8179 and jut.QUAL34_VALUE_ID is not null
8180 and jut.QUAL34_value1 is not null
8181 and jut.INTERFACE_TYPE = v_intf_type
8182 AND jut.ACTION_FLAG = v_action_flag
8183 and jut.header = v_header
8184 union all
8185 select terr_id, user_sequence,
8186 terr_qual_id35 terr_qual_id,
8187 35 qual_num, QUAL35_VALUE_ID qual_value_id,
8188 QUAL35_VALUE1 qual_valUE1,
8189 QUAL35_VALUE2 qual_valUE2,
8190 QUAL35_VALUE3 qual_valUE3, ORG_ID,
8191 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8192 CREATED_BY, CREATION_DATE
8193 FROM JTY_WEBADI_OTH_TERR_INTF jut
8194 where jut.USER_SEQUENCE = v_user_sequence
8195 and jut.status is null
8196 and jut.terr_qual_id35 is not null
8197 and jut.QUAL35_VALUE_ID is not null
8198 and jut.QUAL35_value1 is not null
8199 and jut.INTERFACE_TYPE = v_intf_type
8200 AND jut.ACTION_FLAG = v_action_flag
8201 and jut.header = v_header
8202 union all
8203 select terr_id, user_sequence,
8204 terr_qual_id36 terr_qual_id,
8205 36 qual_num, QUAL36_VALUE_ID qual_value_id,
8206 QUAL36_VALUE1 qual_VALUE1,
8207 QUAL36_VALUE2 qual_VALUE2,
8208 QUAL36_VALUE3 qual_VALUE3, ORG_ID,
8209 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8210 CREATED_BY, CREATION_DATE
8211 FROM JTY_WEBADI_OTH_TERR_INTF jut
8212 where jut.USER_SEQUENCE = v_user_sequence
8213 and jut.status is null
8214 and jut.terr_qual_id36 is not null
8215 and jut.QUAL36_VALUE_ID is not null
8216 and jut.QUAL36_value1 is not null
8217 and jut.INTERFACE_TYPE = v_intf_type
8218 AND jut.ACTION_FLAG = v_action_flag
8219 and jut.header = v_header
8220 union all
8221 select terr_id, user_sequence,
8222 terr_qual_id37 terr_qual_id,
8223 37 qual_num, QUAL37_VALUE_ID qual_value_id,
8224 QUAL37_VALUE1 qual_VALUE1,
8225 QUAL37_VALUE2 qual_VALUE2,
8226 QUAL37_VALUE3 qual_VALUE3, ORG_ID,
8227 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8228 CREATED_BY, CREATION_DATE
8229 FROM JTY_WEBADI_OTH_TERR_INTF jut
8230 where jut.USER_SEQUENCE = v_user_sequence
8231 and jut.status is null
8232 and jut.terr_qual_id37 is not null
8233 and jut.QUAL37_VALUE_ID is not null
8234 and jut.QUAL37_value1 is not null
8235 and jut.INTERFACE_TYPE = v_intf_type
8236 AND jut.ACTION_FLAG = v_action_flag
8237 and jut.header = v_header
8238 union all
8239 select terr_id, user_sequence,
8240 terr_qual_id38 terr_qual_id,
8241 38 qual_num, QUAL38_VALUE_ID qual_value_id,
8242 QUAL38_VALUE1 qual_VALUE1,
8243 QUAL38_VALUE2 qual_VALUE2,
8244 QUAL38_VALUE3 qual_VALUE3, ORG_ID,
8245 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8246 CREATED_BY, CREATION_DATE
8247 FROM JTY_WEBADI_OTH_TERR_INTF jut
8248 where jut.USER_SEQUENCE = v_user_sequence
8249 and jut.status is null
8250 and jut.terr_qual_id38 is not null
8251 and jut.QUAL38_VALUE_ID is not null
8252 and jut.QUAL38_value1 is not null
8253 and jut.INTERFACE_TYPE = v_intf_type
8254 AND jut.ACTION_FLAG = v_action_flag
8255 and jut.header = v_header
8256 union all
8257 select terr_id, user_sequence,
8258 terr_qual_id39 terr_qual_id,
8259 39 qual_num, QUAL39_VALUE_ID qual_value_id,
8260 QUAL39_VALUE1 qual_VALUE1,
8261 QUAL39_VALUE2 qual_VALUE2,
8262 QUAL39_VALUE3 qual_VALUE3, ORG_ID,
8263 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8264 CREATED_BY, CREATION_DATE
8265 FROM JTY_WEBADI_OTH_TERR_INTF jut
8266 where jut.USER_SEQUENCE = v_user_sequence
8267 and jut.status is null
8268 and jut.terr_qual_id39 is not null
8269 and jut.QUAL39_VALUE_ID is not null
8270 and jut.QUAL39_value1 is not null
8271 and jut.INTERFACE_TYPE = v_intf_type
8272 AND jut.ACTION_FLAG = v_action_flag
8273 and jut.header = v_header
8274 union all
8275 select terr_id, user_sequence,
8276 terr_qual_id40 terr_qual_id,
8277 40 qual_num, QUAL40_VALUE_ID qual_value_id,
8278 QUAL40_VALUE1 qual_VALUE1,
8279 QUAL40_VALUE2 qual_VALUE2,
8280 QUAL40_VALUE3 qual_VALUE3, ORG_ID,
8281 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8282 CREATED_BY, CREATION_DATE
8283 FROM JTY_WEBADI_OTH_TERR_INTF jut
8284 where jut.USER_SEQUENCE = v_user_sequence
8285 and jut.status is null
8286 and jut.terr_qual_id40 is not null
8287 and jut.QUAL40_VALUE_ID is not null
8288 and jut.QUAL40_value1 is not null
8289 and jut.INTERFACE_TYPE = v_intf_type
8290 AND jut.ACTION_FLAG = v_action_flag
8291 and jut.header = v_header
8292 union all
8293 select terr_id, user_sequence,
8294 terr_qual_id41 terr_qual_id,
8295 41 qual_num, QUAL41_VALUE_ID qual_value_id,
8296 QUAL41_VALUE1 qual_VALUE1,
8297 QUAL41_VALUE2 qual_VALUE2,
8298 QUAL41_VALUE3 qual_VALUE3, ORG_ID,
8299 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8300 CREATED_BY, CREATION_DATE
8301 FROM JTY_WEBADI_OTH_TERR_INTF jut
8302 where jut.USER_SEQUENCE = v_user_sequence
8303 and jut.status is null
8304 and jut.terr_qual_id41 is not null
8305 and jut.QUAL41_VALUE_ID is not null
8306 and jut.QUAL41_value1 is not null
8307 and jut.INTERFACE_TYPE = v_intf_type
8308 AND jut.ACTION_FLAG = v_action_flag
8309 and jut.header = v_header
8310 union all
8311 select terr_id, user_sequence,
8312 terr_qual_id42 terr_qual_id,
8313 42 qual_num, QUAL42_VALUE_ID qual_value_id,
8314 QUAL42_VALUE1 qual_VALUE1,
8315 QUAL42_VALUE2 qual_VALUE2,
8316 QUAL42_VALUE3 qual_VALUE3, ORG_ID,
8317 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8318 CREATED_BY, CREATION_DATE
8319 FROM JTY_WEBADI_OTH_TERR_INTF jut
8320 where jut.USER_SEQUENCE = v_user_sequence
8321 and jut.status is null
8322 and jut.terr_qual_id42 is not null
8323 and jut.QUAL42_VALUE_ID is not null
8324 and jut.QUAL42_value1 is not null
8325 and jut.INTERFACE_TYPE = v_intf_type
8326 AND jut.ACTION_FLAG = v_action_flag
8327 and jut.header = v_header
8328 union all
8329 select terr_id, user_sequence,
8330 terr_qual_id43 terr_qual_id,
8331 43 qual_num, QUAL43_VALUE_ID qual_value_id,
8332 QUAL43_VALUE1 qual_VALUE1,
8333 QUAL43_VALUE2 qual_VALUE2,
8334 QUAL43_VALUE3 qual_VALUE3, ORG_ID,
8335 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8336 CREATED_BY, CREATION_DATE
8337 FROM JTY_WEBADI_OTH_TERR_INTF jut
8338 where jut.USER_SEQUENCE = v_user_sequence
8339 and jut.status is null
8340 and jut.terr_qual_id43 is not null
8341 and jut.QUAL43_VALUE_ID is not null
8342 and jut.QUAL43_value1 is not null
8343 and jut.INTERFACE_TYPE = v_intf_type
8344 AND jut.ACTION_FLAG = v_action_flag
8345 and jut.header = v_header
8346 union all
8347 select terr_id, user_sequence,
8348 terr_qual_id44 terr_qual_id,
8349 44 qual_num, QUAL44_VALUE_ID qual_value_id,
8350 QUAL44_VALUE1 qual_VALUE1,
8351 QUAL44_VALUE2 qual_VALUE2,
8352 QUAL44_VALUE3 qual_VALUE3, ORG_ID,
8353 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8354 CREATED_BY, CREATION_DATE
8355 FROM JTY_WEBADI_OTH_TERR_INTF jut
8356 where jut.USER_SEQUENCE = v_user_sequence
8357 and jut.status is null
8358 and jut.terr_qual_id44 is not null
8359 and jut.QUAL44_VALUE_ID is not null
8360 and jut.QUAL44_value1 is not null
8361 and jut.INTERFACE_TYPE = v_intf_type
8362 AND jut.ACTION_FLAG = v_action_flag
8363 and jut.header = v_header
8364 union all
8365 select terr_id, user_sequence,
8366 terr_qual_id45 terr_qual_id,
8367 45 qual_num, QUAL45_VALUE_ID qual_value_id,
8368 QUAL45_VALUE1 qual_valUE1,
8369 QUAL45_VALUE2 qual_valUE2,
8370 QUAL45_VALUE3 qual_valUE3, ORG_ID,
8371 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8372 CREATED_BY, CREATION_DATE
8373 FROM JTY_WEBADI_OTH_TERR_INTF jut
8374 where jut.USER_SEQUENCE = v_user_sequence
8375 and jut.status is null
8376 and jut.terr_qual_id45 is not null
8377 and jut.QUAL45_VALUE_ID is not null
8378 and jut.QUAL45_value1 is not null
8379 and jut.INTERFACE_TYPE = v_intf_type
8380 AND jut.ACTION_FLAG = v_action_flag
8381 and jut.header = v_header
8382 union all
8383 select terr_id, user_sequence,
8384 terr_qual_id46 terr_qual_id,
8385 46 qual_num, QUAL46_VALUE_ID qual_value_id,
8386 QUAL46_VALUE1 qual_VALUE1,
8387 QUAL46_VALUE2 qual_VALUE2,
8388 QUAL46_VALUE3 qual_VALUE3, ORG_ID,
8389 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8390 CREATED_BY, CREATION_DATE
8391 FROM JTY_WEBADI_OTH_TERR_INTF jut
8392 where jut.USER_SEQUENCE = v_user_sequence
8393 and jut.status is null
8394 and jut.terr_qual_id46 is not null
8395 and jut.QUAL46_VALUE_ID is not null
8396 and jut.QUAL46_value1 is not null
8397 and jut.INTERFACE_TYPE = v_intf_type
8398 AND jut.ACTION_FLAG = v_action_flag
8399 and jut.header = v_header
8400 union all
8401 select terr_id, user_sequence,
8402 terr_qual_id47 terr_qual_id,
8403 47 qual_num, QUAL47_VALUE_ID qual_value_id,
8404 QUAL47_VALUE1 qual_VALUE1,
8405 QUAL47_VALUE2 qual_VALUE2,
8406 QUAL47_VALUE3 qual_VALUE3, ORG_ID,
8407 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8408 CREATED_BY, CREATION_DATE
8409 FROM JTY_WEBADI_OTH_TERR_INTF jut
8410 where jut.USER_SEQUENCE = v_user_sequence
8411 and jut.status is null
8412 and jut.terr_qual_id47 is not null
8413 and jut.QUAL47_VALUE_ID is not null
8414 and jut.QUAL47_value1 is not null
8415 and jut.INTERFACE_TYPE = v_intf_type
8416 AND jut.ACTION_FLAG = v_action_flag
8417 and jut.header = v_header
8418 union all
8419 select terr_id, user_sequence,
8420 terr_qual_id48 terr_qual_id,
8421 48 qual_num, QUAL48_VALUE_ID qual_value_id,
8422 QUAL48_VALUE1 qual_VALUE1,
8423 QUAL48_VALUE2 qual_VALUE2,
8424 QUAL48_VALUE3 qual_VALUE3, ORG_ID,
8425 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8426 CREATED_BY, CREATION_DATE
8427 FROM JTY_WEBADI_OTH_TERR_INTF jut
8428 where jut.USER_SEQUENCE = v_user_sequence
8429 and jut.status is null
8430 and jut.terr_qual_id48 is not null
8431 and jut.QUAL48_VALUE_ID is not null
8432 and jut.QUAL48_value1 is not null
8433 and jut.INTERFACE_TYPE = v_intf_type
8434 AND jut.ACTION_FLAG = v_action_flag
8435 and jut.header = v_header
8436 union all
8437 select terr_id, user_sequence,
8438 terr_qual_id49 terr_qual_id,
8439 49 qual_num, QUAL49_VALUE_ID qual_value_id,
8440 QUAL49_VALUE1 qual_VALUE1,
8441 QUAL49_VALUE2 qual_VALUE2,
8442 QUAL49_VALUE3 qual_VALUE3, ORG_ID,
8443 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8444 CREATED_BY, CREATION_DATE
8445 FROM JTY_WEBADI_OTH_TERR_INTF jut
8446 where jut.USER_SEQUENCE = v_user_sequence
8447 and jut.status is null
8448 and jut.terr_qual_id49 is not null
8449 and jut.QUAL49_VALUE_ID is not null
8450 and jut.QUAL49_value1 is not null
8451 and jut.INTERFACE_TYPE = v_intf_type
8452 AND jut.ACTION_FLAG = v_action_flag
8453 and jut.header = v_header
8454 union all
8455 select terr_id, user_sequence,
8456 terr_qual_id50 terr_qual_id,
8457 50 qual_num, QUAL50_VALUE_ID qual_value_id,
8458 QUAL50_VALUE1 qual_VALUE1,
8459 QUAL50_VALUE2 qual_VALUE2,
8460 QUAL50_VALUE3 qual_VALUE3, ORG_ID,
8461 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8462 CREATED_BY, CREATION_DATE
8463 FROM JTY_WEBADI_OTH_TERR_INTF jut
8464 where jut.USER_SEQUENCE = v_user_sequence
8465 and jut.status is null
8466 and jut.terr_qual_id50 is not null
8467 and jut.QUAL50_VALUE_ID is not null
8468 and jut.QUAL50_value1 is not null
8469 and jut.INTERFACE_TYPE = v_intf_type
8470 AND jut.ACTION_FLAG = v_action_flag
8471 and jut.header = v_header
8472 union all
8473 select terr_id, user_sequence,
8474 terr_qual_id51 terr_qual_id,
8475 51 qual_num, QUAL51_VALUE_ID qual_value_id,
8476 QUAL51_VALUE1 qual_VALUE1,
8477 QUAL51_VALUE2 qual_VALUE2,
8478 QUAL51_VALUE3 qual_VALUE3, ORG_ID,
8479 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8480 CREATED_BY, CREATION_DATE
8481 FROM JTY_WEBADI_OTH_TERR_INTF jut
8482 where jut.USER_SEQUENCE = v_user_sequence
8483 and jut.status is null
8484 and jut.terr_qual_id51 is not null
8485 and jut.QUAL51_VALUE_ID is not null
8486 and jut.QUAL51_value1 is not null
8487 and jut.INTERFACE_TYPE = v_intf_type
8488 AND jut.ACTION_FLAG = v_action_flag
8489 and jut.header = v_header
8490 union all
8491 select terr_id, user_sequence,
8492 terr_qual_id52 terr_qual_id,
8493 52 qual_num, QUAL52_VALUE_ID qual_value_id,
8494 QUAL52_VALUE1 qual_VALUE1,
8495 QUAL52_VALUE2 qual_VALUE2,
8496 QUAL52_VALUE3 qual_VALUE3, ORG_ID,
8497 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8498 CREATED_BY, CREATION_DATE
8499 FROM JTY_WEBADI_OTH_TERR_INTF jut
8500 where jut.USER_SEQUENCE = v_user_sequence
8501 and jut.status is null
8502 and jut.terr_qual_id52 is not null
8503 and jut.QUAL52_VALUE_ID is not null
8504 and jut.QUAL52_value1 is not null
8505 and jut.INTERFACE_TYPE = v_intf_type
8506 AND jut.ACTION_FLAG = v_action_flag
8507 and jut.header = v_header
8508 union all
8509 select terr_id, user_sequence,
8510 terr_qual_id53 terr_qual_id,
8511 53 qual_num, QUAL53_VALUE_ID qual_value_id,
8512 QUAL53_VALUE1 qual_VALUE1,
8513 QUAL53_VALUE2 qual_VALUE2,
8514 QUAL53_VALUE3 qual_VALUE3, ORG_ID,
8515 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8516 CREATED_BY, CREATION_DATE
8517 FROM JTY_WEBADI_OTH_TERR_INTF jut
8518 where jut.USER_SEQUENCE = v_user_sequence
8519 and jut.status is null
8520 and jut.terr_qual_id53 is not null
8521 and jut.QUAL53_VALUE_ID is not null
8522 and jut.QUAL53_value1 is not null
8523 and jut.INTERFACE_TYPE = v_intf_type
8524 AND jut.ACTION_FLAG = v_action_flag
8525 and jut.header = v_header
8526 union all
8527 select terr_id, user_sequence,
8528 terr_qual_id54 terr_qual_id,
8529 54 qual_num, QUAL54_VALUE_ID qual_value_id,
8530 QUAL54_VALUE1 qual_VALUE1,
8531 QUAL54_VALUE2 qual_VALUE2,
8532 QUAL54_VALUE3 qual_VALUE3, ORG_ID,
8533 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8534 CREATED_BY, CREATION_DATE
8535 FROM JTY_WEBADI_OTH_TERR_INTF jut
8536 where jut.USER_SEQUENCE = v_user_sequence
8537 and jut.status is null
8538 and jut.terr_qual_id54 is not null
8539 and jut.QUAL54_VALUE_ID is not null
8540 and jut.QUAL54_value1 is not null
8541 and jut.INTERFACE_TYPE = v_intf_type
8542 AND jut.ACTION_FLAG = v_action_flag
8543 and jut.header = v_header
8544 union all
8545 select terr_id, user_sequence,
8546 terr_qual_id55 terr_qual_id,
8547 55 qual_num, QUAL55_VALUE_ID qual_value_id,
8548 QUAL55_VALUE1 qual_valUE1,
8549 QUAL55_VALUE2 qual_valUE2,
8550 QUAL55_VALUE3 qual_valUE3, ORG_ID,
8551 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8552 CREATED_BY, CREATION_DATE
8553 FROM JTY_WEBADI_OTH_TERR_INTF jut
8554 where jut.USER_SEQUENCE = v_user_sequence
8555 and jut.status is null
8556 and jut.terr_qual_id55 is not null
8557 and jut.QUAL55_VALUE_ID is not null
8558 and jut.QUAL55_value1 is not null
8559 and jut.INTERFACE_TYPE = v_intf_type
8560 AND jut.ACTION_FLAG = v_action_flag
8561 and jut.header = v_header
8562 union all
8563 select terr_id, user_sequence,
8564 terr_qual_id56 terr_qual_id,
8565 56 qual_num, QUAL56_VALUE_ID qual_value_id,
8566 QUAL56_VALUE1 qual_VALUE1,
8567 QUAL56_VALUE2 qual_VALUE2,
8568 QUAL56_VALUE3 qual_VALUE3, ORG_ID,
8569 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8570 CREATED_BY, CREATION_DATE
8571 FROM JTY_WEBADI_OTH_TERR_INTF jut
8572 where jut.USER_SEQUENCE = v_user_sequence
8573 and jut.status is null
8574 and jut.terr_qual_id56 is not null
8575 and jut.QUAL56_VALUE_ID is not null
8576 and jut.QUAL56_value1 is not null
8577 and jut.INTERFACE_TYPE = v_intf_type
8578 AND jut.ACTION_FLAG = v_action_flag
8579 and jut.header = v_header
8580 union all
8581 select terr_id, user_sequence,
8582 terr_qual_id57 terr_qual_id,
8583 57 qual_num, QUAL57_VALUE_ID qual_value_id,
8584 QUAL57_VALUE1 qual_VALUE1,
8585 QUAL57_VALUE2 qual_VALUE2,
8586 QUAL57_VALUE3 qual_VALUE3, ORG_ID,
8587 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8588 CREATED_BY, CREATION_DATE
8589 FROM JTY_WEBADI_OTH_TERR_INTF jut
8590 where jut.USER_SEQUENCE = v_user_sequence
8591 and jut.status is null
8592 and jut.terr_qual_id57 is not null
8593 and jut.QUAL57_VALUE_ID is not null
8594 and jut.QUAL57_value1 is not null
8595 and jut.INTERFACE_TYPE = v_intf_type
8596 AND jut.ACTION_FLAG = v_action_flag
8597 and jut.header = v_header
8598 union all
8599 select terr_id, user_sequence,
8600 terr_qual_id58 terr_qual_id,
8601 58 qual_num, QUAL58_VALUE_ID qual_value_id,
8602 QUAL58_VALUE1 qual_VALUE1,
8603 QUAL58_VALUE2 qual_VALUE2,
8604 QUAL58_VALUE3 qual_VALUE3, ORG_ID,
8605 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8606 CREATED_BY, CREATION_DATE
8607 FROM JTY_WEBADI_OTH_TERR_INTF jut
8608 where jut.USER_SEQUENCE = v_user_sequence
8609 and jut.status is null
8610 and jut.terr_qual_id58 is not null
8611 and jut.QUAL58_VALUE_ID is not null
8612 and jut.QUAL58_value1 is not null
8613 and jut.INTERFACE_TYPE = v_intf_type
8614 AND jut.ACTION_FLAG = v_action_flag
8615 and jut.header = v_header
8616 union all
8617 select terr_id, user_sequence,
8618 terr_qual_id59 terr_qual_id,
8619 59 qual_num, QUAL59_VALUE_ID qual_value_id,
8620 QUAL59_VALUE1 qual_VALUE1,
8621 QUAL59_VALUE2 qual_VALUE2,
8622 QUAL59_VALUE3 qual_VALUE3, ORG_ID,
8623 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8624 CREATED_BY, CREATION_DATE
8625 FROM JTY_WEBADI_OTH_TERR_INTF jut
8626 where jut.USER_SEQUENCE = v_user_sequence
8627 and jut.status is null
8628 and jut.terr_qual_id59 is not null
8629 and jut.QUAL59_VALUE_ID is not null
8630 and jut.QUAL59_value1 is not null
8631 and jut.INTERFACE_TYPE = v_intf_type
8632 AND jut.ACTION_FLAG = v_action_flag
8633 and jut.header = v_header
8634 union all
8635 select terr_id, user_sequence,
8636 terr_qual_id60 terr_qual_id,
8637 60 qual_num, QUAL60_VALUE_ID qual_value_id,
8638 QUAL60_VALUE1 qual_VALUE1,
8639 QUAL60_VALUE2 qual_VALUE2,
8640 QUAL60_VALUE3 qual_VALUE3, ORG_ID,
8641 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8642 CREATED_BY, CREATION_DATE
8643 FROM JTY_WEBADI_OTH_TERR_INTF jut
8644 where jut.USER_SEQUENCE = v_user_sequence
8645 and jut.status is null
8646 and jut.terr_qual_id60 is not null
8647 and jut.QUAL60_VALUE_ID is not null
8648 and jut.QUAL60_value1 is not null
8649 and jut.INTERFACE_TYPE = v_intf_type
8650 AND jut.ACTION_FLAG = v_action_flag
8651 and jut.header = v_header
8652 union all
8653 select terr_id, user_sequence,
8654 terr_qual_id61 terr_qual_id,
8655 61 qual_num, QUAL61_VALUE_ID qual_value_id,
8656 QUAL61_VALUE1 qual_VALUE1,
8657 QUAL61_VALUE2 qual_VALUE2,
8658 QUAL61_VALUE3 qual_VALUE3, ORG_ID,
8659 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8660 CREATED_BY, CREATION_DATE
8661 FROM JTY_WEBADI_OTH_TERR_INTF jut
8662 where jut.USER_SEQUENCE = v_user_sequence
8663 and jut.status is null
8664 and jut.terr_qual_id61 is not null
8665 and jut.QUAL61_VALUE_ID is not null
8666 and jut.QUAL61_value1 is not null
8667 and jut.INTERFACE_TYPE = v_intf_type
8668 AND jut.ACTION_FLAG = v_action_flag
8669 and jut.header = v_header
8670 union all
8671 select terr_id, user_sequence,
8672 terr_qual_id62 terr_qual_id,
8673 62 qual_num, QUAL62_VALUE_ID qual_value_id,
8674 QUAL62_VALUE1 qual_VALUE1,
8675 QUAL62_VALUE2 qual_VALUE2,
8676 QUAL62_VALUE3 qual_VALUE3, ORG_ID,
8677 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8678 CREATED_BY, CREATION_DATE
8679 FROM JTY_WEBADI_OTH_TERR_INTF jut
8680 where jut.USER_SEQUENCE = v_user_sequence
8681 and jut.status is null
8682 and jut.terr_qual_id62 is not null
8683 and jut.QUAL62_VALUE_ID is not null
8684 and jut.QUAL62_value1 is not null
8685 and jut.INTERFACE_TYPE = v_intf_type
8686 AND jut.ACTION_FLAG = v_action_flag
8687 and jut.header = v_header
8688 union all
8689 select terr_id, user_sequence,
8690 terr_qual_id63 terr_qual_id,
8691 63 qual_num, QUAL63_VALUE_ID qual_value_id,
8692 QUAL63_VALUE1 qual_VALUE1,
8693 QUAL63_VALUE2 qual_VALUE2,
8694 QUAL63_VALUE3 qual_VALUE3, ORG_ID,
8695 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8696 CREATED_BY, CREATION_DATE
8697 FROM JTY_WEBADI_OTH_TERR_INTF jut
8698 where jut.USER_SEQUENCE = v_user_sequence
8699 and jut.status is null
8700 and jut.terr_qual_id63 is not null
8701 and jut.QUAL63_VALUE_ID is not null
8702 and jut.QUAL63_value1 is not null
8703 and jut.INTERFACE_TYPE = v_intf_type
8704 AND jut.ACTION_FLAG = v_action_flag
8705 and jut.header = v_header
8706 union all
8707 select terr_id, user_sequence,
8708 terr_qual_id64 terr_qual_id,
8709 64 qual_num, QUAL64_VALUE_ID qual_value_id,
8710 QUAL64_VALUE1 qual_VALUE1,
8711 QUAL64_VALUE2 qual_VALUE2,
8712 QUAL64_VALUE3 qual_VALUE3, ORG_ID,
8713 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8714 CREATED_BY, CREATION_DATE
8715 FROM JTY_WEBADI_OTH_TERR_INTF jut
8716 where jut.USER_SEQUENCE = v_user_sequence
8717 and jut.status is null
8718 and jut.terr_qual_id64 is not null
8719 and jut.QUAL64_VALUE_ID is not null
8720 and jut.QUAL64_value1 is not null
8721 and jut.INTERFACE_TYPE = v_intf_type
8722 AND jut.ACTION_FLAG = v_action_flag
8723 and jut.header = v_header
8724 union all
8725 select terr_id, user_sequence,
8726 terr_qual_id65 terr_qual_id,
8727 65 qual_num, QUAL65_VALUE_ID qual_value_id,
8728 QUAL65_VALUE1 qual_valUE1,
8729 QUAL65_VALUE2 qual_valUE2,
8730 QUAL65_VALUE3 qual_valUE3, ORG_ID,
8731 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8732 CREATED_BY, CREATION_DATE
8733 FROM JTY_WEBADI_OTH_TERR_INTF jut
8734 where jut.USER_SEQUENCE = v_user_sequence
8735 and jut.status is null
8736 and jut.terr_qual_id65 is not null
8737 and jut.QUAL65_VALUE_ID is not null
8738 and jut.QUAL65_value1 is not null
8739 and jut.INTERFACE_TYPE = v_intf_type
8740 AND jut.ACTION_FLAG = v_action_flag
8741 and jut.header = v_header
8742 union all
8743 select terr_id, user_sequence,
8744 terr_qual_id66 terr_qual_id,
8745 66 qual_num, QUAL66_VALUE_ID qual_value_id,
8746 QUAL66_VALUE1 qual_VALUE1,
8747 QUAL66_VALUE2 qual_VALUE2,
8748 QUAL66_VALUE3 qual_VALUE3, ORG_ID,
8749 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8750 CREATED_BY, CREATION_DATE
8751 FROM JTY_WEBADI_OTH_TERR_INTF jut
8752 where jut.USER_SEQUENCE = v_user_sequence
8753 and jut.status is null
8754 and jut.terr_qual_id66 is not null
8755 and jut.QUAL66_VALUE_ID is not null
8756 and jut.QUAL66_value1 is not null
8757 and jut.INTERFACE_TYPE = v_intf_type
8758 AND jut.ACTION_FLAG = v_action_flag
8759 and jut.header = v_header
8760 union all
8761 select terr_id, user_sequence,
8762 terr_qual_id67 terr_qual_id,
8763 67 qual_num, QUAL67_VALUE_ID qual_value_id,
8764 QUAL67_VALUE1 qual_VALUE1,
8765 QUAL67_VALUE2 qual_VALUE2,
8766 QUAL67_VALUE3 qual_VALUE3, ORG_ID,
8767 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8768 CREATED_BY, CREATION_DATE
8769 FROM JTY_WEBADI_OTH_TERR_INTF jut
8770 where jut.USER_SEQUENCE = v_user_sequence
8771 and jut.status is null
8772 and jut.terr_qual_id67 is not null
8773 and jut.QUAL67_VALUE_ID is not null
8774 and jut.QUAL67_value1 is not null
8775 and jut.INTERFACE_TYPE = v_intf_type
8776 AND jut.ACTION_FLAG = v_action_flag
8777 and jut.header = v_header
8778 union all
8779 select terr_id, user_sequence,
8780 terr_qual_id68 terr_qual_id,
8781 68 qual_num, QUAL68_VALUE_ID qual_value_id,
8782 QUAL68_VALUE1 qual_VALUE1,
8783 QUAL68_VALUE2 qual_VALUE2,
8784 QUAL68_VALUE3 qual_VALUE3, ORG_ID,
8785 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8786 CREATED_BY, CREATION_DATE
8787 FROM JTY_WEBADI_OTH_TERR_INTF jut
8788 where jut.USER_SEQUENCE = v_user_sequence
8789 and jut.status is null
8790 and jut.terr_qual_id68 is not null
8791 and jut.QUAL68_VALUE_ID is not null
8792 and jut.QUAL68_value1 is not null
8793 and jut.INTERFACE_TYPE = v_intf_type
8794 AND jut.ACTION_FLAG = v_action_flag
8795 and jut.header = v_header
8796 union all
8797 select terr_id, user_sequence,
8798 terr_qual_id69 terr_qual_id,
8799 69 qual_num, QUAL69_VALUE_ID qual_value_id,
8800 QUAL69_VALUE1 qual_VALUE1,
8801 QUAL69_VALUE2 qual_VALUE2,
8802 QUAL69_VALUE3 qual_VALUE3, ORG_ID,
8803 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8804 CREATED_BY, CREATION_DATE
8805 FROM JTY_WEBADI_OTH_TERR_INTF jut
8806 where jut.USER_SEQUENCE = v_user_sequence
8807 and jut.status is null
8808 and jut.terr_qual_id69 is not null
8809 and jut.QUAL69_VALUE_ID is not null
8810 and jut.QUAL69_value1 is not null
8811 and jut.INTERFACE_TYPE = v_intf_type
8812 AND jut.ACTION_FLAG = v_action_flag
8813 and jut.header = v_header
8814 union all
8815 select terr_id, user_sequence,
8816 terr_qual_id70 terr_qual_id,
8817 70 qual_num, QUAL70_VALUE_ID qual_value_id,
8818 QUAL70_VALUE1 qual_VALUE1,
8819 QUAL70_VALUE2 qual_VALUE2,
8820 QUAL70_VALUE3 qual_VALUE3, ORG_ID,
8821 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8822 CREATED_BY, CREATION_DATE
8823 FROM JTY_WEBADI_OTH_TERR_INTF jut
8824 where jut.USER_SEQUENCE = v_user_sequence
8825 and jut.status is null
8826 and jut.terr_qual_id70 is not null
8827 and jut.QUAL70_VALUE_ID is not null
8828 and jut.QUAL70_value1 is not null
8829 and jut.INTERFACE_TYPE = v_intf_type
8830 AND jut.ACTION_FLAG = v_action_flag
8831 and jut.header = v_header
8832 union all
8833 select terr_id, user_sequence,
8834 terr_qual_id71 terr_qual_id,
8835 71 qual_num, QUAL71_VALUE_ID qual_value_id,
8836 QUAL71_VALUE1 qual_VALUE1,
8837 QUAL71_VALUE2 qual_VALUE2,
8838 QUAL71_VALUE3 qual_VALUE3, ORG_ID,
8839 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8840 CREATED_BY, CREATION_DATE
8841 FROM JTY_WEBADI_OTH_TERR_INTF jut
8842 where jut.USER_SEQUENCE = v_user_sequence
8843 and jut.status is null
8844 and jut.terr_qual_id71 is not null
8845 and jut.QUAL71_VALUE_ID is not null
8846 and jut.QUAL71_value1 is not null
8847 and jut.INTERFACE_TYPE = v_intf_type
8848 AND jut.ACTION_FLAG = v_action_flag
8849 and jut.header = v_header
8850 union all
8851 select terr_id, user_sequence,
8852 terr_qual_id72 terr_qual_id,
8853 72 qual_num, QUAL72_VALUE_ID qual_value_id,
8854 QUAL72_VALUE1 qual_VALUE1,
8855 QUAL72_VALUE2 qual_VALUE2,
8856 QUAL72_VALUE3 qual_VALUE3, ORG_ID,
8857 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8858 CREATED_BY, CREATION_DATE
8859 FROM JTY_WEBADI_OTH_TERR_INTF jut
8860 where jut.USER_SEQUENCE = v_user_sequence
8861 and jut.status is null
8862 and jut.terr_qual_id72 is not null
8863 and jut.QUAL72_VALUE_ID is not null
8864 and jut.QUAL72_value1 is not null
8865 and jut.INTERFACE_TYPE = v_intf_type
8866 AND jut.ACTION_FLAG = v_action_flag
8867 and jut.header = v_header
8868 union all
8869 select terr_id, user_sequence,
8870 terr_qual_id73 terr_qual_id,
8871 73 qual_num, QUAL73_VALUE_ID qual_value_id,
8872 QUAL73_VALUE1 qual_VALUE1,
8873 QUAL73_VALUE2 qual_VALUE2,
8874 QUAL73_VALUE3 qual_VALUE3, ORG_ID,
8875 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8876 CREATED_BY, CREATION_DATE
8877 FROM JTY_WEBADI_OTH_TERR_INTF jut
8878 where jut.USER_SEQUENCE = v_user_sequence
8879 and jut.status is null
8880 and jut.terr_qual_id73 is not null
8881 and jut.QUAL73_VALUE_ID is not null
8882 and jut.QUAL73_value1 is not null
8883 and jut.INTERFACE_TYPE = v_intf_type
8884 AND jut.ACTION_FLAG = v_action_flag
8885 and jut.header = v_header
8886 union all
8887 select terr_id, user_sequence,
8888 terr_qual_id74 terr_qual_id,
8889 74 qual_num, QUAL74_VALUE_ID qual_value_id,
8890 QUAL74_VALUE1 qual_VALUE1,
8891 QUAL74_VALUE2 qual_VALUE2,
8892 QUAL74_VALUE3 qual_VALUE3, ORG_ID,
8893 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8894 CREATED_BY, CREATION_DATE
8895 FROM JTY_WEBADI_OTH_TERR_INTF jut
8896 where jut.USER_SEQUENCE = v_user_sequence
8897 and jut.status is null
8898 and jut.terr_qual_id74 is not null
8899 and jut.QUAL74_VALUE_ID is not null
8900 and jut.QUAL74_value1 is not null
8901 and jut.INTERFACE_TYPE = v_intf_type
8902 AND jut.ACTION_FLAG = v_action_flag
8903 and jut.header = v_header
8904 union all
8905 select terr_id, user_sequence,
8906 terr_qual_id75 terr_qual_id,
8907 75 qual_num, QUAL75_VALUE_ID qual_value_id,
8908 QUAL75_VALUE1 qual_valUE1,
8909 QUAL75_VALUE2 qual_valUE2,
8910 QUAL75_VALUE3 qual_valUE3, ORG_ID,
8911 LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN,
8912 CREATED_BY, CREATION_DATE
8913 FROM JTY_WEBADI_OTH_TERR_INTF jut
8914 where jut.USER_SEQUENCE = v_user_sequence
8915 and jut.status is null
8916 and jut.terr_qual_id75 is not null
8917 and jut.QUAL75_VALUE_ID is not null
8918 and jut.QUAL75_value1 is not null
8919 and jut.INTERFACE_TYPE = v_intf_type
8920 AND jut.ACTION_FLAG = v_action_flag
8921 and jut.header = v_header
8922 ) sub
8923 where jq.user_sequence = sub.user_sequence
8924 and jq.qualifier_num = sub.qual_num;
8925
8926 CURSOR get_d_terr_value_csr(
8927 v_user_sequence number,
8928 v_action_flag varchar2,
8929 v_intf_type varchar2,
8930 v_header varchar2) IS
8931 select sub.TERR_QUAL_ID, sub.terr_id, sub.qual_value_id,
8932 sub.qual_num
8933 from (
8934 select terr_id, user_sequence,
8935 terr_qual_id1 terr_qual_id,
8936 1 qual_num, QUAL1_VALUE_ID qual_value_id
8937 FROM JTY_WEBADI_OTH_TERR_INTF jut
8938 where jut.USER_SEQUENCE = v_user_sequence
8939 and jut.status is null
8940 and jut.terr_qual_id1 is not null
8941 and jut.QUAL1_VALUE_ID is not null
8942 and jut.qual1_value1 is null
8943 and jut.INTERFACE_TYPE = v_intf_type
8944 AND jut.ACTION_FLAG = v_action_flag
8945 and jut.header = v_header
8946 union all
8947 select terr_id, user_sequence,
8948 terr_qual_id2 terr_qual_id,
8949 2 qual_num, QUAL2_VALUE_ID qual_value_id
8950 FROM JTY_WEBADI_OTH_TERR_INTF jut
8951 where jut.USER_SEQUENCE = v_user_sequence
8952 and jut.status is null
8953 and jut.terr_qual_id2 is not null
8954 and jut.QUAL2_VALUE_ID is not null
8955 and jut.qual2_value1 is null
8956 and jut.INTERFACE_TYPE = v_intf_type
8957 AND jut.ACTION_FLAG = v_action_flag
8958 and jut.header = v_header
8959 union all
8960 select terr_id, user_sequence,
8961 terr_qual_id3 terr_qual_id,
8962 3 qual_num, QUAL3_VALUE_ID qual_value_id
8963 FROM JTY_WEBADI_OTH_TERR_INTF jut
8964 where jut.USER_SEQUENCE = v_user_sequence
8965 and jut.status is null
8966 and jut.terr_qual_id3 is not null
8967 and jut.QUAL3_VALUE_ID is not null
8968 and jut.qual3_value1 is null
8969 and jut.INTERFACE_TYPE = v_intf_type
8970 AND jut.ACTION_FLAG = v_action_flag
8971 and jut.header = v_header
8972 union all
8973 select terr_id, user_sequence,
8974 terr_qual_id4 terr_qual_id,
8975 4 qual_num, QUAL4_VALUE_ID qual_value_id
8976 FROM JTY_WEBADI_OTH_TERR_INTF jut
8977 where jut.USER_SEQUENCE = v_user_sequence
8978 and jut.status is null
8979 and jut.terr_qual_id4 is not null
8980 and jut.QUAL4_VALUE_ID is not null
8981 and jut.qual4_value1 is null
8982 and jut.INTERFACE_TYPE = v_intf_type
8983 AND jut.ACTION_FLAG = v_action_flag
8984 and jut.header = v_header
8985 union all
8986 select terr_id, user_sequence,
8987 terr_qual_id5 terr_qual_id,
8988 5 qual_num, QUAL5_VALUE_ID qual_value_id
8989 FROM JTY_WEBADI_OTH_TERR_INTF jut
8990 where jut.USER_SEQUENCE = v_user_sequence
8991 and jut.status is null
8992 and jut.terr_qual_id5 is not null
8993 and jut.QUAL5_VALUE_ID is not null
8994 and jut.qual5_value1 is null
8995 and jut.INTERFACE_TYPE = v_intf_type
8996 AND jut.ACTION_FLAG = v_action_flag
8997 and jut.header = v_header
8998 union all
8999 select terr_id, user_sequence,
9000 terr_qual_id6 terr_qual_id,
9001 6 qual_num, QUAL6_VALUE_ID qual_value_id
9002 FROM JTY_WEBADI_OTH_TERR_INTF jut
9003 where jut.USER_SEQUENCE = v_user_sequence
9004 and jut.status is null
9005 and jut.terr_qual_id6 is not null
9006 and jut.QUAL6_VALUE_ID is not null
9007 and jut.qual6_value1 is null
9008 and jut.INTERFACE_TYPE = v_intf_type
9009 AND jut.ACTION_FLAG = v_action_flag
9010 and jut.header = v_header
9011 union all
9012 select terr_id, user_sequence,
9013 terr_qual_id7 terr_qual_id,
9014 7 qual_num, QUAL7_VALUE_ID qual_value_id
9015 FROM JTY_WEBADI_OTH_TERR_INTF jut
9016 where jut.USER_SEQUENCE = v_user_sequence
9017 and jut.status is null
9018 and jut.terr_qual_id7 is not null
9019 and jut.QUAL7_VALUE_ID is not null
9020 and jut.qual7_value1 is null
9021 and jut.INTERFACE_TYPE = v_intf_type
9022 AND jut.ACTION_FLAG = v_action_flag
9023 and jut.header = v_header
9024 union all
9025 select terr_id, user_sequence,
9026 terr_qual_id8 terr_qual_id,
9027 8 qual_num, QUAL8_VALUE_ID qual_value_id
9028 FROM JTY_WEBADI_OTH_TERR_INTF jut
9029 where jut.USER_SEQUENCE = v_user_sequence
9030 and jut.status is null
9031 and jut.terr_qual_id8 is not null
9032 and jut.QUAL8_VALUE_ID is not null
9033 and jut.qual8_value1 is null
9034 and jut.INTERFACE_TYPE = v_intf_type
9035 AND jut.ACTION_FLAG = v_action_flag
9036 and jut.header = v_header
9037 union all
9038 select terr_id, user_sequence,
9039 terr_qual_id9 terr_qual_id,
9040 9 qual_num, QUAL9_VALUE_ID qual_value_id
9041 FROM JTY_WEBADI_OTH_TERR_INTF jut
9042 where jut.USER_SEQUENCE = v_user_sequence
9043 and jut.status is null
9044 and jut.terr_qual_id9 is not null
9045 and jut.QUAL9_VALUE_ID is not null
9046 and jut.qual9_value1 is null
9047 and jut.INTERFACE_TYPE = v_intf_type
9048 AND jut.ACTION_FLAG = v_action_flag
9049 and jut.header = v_header
9050 union all
9051 select terr_id, user_sequence,
9052 terr_qual_id10 terr_qual_id,
9053 10 qual_num, QUAL10_VALUE_ID qual_value_id
9054 FROM JTY_WEBADI_OTH_TERR_INTF jut
9055 where jut.USER_SEQUENCE = v_user_sequence
9056 and jut.status is null
9057 and jut.terr_qual_id10 is not null
9058 and jut.QUAL10_VALUE_ID is not null
9059 and jut.qual10_value1 is null
9060 and jut.INTERFACE_TYPE = v_intf_type
9061 AND jut.ACTION_FLAG = v_action_flag
9062 and jut.header = v_header
9063 union all
9064 select terr_id, user_sequence,
9065 terr_qual_id11 terr_qual_id,
9066 11 qual_num, QUAL11_VALUE_ID qual_value_id
9067 FROM JTY_WEBADI_OTH_TERR_INTF jut
9068 where jut.USER_SEQUENCE = v_user_sequence
9069 and jut.status is null
9070 and jut.terr_qual_id11 is not null
9071 and jut.QUAL11_VALUE_ID is not null
9072 and jut.qual11_value1 is null
9073 and jut.INTERFACE_TYPE = v_intf_type
9074 AND jut.ACTION_FLAG = v_action_flag
9075 and jut.header = v_header
9076 union all
9077 select terr_id, user_sequence,
9078 terr_qual_id12 terr_qual_id,
9079 12 qual_num, QUAL12_VALUE_ID qual_value_id
9080 FROM JTY_WEBADI_OTH_TERR_INTF jut
9081 where jut.USER_SEQUENCE = v_user_sequence
9082 and jut.status is null
9083 and jut.terr_qual_id12 is not null
9084 and jut.QUAL12_VALUE_ID is not null
9085 and jut.qual12_value1 is null
9086 and jut.INTERFACE_TYPE = v_intf_type
9087 AND jut.ACTION_FLAG = v_action_flag
9088 and jut.header = v_header
9089 union all
9090 select terr_id, user_sequence,
9091 terr_qual_id13 terr_qual_id,
9092 13 qual_num, QUAL13_VALUE_ID qual_value_id
9093 FROM JTY_WEBADI_OTH_TERR_INTF jut
9094 where jut.USER_SEQUENCE = v_user_sequence
9095 and jut.status is null
9096 and jut.terr_qual_id13 is not null
9097 and jut.QUAL13_VALUE_ID is not null
9098 and jut.qual13_value1 is null
9099 and jut.INTERFACE_TYPE = v_intf_type
9100 AND jut.ACTION_FLAG = v_action_flag
9101 and jut.header = v_header
9102 union all
9103 select terr_id, user_sequence,
9104 terr_qual_id14 terr_qual_id,
9105 14 qual_num, QUAL14_VALUE_ID qual_value_id
9106 FROM JTY_WEBADI_OTH_TERR_INTF jut
9107 where jut.USER_SEQUENCE = v_user_sequence
9108 and jut.status is null
9109 and jut.terr_qual_id14 is not null
9110 and jut.QUAL14_VALUE_ID is not null
9111 and jut.qual14_value1 is null
9112 and jut.INTERFACE_TYPE = v_intf_type
9113 AND jut.ACTION_FLAG = v_action_flag
9114 and jut.header = v_header
9115 union all
9116 select terr_id, user_sequence,
9117 terr_qual_id15 terr_qual_id,
9118 15 qual_num, QUAL15_VALUE_ID qual_value_id
9119 FROM JTY_WEBADI_OTH_TERR_INTF jut
9120 where jut.USER_SEQUENCE = v_user_sequence
9121 and jut.status is null
9122 and jut.terr_qual_id15 is not null
9123 and jut.QUAL15_VALUE_ID is not null
9124 and jut.qual15_value1 is null
9125 and jut.INTERFACE_TYPE = v_intf_type
9126 AND jut.ACTION_FLAG = v_action_flag
9127 and jut.header = v_header
9128 union all
9129 select terr_id, user_sequence,
9130 terr_qual_id16 terr_qual_id,
9131 16 qual_num, QUAL16_VALUE_ID qual_value_id
9132 FROM JTY_WEBADI_OTH_TERR_INTF jut
9133 where jut.USER_SEQUENCE = v_user_sequence
9134 and jut.status is null
9135 and jut.terr_qual_id16 is not null
9136 and jut.QUAL16_VALUE_ID is not null
9137 and jut.qual16_value1 is null
9138 and jut.INTERFACE_TYPE = v_intf_type
9139 AND jut.ACTION_FLAG = v_action_flag
9140 and jut.header = v_header
9141 union all
9142 select terr_id, user_sequence,
9143 terr_qual_id17 terr_qual_id,
9144 17 qual_num, QUAL17_VALUE_ID qual_value_id
9145 FROM JTY_WEBADI_OTH_TERR_INTF jut
9146 where jut.USER_SEQUENCE = v_user_sequence
9147 and jut.status is null
9148 and jut.terr_qual_id17 is not null
9149 and jut.QUAL17_VALUE_ID is not null
9150 and jut.qual17_value1 is null
9151 and jut.INTERFACE_TYPE = v_intf_type
9152 AND jut.ACTION_FLAG = v_action_flag
9153 and jut.header = v_header
9154 union all
9155 select terr_id, user_sequence,
9156 terr_qual_id18 terr_qual_id,
9157 18 qual_num, QUAL18_VALUE_ID qual_value_id
9158 FROM JTY_WEBADI_OTH_TERR_INTF jut
9159 where jut.USER_SEQUENCE = v_user_sequence
9160 and jut.status is null
9161 and jut.terr_qual_id18 is not null
9162 and jut.QUAL18_VALUE_ID is not null
9163 and jut.qual18_value1 is null
9164 and jut.INTERFACE_TYPE = v_intf_type
9165 AND jut.ACTION_FLAG = v_action_flag
9166 and jut.header = v_header
9167 union all
9168 select terr_id, user_sequence,
9169 terr_qual_id19 terr_qual_id,
9170 19 qual_num, QUAL19_VALUE_ID qual_value_id
9171 FROM JTY_WEBADI_OTH_TERR_INTF jut
9172 where jut.USER_SEQUENCE = v_user_sequence
9173 and jut.status is null
9174 and jut.terr_qual_id19 is not null
9175 and jut.QUAL19_VALUE_ID is not null
9176 and jut.qual19_value1 is null
9177 and jut.INTERFACE_TYPE = v_intf_type
9178 AND jut.ACTION_FLAG = v_action_flag
9179 and jut.header = v_header
9180 union all
9181 select terr_id, user_sequence,
9182 terr_qual_id20 terr_qual_id,
9183 20 qual_num, QUAL20_VALUE_ID qual_value_id
9184 FROM JTY_WEBADI_OTH_TERR_INTF jut
9185 where jut.USER_SEQUENCE = v_user_sequence
9186 and jut.status is null
9187 and jut.terr_qual_id20 is not null
9188 and jut.QUAL20_VALUE_ID is not null
9189 and jut.qual20_value1 is null
9190 and jut.INTERFACE_TYPE = v_intf_type
9191 AND jut.ACTION_FLAG = v_action_flag
9192 and jut.header = v_header
9193 union all
9194 select terr_id, user_sequence,
9195 terr_qual_id21 terr_qual_id,
9196 21 qual_num, QUAL21_VALUE_ID qual_value_id
9197 FROM JTY_WEBADI_OTH_TERR_INTF jut
9198 where jut.USER_SEQUENCE = v_user_sequence
9199 and jut.status is null
9200 and jut.terr_qual_id21 is not null
9201 and jut.QUAL21_VALUE_ID is not null
9202 and jut.qual21_value1 is null
9203 and jut.INTERFACE_TYPE = v_intf_type
9204 AND jut.ACTION_FLAG = v_action_flag
9205 and jut.header = v_header
9206 union all
9207 select terr_id, user_sequence,
9208 terr_qual_id22 terr_qual_id,
9209 22 qual_num, QUAL22_VALUE_ID qual_value_id
9210 FROM JTY_WEBADI_OTH_TERR_INTF jut
9211 where jut.USER_SEQUENCE = v_user_sequence
9212 and jut.status is null
9213 and jut.terr_qual_id22 is not null
9214 and jut.QUAL22_VALUE_ID is not null
9215 and jut.qual22_value1 is null
9216 and jut.INTERFACE_TYPE = v_intf_type
9217 AND jut.ACTION_FLAG = v_action_flag
9218 and jut.header = v_header
9219 union all
9220 select terr_id, user_sequence,
9221 terr_qual_id23 terr_qual_id,
9222 23 qual_num, QUAL23_VALUE_ID qual_value_id
9223 FROM JTY_WEBADI_OTH_TERR_INTF jut
9224 where jut.USER_SEQUENCE = v_user_sequence
9225 and jut.status is null
9226 and jut.terr_qual_id23 is not null
9227 and jut.QUAL23_VALUE_ID is not null
9228 and jut.qual23_value1 is null
9229 and jut.INTERFACE_TYPE = v_intf_type
9230 AND jut.ACTION_FLAG = v_action_flag
9231 and jut.header = v_header
9232 union all
9233 select terr_id, user_sequence,
9234 terr_qual_id24 terr_qual_id,
9235 24 qual_num, QUAL24_VALUE_ID qual_value_id
9236 FROM JTY_WEBADI_OTH_TERR_INTF jut
9237 where jut.USER_SEQUENCE = v_user_sequence
9238 and jut.status is null
9239 and jut.terr_qual_id24 is not null
9240 and jut.QUAL24_VALUE_ID is not null
9241 and jut.qual24_value1 is null
9242 and jut.INTERFACE_TYPE = v_intf_type
9243 AND jut.ACTION_FLAG = v_action_flag
9244 and jut.header = v_header
9245 union all
9246 select terr_id, user_sequence,
9247 terr_qual_id25 terr_qual_id,
9248 25 qual_num, QUAL25_VALUE_ID qual_value_id
9249 FROM JTY_WEBADI_OTH_TERR_INTF jut
9250 where jut.USER_SEQUENCE = v_user_sequence
9251 and jut.status is null
9252 and jut.terr_qual_id25 is not null
9253 and jut.QUAL25_VALUE_ID is not null
9254 and jut.qual25_value1 is null
9255 and jut.INTERFACE_TYPE = v_intf_type
9256 AND jut.ACTION_FLAG = v_action_flag
9257 and jut.header = v_header
9258 union all
9259 select terr_id, user_sequence,
9260 terr_qual_id26 terr_qual_id,
9261 26 qual_num, QUAL26_VALUE_ID qual_value_id
9262 FROM JTY_WEBADI_OTH_TERR_INTF jut
9263 where jut.USER_SEQUENCE = v_user_sequence
9264 and jut.status is null
9265 and jut.terr_qual_id26 is not null
9266 and jut.QUAL26_VALUE_ID is not null
9267 and jut.QUAL26_value1 is null
9268 and jut.INTERFACE_TYPE = v_intf_type
9269 AND jut.ACTION_FLAG = v_action_flag
9270 and jut.header = v_header
9271 union all
9272 select terr_id, user_sequence,
9273 terr_qual_id27 terr_qual_id,
9274 27 qual_num, QUAL27_VALUE_ID qual_value_id
9275 FROM JTY_WEBADI_OTH_TERR_INTF jut
9276 where jut.USER_SEQUENCE = v_user_sequence
9277 and jut.status is null
9278 and jut.terr_qual_id27 is not null
9279 and jut.QUAL27_VALUE_ID is not null
9280 and jut.QUAL27_value1 is null
9281 and jut.INTERFACE_TYPE = v_intf_type
9282 AND jut.ACTION_FLAG = v_action_flag
9283 and jut.header = v_header
9284 union all
9285 select terr_id, user_sequence,
9286 terr_qual_id28 terr_qual_id,
9287 28 qual_num, QUAL28_VALUE_ID qual_value_id
9288 FROM JTY_WEBADI_OTH_TERR_INTF jut
9289 where jut.USER_SEQUENCE = v_user_sequence
9290 and jut.status is null
9291 and jut.terr_qual_id28 is not null
9292 and jut.QUAL28_VALUE_ID is not null
9293 and jut.QUAL28_value1 is null
9294 and jut.INTERFACE_TYPE = v_intf_type
9295 AND jut.ACTION_FLAG = v_action_flag
9296 and jut.header = v_header
9297 union all
9298 select terr_id, user_sequence,
9299 terr_qual_id29 terr_qual_id,
9300 29 qual_num, QUAL29_VALUE_ID qual_value_id
9301 FROM JTY_WEBADI_OTH_TERR_INTF jut
9302 where jut.USER_SEQUENCE = v_user_sequence
9303 and jut.status is null
9304 and jut.terr_qual_id29 is not null
9305 and jut.QUAL29_VALUE_ID is not null
9306 and jut.QUAL29_value1 is null
9307 and jut.INTERFACE_TYPE = v_intf_type
9308 AND jut.ACTION_FLAG = v_action_flag
9309 and jut.header = v_header
9310 union all
9311 select terr_id, user_sequence,
9312 terr_qual_id30 terr_qual_id,
9313 30 qual_num, QUAL30_VALUE_ID qual_value_id
9314 FROM JTY_WEBADI_OTH_TERR_INTF jut
9315 where jut.USER_SEQUENCE = v_user_sequence
9316 and jut.status is null
9317 and jut.terr_qual_id30 is not null
9318 and jut.QUAL30_VALUE_ID is not null
9319 and jut.QUAL30_value1 is null
9320 and jut.INTERFACE_TYPE = v_intf_type
9321 AND jut.ACTION_FLAG = v_action_flag
9322 and jut.header = v_header
9323 union all
9324 select terr_id, user_sequence,
9325 terr_qual_id31 terr_qual_id,
9326 31 qual_num, QUAL31_VALUE_ID qual_value_id
9327 FROM JTY_WEBADI_OTH_TERR_INTF jut
9328 where jut.USER_SEQUENCE = v_user_sequence
9329 and jut.status is null
9330 and jut.terr_qual_id31 is not null
9331 and jut.QUAL31_VALUE_ID is not null
9332 and jut.QUAL31_value1 is null
9333 and jut.INTERFACE_TYPE = v_intf_type
9334 AND jut.ACTION_FLAG = v_action_flag
9335 and jut.header = v_header
9336 union all
9337 select terr_id, user_sequence,
9338 terr_qual_id32 terr_qual_id,
9339 32 qual_num, QUAL32_VALUE_ID qual_value_id
9340 FROM JTY_WEBADI_OTH_TERR_INTF jut
9341 where jut.USER_SEQUENCE = v_user_sequence
9342 and jut.status is null
9343 and jut.terr_qual_id32 is not null
9344 and jut.QUAL32_VALUE_ID is not null
9345 and jut.QUAL32_value1 is null
9346 and jut.INTERFACE_TYPE = v_intf_type
9347 AND jut.ACTION_FLAG = v_action_flag
9348 and jut.header = v_header
9349 union all
9350 select terr_id, user_sequence,
9351 terr_qual_id33 terr_qual_id,
9352 33 qual_num, QUAL33_VALUE_ID qual_value_id
9353 FROM JTY_WEBADI_OTH_TERR_INTF jut
9354 where jut.USER_SEQUENCE = v_user_sequence
9355 and jut.status is null
9356 and jut.terr_qual_id33 is not null
9357 and jut.QUAL33_VALUE_ID is not null
9358 and jut.QUAL33_value1 is null
9359 and jut.INTERFACE_TYPE = v_intf_type
9360 AND jut.ACTION_FLAG = v_action_flag
9361 and jut.header = v_header
9362 union all
9363 select terr_id, user_sequence,
9364 terr_qual_id34 terr_qual_id,
9365 34 qual_num, QUAL34_VALUE_ID qual_value_id
9366 FROM JTY_WEBADI_OTH_TERR_INTF jut
9367 where jut.USER_SEQUENCE = v_user_sequence
9368 and jut.status is null
9369 and jut.terr_qual_id34 is not null
9370 and jut.QUAL34_VALUE_ID is not null
9371 and jut.QUAL34_value1 is null
9372 and jut.INTERFACE_TYPE = v_intf_type
9373 AND jut.ACTION_FLAG = v_action_flag
9374 and jut.header = v_header
9375 union all
9376 select terr_id, user_sequence,
9377 terr_qual_id35 terr_qual_id,
9378 35 qual_num, QUAL35_VALUE_ID qual_value_id
9379 FROM JTY_WEBADI_OTH_TERR_INTF jut
9380 where jut.USER_SEQUENCE = v_user_sequence
9381 and jut.status is null
9382 and jut.terr_qual_id35 is not null
9383 and jut.QUAL35_VALUE_ID is not null
9384 and jut.QUAL35_value1 is null
9385 and jut.INTERFACE_TYPE = v_intf_type
9386 AND jut.ACTION_FLAG = v_action_flag
9387 and jut.header = v_header
9388 union all
9389 select terr_id, user_sequence,
9390 terr_qual_id36 terr_qual_id,
9391 36 qual_num, QUAL36_VALUE_ID qual_value_id
9392 FROM JTY_WEBADI_OTH_TERR_INTF jut
9393 where jut.USER_SEQUENCE = v_user_sequence
9394 and jut.status is null
9395 and jut.terr_qual_id36 is not null
9396 and jut.QUAL36_VALUE_ID is not null
9397 and jut.QUAL36_value1 is null
9398 and jut.INTERFACE_TYPE = v_intf_type
9399 AND jut.ACTION_FLAG = v_action_flag
9400 and jut.header = v_header
9401 union all
9402 select terr_id, user_sequence,
9403 terr_qual_id37 terr_qual_id,
9404 37 qual_num, QUAL37_VALUE_ID qual_value_id
9405 FROM JTY_WEBADI_OTH_TERR_INTF jut
9406 where jut.USER_SEQUENCE = v_user_sequence
9407 and jut.status is null
9408 and jut.terr_qual_id37 is not null
9409 and jut.QUAL37_VALUE_ID is not null
9410 and jut.QUAL37_value1 is null
9411 and jut.INTERFACE_TYPE = v_intf_type
9412 AND jut.ACTION_FLAG = v_action_flag
9413 and jut.header = v_header
9414 union all
9415 select terr_id, user_sequence,
9416 terr_qual_id38 terr_qual_id,
9417 38 qual_num, QUAL38_VALUE_ID qual_value_id
9418 FROM JTY_WEBADI_OTH_TERR_INTF jut
9419 where jut.USER_SEQUENCE = v_user_sequence
9420 and jut.status is null
9421 and jut.terr_qual_id38 is not null
9422 and jut.QUAL38_VALUE_ID is not null
9423 and jut.QUAL38_value1 is null
9424 and jut.INTERFACE_TYPE = v_intf_type
9425 AND jut.ACTION_FLAG = v_action_flag
9426 and jut.header = v_header
9427 union all
9428 select terr_id, user_sequence,
9429 terr_qual_id39 terr_qual_id,
9430 39 qual_num, QUAL39_VALUE_ID qual_value_id
9431 FROM JTY_WEBADI_OTH_TERR_INTF jut
9432 where jut.USER_SEQUENCE = v_user_sequence
9433 and jut.status is null
9434 and jut.terr_qual_id39 is not null
9435 and jut.QUAL39_VALUE_ID is not null
9436 and jut.QUAL39_value1 is null
9437 and jut.INTERFACE_TYPE = v_intf_type
9438 AND jut.ACTION_FLAG = v_action_flag
9439 and jut.header = v_header
9440 union all
9441 select terr_id, user_sequence,
9442 terr_qual_id40 terr_qual_id,
9443 40 qual_num, QUAL40_VALUE_ID qual_value_id
9444 FROM JTY_WEBADI_OTH_TERR_INTF jut
9445 where jut.USER_SEQUENCE = v_user_sequence
9446 and jut.status is null
9447 and jut.terr_qual_id40 is not null
9448 and jut.QUAL40_VALUE_ID is not null
9449 and jut.QUAL40_value1 is null
9450 and jut.INTERFACE_TYPE = v_intf_type
9451 AND jut.ACTION_FLAG = v_action_flag
9452 and jut.header = v_header
9453 union all
9454 select terr_id, user_sequence,
9455 terr_qual_id41 terr_qual_id,
9456 41 qual_num, QUAL41_VALUE_ID qual_value_id
9457 FROM JTY_WEBADI_OTH_TERR_INTF jut
9458 where jut.USER_SEQUENCE = v_user_sequence
9459 and jut.status is null
9460 and jut.terr_qual_id41 is not null
9461 and jut.QUAL41_VALUE_ID is not null
9462 and jut.QUAL41_value1 is null
9463 and jut.INTERFACE_TYPE = v_intf_type
9464 AND jut.ACTION_FLAG = v_action_flag
9465 and jut.header = v_header
9466 union all
9467 select terr_id, user_sequence,
9468 terr_qual_id42 terr_qual_id,
9469 42 qual_num, QUAL42_VALUE_ID qual_value_id
9470 FROM JTY_WEBADI_OTH_TERR_INTF jut
9471 where jut.USER_SEQUENCE = v_user_sequence
9472 and jut.status is null
9473 and jut.terr_qual_id42 is not null
9474 and jut.QUAL42_VALUE_ID is not null
9475 and jut.QUAL42_value1 is null
9476 and jut.INTERFACE_TYPE = v_intf_type
9477 AND jut.ACTION_FLAG = v_action_flag
9478 and jut.header = v_header
9479 union all
9480 select terr_id, user_sequence,
9481 terr_qual_id43 terr_qual_id,
9482 43 qual_num, QUAL43_VALUE_ID qual_value_id
9483 FROM JTY_WEBADI_OTH_TERR_INTF jut
9484 where jut.USER_SEQUENCE = v_user_sequence
9485 and jut.status is null
9486 and jut.terr_qual_id43 is not null
9487 and jut.QUAL43_VALUE_ID is not null
9488 and jut.QUAL43_value1 is null
9489 and jut.INTERFACE_TYPE = v_intf_type
9490 AND jut.ACTION_FLAG = v_action_flag
9491 and jut.header = v_header
9492 union all
9493 select terr_id, user_sequence,
9494 terr_qual_id44 terr_qual_id,
9495 44 qual_num, QUAL44_VALUE_ID qual_value_id
9496 FROM JTY_WEBADI_OTH_TERR_INTF jut
9497 where jut.USER_SEQUENCE = v_user_sequence
9498 and jut.status is null
9499 and jut.terr_qual_id44 is not null
9500 and jut.QUAL44_VALUE_ID is not null
9501 and jut.QUAL44_value1 is null
9502 and jut.INTERFACE_TYPE = v_intf_type
9503 AND jut.ACTION_FLAG = v_action_flag
9504 and jut.header = v_header
9505 union all
9506 select terr_id, user_sequence,
9507 terr_qual_id45 terr_qual_id,
9508 45 qual_num, QUAL45_VALUE_ID qual_value_id
9509 FROM JTY_WEBADI_OTH_TERR_INTF jut
9510 where jut.USER_SEQUENCE = v_user_sequence
9511 and jut.status is null
9512 and jut.terr_qual_id45 is not null
9513 and jut.QUAL45_VALUE_ID is not null
9514 and jut.QUAL45_value1 is null
9515 and jut.INTERFACE_TYPE = v_intf_type
9516 AND jut.ACTION_FLAG = v_action_flag
9517 and jut.header = v_header
9518 union all
9519 select terr_id, user_sequence,
9520 terr_qual_id46 terr_qual_id,
9521 46 qual_num, QUAL46_VALUE_ID qual_value_id
9522 FROM JTY_WEBADI_OTH_TERR_INTF jut
9523 where jut.USER_SEQUENCE = v_user_sequence
9524 and jut.status is null
9525 and jut.terr_qual_id46 is not null
9526 and jut.QUAL46_VALUE_ID is not null
9527 and jut.QUAL46_value1 is null
9528 and jut.INTERFACE_TYPE = v_intf_type
9529 AND jut.ACTION_FLAG = v_action_flag
9530 and jut.header = v_header
9531 union all
9532 select terr_id, user_sequence,
9533 terr_qual_id47 terr_qual_id,
9534 47 qual_num, QUAL47_VALUE_ID qual_value_id
9535 FROM JTY_WEBADI_OTH_TERR_INTF jut
9536 where jut.USER_SEQUENCE = v_user_sequence
9537 and jut.status is null
9538 and jut.terr_qual_id47 is not null
9539 and jut.QUAL47_VALUE_ID is not null
9540 and jut.QUAL47_value1 is null
9541 and jut.INTERFACE_TYPE = v_intf_type
9542 AND jut.ACTION_FLAG = v_action_flag
9543 and jut.header = v_header
9544 union all
9545 select terr_id, user_sequence,
9546 terr_qual_id48 terr_qual_id,
9547 48 qual_num, QUAL48_VALUE_ID qual_value_id
9548 FROM JTY_WEBADI_OTH_TERR_INTF jut
9549 where jut.USER_SEQUENCE = v_user_sequence
9550 and jut.status is null
9551 and jut.terr_qual_id48 is not null
9552 and jut.QUAL48_VALUE_ID is not null
9553 and jut.QUAL48_value1 is null
9554 and jut.INTERFACE_TYPE = v_intf_type
9555 AND jut.ACTION_FLAG = v_action_flag
9556 and jut.header = v_header
9557 union all
9558 select terr_id, user_sequence,
9559 terr_qual_id49 terr_qual_id,
9560 49 qual_num, QUAL49_VALUE_ID qual_value_id
9561 FROM JTY_WEBADI_OTH_TERR_INTF jut
9562 where jut.USER_SEQUENCE = v_user_sequence
9563 and jut.status is null
9564 and jut.terr_qual_id49 is not null
9565 and jut.QUAL49_VALUE_ID is not null
9566 and jut.QUAL49_value1 is null
9567 and jut.INTERFACE_TYPE = v_intf_type
9568 AND jut.ACTION_FLAG = v_action_flag
9569 and jut.header = v_header
9570 union all
9571 select terr_id, user_sequence,
9572 terr_qual_id50 terr_qual_id,
9573 50 qual_num, QUAL50_VALUE_ID qual_value_id
9574 FROM JTY_WEBADI_OTH_TERR_INTF jut
9575 where jut.USER_SEQUENCE = v_user_sequence
9576 and jut.status is null
9577 and jut.terr_qual_id50 is not null
9578 and jut.QUAL50_VALUE_ID is not null
9579 and jut.QUAL50_value1 is null
9580 and jut.INTERFACE_TYPE = v_intf_type
9581 AND jut.ACTION_FLAG = v_action_flag
9582 and jut.header = v_header
9583 union all
9584 select terr_id, user_sequence,
9585 terr_qual_id51 terr_qual_id,
9586 51 qual_num, QUAL51_VALUE_ID qual_value_id
9587 FROM JTY_WEBADI_OTH_TERR_INTF jut
9588 where jut.USER_SEQUENCE = v_user_sequence
9589 and jut.status is null
9590 and jut.terr_qual_id51 is not null
9591 and jut.QUAL51_VALUE_ID is not null
9592 and jut.QUAL51_value1 is null
9593 and jut.INTERFACE_TYPE = v_intf_type
9594 AND jut.ACTION_FLAG = v_action_flag
9595 and jut.header = v_header
9596 union all
9597 select terr_id, user_sequence,
9598 terr_qual_id52 terr_qual_id,
9599 52 qual_num, QUAL52_VALUE_ID qual_value_id
9600 FROM JTY_WEBADI_OTH_TERR_INTF jut
9601 where jut.USER_SEQUENCE = v_user_sequence
9602 and jut.status is null
9603 and jut.terr_qual_id52 is not null
9604 and jut.QUAL52_VALUE_ID is not null
9605 and jut.QUAL52_value1 is null
9606 and jut.INTERFACE_TYPE = v_intf_type
9607 AND jut.ACTION_FLAG = v_action_flag
9608 and jut.header = v_header
9609 union all
9610 select terr_id, user_sequence,
9611 terr_qual_id53 terr_qual_id,
9612 53 qual_num, QUAL53_VALUE_ID qual_value_id
9613 FROM JTY_WEBADI_OTH_TERR_INTF jut
9614 where jut.USER_SEQUENCE = v_user_sequence
9615 and jut.status is null
9616 and jut.terr_qual_id53 is not null
9617 and jut.QUAL53_VALUE_ID is not null
9618 and jut.QUAL53_value1 is null
9619 and jut.INTERFACE_TYPE = v_intf_type
9620 AND jut.ACTION_FLAG = v_action_flag
9621 and jut.header = v_header
9622 union all
9623 select terr_id, user_sequence,
9624 terr_qual_id54 terr_qual_id,
9625 54 qual_num, QUAL54_VALUE_ID qual_value_id
9626 FROM JTY_WEBADI_OTH_TERR_INTF jut
9627 where jut.USER_SEQUENCE = v_user_sequence
9628 and jut.status is null
9629 and jut.terr_qual_id54 is not null
9630 and jut.QUAL54_VALUE_ID is not null
9631 and jut.QUAL54_value1 is null
9632 and jut.INTERFACE_TYPE = v_intf_type
9633 AND jut.ACTION_FLAG = v_action_flag
9634 and jut.header = v_header
9635 union all
9636 select terr_id, user_sequence,
9637 terr_qual_id55 terr_qual_id,
9638 55 qual_num, QUAL55_VALUE_ID qual_value_id
9639 FROM JTY_WEBADI_OTH_TERR_INTF jut
9640 where jut.USER_SEQUENCE = v_user_sequence
9641 and jut.status is null
9642 and jut.terr_qual_id55 is not null
9643 and jut.QUAL55_VALUE_ID is not null
9644 and jut.QUAL55_value1 is null
9645 and jut.INTERFACE_TYPE = v_intf_type
9646 AND jut.ACTION_FLAG = v_action_flag
9647 and jut.header = v_header
9648 union all
9649 select terr_id, user_sequence,
9650 terr_qual_id56 terr_qual_id,
9651 56 qual_num, QUAL56_VALUE_ID qual_value_id
9652 FROM JTY_WEBADI_OTH_TERR_INTF jut
9653 where jut.USER_SEQUENCE = v_user_sequence
9654 and jut.status is null
9655 and jut.terr_qual_id56 is not null
9656 and jut.QUAL56_VALUE_ID is not null
9657 and jut.QUAL56_value1 is null
9658 and jut.INTERFACE_TYPE = v_intf_type
9659 AND jut.ACTION_FLAG = v_action_flag
9660 and jut.header = v_header
9661 union all
9662 select terr_id, user_sequence,
9663 terr_qual_id57 terr_qual_id,
9664 57 qual_num, QUAL57_VALUE_ID qual_value_id
9665 FROM JTY_WEBADI_OTH_TERR_INTF jut
9666 where jut.USER_SEQUENCE = v_user_sequence
9667 and jut.status is null
9668 and jut.terr_qual_id57 is not null
9669 and jut.QUAL57_VALUE_ID is not null
9670 and jut.QUAL57_value1 is null
9671 and jut.INTERFACE_TYPE = v_intf_type
9672 AND jut.ACTION_FLAG = v_action_flag
9673 and jut.header = v_header
9674 union all
9675 select terr_id, user_sequence,
9676 terr_qual_id58 terr_qual_id,
9677 58 qual_num, QUAL58_VALUE_ID qual_value_id
9678 FROM JTY_WEBADI_OTH_TERR_INTF jut
9679 where jut.USER_SEQUENCE = v_user_sequence
9680 and jut.status is null
9681 and jut.terr_qual_id58 is not null
9682 and jut.QUAL58_VALUE_ID is not null
9683 and jut.QUAL58_value1 is null
9684 and jut.INTERFACE_TYPE = v_intf_type
9685 AND jut.ACTION_FLAG = v_action_flag
9686 and jut.header = v_header
9687 union all
9688 select terr_id, user_sequence,
9689 terr_qual_id59 terr_qual_id,
9690 59 qual_num, QUAL59_VALUE_ID qual_value_id
9691 FROM JTY_WEBADI_OTH_TERR_INTF jut
9692 where jut.USER_SEQUENCE = v_user_sequence
9693 and jut.status is null
9694 and jut.terr_qual_id59 is not null
9695 and jut.QUAL59_VALUE_ID is not null
9696 and jut.QUAL59_value1 is null
9697 and jut.INTERFACE_TYPE = v_intf_type
9698 AND jut.ACTION_FLAG = v_action_flag
9699 and jut.header = v_header
9700 union all
9701 select terr_id, user_sequence,
9702 terr_qual_id60 terr_qual_id,
9703 60 qual_num, QUAL60_VALUE_ID qual_value_id
9704 FROM JTY_WEBADI_OTH_TERR_INTF jut
9705 where jut.USER_SEQUENCE = v_user_sequence
9706 and jut.status is null
9707 and jut.terr_qual_id60 is not null
9708 and jut.QUAL60_VALUE_ID is not null
9709 and jut.QUAL60_value1 is null
9710 and jut.INTERFACE_TYPE = v_intf_type
9711 AND jut.ACTION_FLAG = v_action_flag
9712 and jut.header = v_header
9713 union all
9714 select terr_id, user_sequence,
9715 terr_qual_id61 terr_qual_id,
9716 61 qual_num, QUAL61_VALUE_ID qual_value_id
9717 FROM JTY_WEBADI_OTH_TERR_INTF jut
9718 where jut.USER_SEQUENCE = v_user_sequence
9719 and jut.status is null
9720 and jut.terr_qual_id61 is not null
9721 and jut.QUAL61_VALUE_ID is not null
9722 and jut.QUAL61_value1 is null
9723 and jut.INTERFACE_TYPE = v_intf_type
9724 AND jut.ACTION_FLAG = v_action_flag
9725 and jut.header = v_header
9726 union all
9727 select terr_id, user_sequence,
9728 terr_qual_id62 terr_qual_id,
9729 62 qual_num, QUAL62_VALUE_ID qual_value_id
9730 FROM JTY_WEBADI_OTH_TERR_INTF jut
9731 where jut.USER_SEQUENCE = v_user_sequence
9732 and jut.status is null
9733 and jut.terr_qual_id62 is not null
9734 and jut.QUAL62_VALUE_ID is not null
9735 and jut.QUAL62_value1 is null
9736 and jut.INTERFACE_TYPE = v_intf_type
9737 AND jut.ACTION_FLAG = v_action_flag
9738 and jut.header = v_header
9739 union all
9740 select terr_id, user_sequence,
9741 terr_qual_id63 terr_qual_id,
9742 63 qual_num, QUAL63_VALUE_ID qual_value_id
9743 FROM JTY_WEBADI_OTH_TERR_INTF jut
9744 where jut.USER_SEQUENCE = v_user_sequence
9745 and jut.status is null
9746 and jut.terr_qual_id63 is not null
9747 and jut.QUAL63_VALUE_ID is not null
9748 and jut.QUAL63_value1 is null
9749 and jut.INTERFACE_TYPE = v_intf_type
9750 AND jut.ACTION_FLAG = v_action_flag
9751 and jut.header = v_header
9752 union all
9753 select terr_id, user_sequence,
9754 terr_qual_id64 terr_qual_id,
9755 64 qual_num, QUAL64_VALUE_ID qual_value_id
9756 FROM JTY_WEBADI_OTH_TERR_INTF jut
9757 where jut.USER_SEQUENCE = v_user_sequence
9758 and jut.status is null
9759 and jut.terr_qual_id64 is not null
9760 and jut.QUAL64_VALUE_ID is not null
9761 and jut.QUAL64_value1 is null
9762 and jut.INTERFACE_TYPE = v_intf_type
9763 AND jut.ACTION_FLAG = v_action_flag
9764 and jut.header = v_header
9765 union all
9766 select terr_id, user_sequence,
9767 terr_qual_id65 terr_qual_id,
9768 65 qual_num, QUAL65_VALUE_ID qual_value_id
9769 FROM JTY_WEBADI_OTH_TERR_INTF jut
9770 where jut.USER_SEQUENCE = v_user_sequence
9771 and jut.status is null
9772 and jut.terr_qual_id65 is not null
9773 and jut.QUAL65_VALUE_ID is not null
9774 and jut.QUAL65_value1 is null
9775 and jut.INTERFACE_TYPE = v_intf_type
9776 AND jut.ACTION_FLAG = v_action_flag
9777 and jut.header = v_header
9778 union all
9779 select terr_id, user_sequence,
9780 terr_qual_id66 terr_qual_id,
9781 66 qual_num, QUAL66_VALUE_ID qual_value_id
9782 FROM JTY_WEBADI_OTH_TERR_INTF jut
9783 where jut.USER_SEQUENCE = v_user_sequence
9784 and jut.status is null
9785 and jut.terr_qual_id66 is not null
9786 and jut.QUAL66_VALUE_ID is not null
9787 and jut.QUAL66_value1 is null
9788 and jut.INTERFACE_TYPE = v_intf_type
9789 AND jut.ACTION_FLAG = v_action_flag
9790 and jut.header = v_header
9791 union all
9792 select terr_id, user_sequence,
9793 terr_qual_id67 terr_qual_id,
9794 67 qual_num, QUAL67_VALUE_ID qual_value_id
9795 FROM JTY_WEBADI_OTH_TERR_INTF jut
9796 where jut.USER_SEQUENCE = v_user_sequence
9797 and jut.status is null
9798 and jut.terr_qual_id67 is not null
9799 and jut.QUAL67_VALUE_ID is not null
9800 and jut.QUAL67_value1 is null
9801 and jut.INTERFACE_TYPE = v_intf_type
9802 AND jut.ACTION_FLAG = v_action_flag
9803 and jut.header = v_header
9804 union all
9805 select terr_id, user_sequence,
9806 terr_qual_id68 terr_qual_id,
9807 68 qual_num, QUAL68_VALUE_ID qual_value_id
9808 FROM JTY_WEBADI_OTH_TERR_INTF jut
9809 where jut.USER_SEQUENCE = v_user_sequence
9810 and jut.status is null
9811 and jut.terr_qual_id68 is not null
9812 and jut.QUAL68_VALUE_ID is not null
9813 and jut.QUAL68_value1 is null
9814 and jut.INTERFACE_TYPE = v_intf_type
9815 AND jut.ACTION_FLAG = v_action_flag
9816 and jut.header = v_header
9817 union all
9818 select terr_id, user_sequence,
9819 terr_qual_id69 terr_qual_id,
9820 69 qual_num, QUAL69_VALUE_ID qual_value_id
9821 FROM JTY_WEBADI_OTH_TERR_INTF jut
9822 where jut.USER_SEQUENCE = v_user_sequence
9823 and jut.status is null
9824 and jut.terr_qual_id69 is not null
9825 and jut.QUAL69_VALUE_ID is not null
9826 and jut.QUAL69_value1 is null
9827 and jut.INTERFACE_TYPE = v_intf_type
9828 AND jut.ACTION_FLAG = v_action_flag
9829 and jut.header = v_header
9830 union all
9831 select terr_id, user_sequence,
9832 terr_qual_id70 terr_qual_id,
9833 70 qual_num, QUAL70_VALUE_ID qual_value_id
9834 FROM JTY_WEBADI_OTH_TERR_INTF jut
9835 where jut.USER_SEQUENCE = v_user_sequence
9836 and jut.status is null
9837 and jut.terr_qual_id70 is not null
9838 and jut.QUAL70_VALUE_ID is not null
9839 and jut.QUAL70_value1 is null
9840 and jut.INTERFACE_TYPE = v_intf_type
9841 AND jut.ACTION_FLAG = v_action_flag
9842 and jut.header = v_header
9843 union all
9844 select terr_id, user_sequence,
9845 terr_qual_id71 terr_qual_id,
9846 71 qual_num, QUAL71_VALUE_ID qual_value_id
9847 FROM JTY_WEBADI_OTH_TERR_INTF jut
9848 where jut.USER_SEQUENCE = v_user_sequence
9849 and jut.status is null
9850 and jut.terr_qual_id71 is not null
9851 and jut.QUAL71_VALUE_ID is not null
9852 and jut.QUAL71_value1 is null
9853 and jut.INTERFACE_TYPE = v_intf_type
9854 AND jut.ACTION_FLAG = v_action_flag
9855 and jut.header = v_header
9856 union all
9857 select terr_id, user_sequence,
9858 terr_qual_id72 terr_qual_id,
9859 72 qual_num, QUAL72_VALUE_ID qual_value_id
9860 FROM JTY_WEBADI_OTH_TERR_INTF jut
9861 where jut.USER_SEQUENCE = v_user_sequence
9862 and jut.status is null
9863 and jut.terr_qual_id72 is not null
9864 and jut.QUAL72_VALUE_ID is not null
9865 and jut.QUAL72_value1 is null
9866 and jut.INTERFACE_TYPE = v_intf_type
9867 AND jut.ACTION_FLAG = v_action_flag
9868 and jut.header = v_header
9869 union all
9870 select terr_id, user_sequence,
9871 terr_qual_id73 terr_qual_id,
9872 73 qual_num, QUAL73_VALUE_ID qual_value_id
9873 FROM JTY_WEBADI_OTH_TERR_INTF jut
9874 where jut.USER_SEQUENCE = v_user_sequence
9875 and jut.status is null
9876 and jut.terr_qual_id73 is not null
9877 and jut.QUAL73_VALUE_ID is not null
9878 and jut.QUAL73_value1 is null
9879 and jut.INTERFACE_TYPE = v_intf_type
9880 AND jut.ACTION_FLAG = v_action_flag
9881 and jut.header = v_header
9882 union all
9883 select terr_id, user_sequence,
9884 terr_qual_id74 terr_qual_id,
9885 74 qual_num, QUAL74_VALUE_ID qual_value_id
9886 FROM JTY_WEBADI_OTH_TERR_INTF jut
9887 where jut.USER_SEQUENCE = v_user_sequence
9888 and jut.status is null
9889 and jut.terr_qual_id74 is not null
9890 and jut.QUAL74_VALUE_ID is not null
9891 and jut.QUAL74_value1 is null
9892 and jut.INTERFACE_TYPE = v_intf_type
9893 AND jut.ACTION_FLAG = v_action_flag
9894 and jut.header = v_header
9895 union all
9896 select terr_id, user_sequence,
9897 terr_qual_id75 terr_qual_id,
9898 75 qual_num, QUAL75_VALUE_ID qual_value_id
9899 FROM JTY_WEBADI_OTH_TERR_INTF jut
9900 where jut.USER_SEQUENCE = v_user_sequence
9901 and jut.status is null
9902 and jut.terr_qual_id75 is not null
9903 and jut.QUAL75_VALUE_ID is not null
9904 and jut.QUAL75_value1 is null
9905 and jut.INTERFACE_TYPE = v_intf_type
9906 AND jut.ACTION_FLAG = v_action_flag
9907 and jut.header = v_header
9908 ) sub;
9909
9910 l_Terr_Qual_Rec Terr_Qual_Rec_Type;
9911 l_terr_values_rec Terr_values_rec_type;
9912 l_terr_values_out_rec Terr_values_out_rec_type;
9913
9914 l_intf_type VARCHAR2(1) := 'U';
9915 l_header varchar2(15) := 'QUAL';
9916 l_action_flag varchar2(1);
9917
9918 BEGIN
9919 x_return_status := FND_API.G_RET_STS_SUCCESS;
9920 x_msg_data := NULL;
9921 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : Inside' );
9922 --l_action_flag := p_action_flag;
9923 l_action_flag := 'C';
9924 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : l_action_flag :' || l_action_flag);
9925 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : l_intf_type :' || l_intf_type);
9926 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : l_header :' || l_header);
9927 open get_qual_csr(P_USER_SEQUENCE, l_action_flag, l_intf_type, l_header);
9928 fetch get_qual_csr bulk collect into
9929 l_Terr_Qual_Rec.TERR_QUAL_ID, l_Terr_Qual_Rec.terr_id,
9930 l_Terr_Qual_Rec.qual_value_id, l_Terr_Qual_Rec.qual_value1,
9931 l_Terr_Qual_Rec.qual_value2, l_Terr_Qual_Rec.qual_value3,
9932 l_Terr_Qual_Rec.org_id, l_Terr_Qual_Rec.last_updated_by,
9933 l_Terr_Qual_Rec.last_update_date, l_Terr_Qual_Rec.last_update_login,
9934 l_Terr_Qual_Rec.creation_date, l_Terr_Qual_Rec.created_by,
9935 l_Terr_Qual_Rec.qual_usg_id, l_Terr_Qual_Rec.qual_type,
9936 l_Terr_Qual_Rec.CONVERT_TO_ID_FLAG, l_Terr_Qual_Rec.qualifier_num,
9937 l_Terr_Qual_Rec.html_lov_sql1, l_Terr_Qual_Rec.qual_cond;
9938 close get_qual_csr;
9939
9940 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : l_Terr_Qual_Rec.TERR_ID.count :' || l_Terr_Qual_Rec.TERR_ID.count);
9941 if (l_action_flag = 'C' AND l_Terr_Qual_Rec.TERR_ID.count > 0) then
9942 debugmsg('UPDATE_TERR_DEF: INSERT_TERR_QUAL : Before ' );
9943 INSERT_TERR_QUAL (
9944 p_Terr_Qual_Rec => l_Terr_Qual_Rec,
9945 x_return_status => x_return_status,
9946 x_msg_data => x_msg_data);
9947 debugmsg('UPDATE_TERR_DEF: INSERT_TERR_QUAL : After completion x_return_status : ' || x_return_status);
9948 if (x_return_status = FND_API.G_RET_STS_SUCCESS) then
9949 debugmsg('UPDATE_TERR_DEF: INSERT_TERR_VALUES : Before ' );
9950 INSERT_TERR_VALUES(
9951 p_Terr_Qual_Rec => l_terr_qual_rec,
9952 p_terr_values_out_rec => l_terr_values_out_rec,
9953 x_return_status => x_return_status,
9954 x_msg_data => x_msg_data);
9955 debugmsg('UPDATE_TERR_DEF: INSERT_TERR_VALUES : After completion x_return_status : ' || x_return_status);
9956 debugmsg('UPDATE_TERR_DEF: INSERT_TERR_VALUES : After completion x_msg_data : ' || x_msg_data);
9957 end if;
9958 debugmsg('UPDATE_TERR_DEF: Update Terr qual id : ');
9959 forall i in l_Terr_Qual_Rec.TERR_ID.first..l_Terr_Qual_Rec.TERR_ID.last
9960 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
9961 set
9962 jwot.terr_qual_id1 = decode(l_Terr_Qual_Rec.qualifier_num(i),1,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id1),
9963 jwot.terr_qual_id2 = decode(l_Terr_Qual_Rec.qualifier_num(i),2,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id2),
9964 jwot.terr_qual_id3 = decode(l_Terr_Qual_Rec.qualifier_num(i),3,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id3),
9965 jwot.terr_qual_id4 = decode(l_Terr_Qual_Rec.qualifier_num(i),4,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id4),
9966 jwot.terr_qual_id5 = decode(l_Terr_Qual_Rec.qualifier_num(i),5,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id5),
9967 jwot.terr_qual_id6 = decode(l_Terr_Qual_Rec.qualifier_num(i),6,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id6),
9968 jwot.terr_qual_id7 = decode(l_Terr_Qual_Rec.qualifier_num(i),7,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id7),
9969 jwot.terr_qual_id8 = decode(l_Terr_Qual_Rec.qualifier_num(i),8,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id8),
9970 jwot.terr_qual_id9 = decode(l_Terr_Qual_Rec.qualifier_num(i),9,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id9),
9971 jwot.terr_qual_id10 = decode(l_Terr_Qual_Rec.qualifier_num(i),10,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id10),
9972 jwot.terr_qual_id11 = decode(l_Terr_Qual_Rec.qualifier_num(i),11,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id11),
9973 jwot.terr_qual_id12 = decode(l_Terr_Qual_Rec.qualifier_num(i),12,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id12),
9974 jwot.terr_qual_id13 = decode(l_Terr_Qual_Rec.qualifier_num(i),13,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id13),
9975 jwot.terr_qual_id14 = decode(l_Terr_Qual_Rec.qualifier_num(i),14,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id14),
9976 jwot.terr_qual_id15 = decode(l_Terr_Qual_Rec.qualifier_num(i),15,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id15),
9977 jwot.terr_qual_id16 = decode(l_Terr_Qual_Rec.qualifier_num(i),16,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id16),
9978 jwot.terr_qual_id17 = decode(l_Terr_Qual_Rec.qualifier_num(i),17,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id17),
9979 jwot.terr_qual_id18 = decode(l_Terr_Qual_Rec.qualifier_num(i),18,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id18),
9980 jwot.terr_qual_id19 = decode(l_Terr_Qual_Rec.qualifier_num(i),19,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id19),
9981 jwot.terr_qual_id20 = decode(l_Terr_Qual_Rec.qualifier_num(i),20,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id20),
9982 jwot.terr_qual_id21 = decode(l_Terr_Qual_Rec.qualifier_num(i),21,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id21),
9983 jwot.terr_qual_id22 = decode(l_Terr_Qual_Rec.qualifier_num(i),22,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id22),
9984 jwot.terr_qual_id23 = decode(l_Terr_Qual_Rec.qualifier_num(i),23,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id23),
9985 jwot.terr_qual_id24 = decode(l_Terr_Qual_Rec.qualifier_num(i),24,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id24),
9986 jwot.terr_qual_id25 = decode(l_Terr_Qual_Rec.qualifier_num(i),25,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id25),
9987 jwot.terr_qual_id26 = decode(l_Terr_Qual_Rec.qualifier_num(i),26,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id26),
9988 jwot.terr_qual_id27 = decode(l_Terr_Qual_Rec.qualifier_num(i),27,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id27),
9989 jwot.terr_qual_id28 = decode(l_Terr_Qual_Rec.qualifier_num(i),28,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id28),
9990 jwot.terr_qual_id29 = decode(l_Terr_Qual_Rec.qualifier_num(i),29,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id29),
9991 jwot.terr_qual_id30 = decode(l_Terr_Qual_Rec.qualifier_num(i),30,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id30),
9992 jwot.terr_qual_id31 = decode(l_Terr_Qual_Rec.qualifier_num(i),31,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id31),
9993 jwot.terr_qual_id32 = decode(l_Terr_Qual_Rec.qualifier_num(i),32,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id32),
9994 jwot.terr_qual_id33 = decode(l_Terr_Qual_Rec.qualifier_num(i),33,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id33),
9995 jwot.terr_qual_id34 = decode(l_Terr_Qual_Rec.qualifier_num(i),34,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id34),
9996 jwot.terr_qual_id35 = decode(l_Terr_Qual_Rec.qualifier_num(i),35,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id35),
9997 jwot.terr_qual_id36 = decode(l_Terr_Qual_Rec.qualifier_num(i),36,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id36),
9998 jwot.terr_qual_id37 = decode(l_Terr_Qual_Rec.qualifier_num(i),37,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id37),
9999 jwot.terr_qual_id38 = decode(l_Terr_Qual_Rec.qualifier_num(i),38,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id38),
10000 jwot.terr_qual_id39 = decode(l_Terr_Qual_Rec.qualifier_num(i),39,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id39),
10001 jwot.terr_qual_id40 = decode(l_Terr_Qual_Rec.qualifier_num(i),40,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id40),
10002 jwot.terr_qual_id41 = decode(l_Terr_Qual_Rec.qualifier_num(i),41,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id41),
10003 jwot.terr_qual_id42 = decode(l_Terr_Qual_Rec.qualifier_num(i),42,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id42),
10004 jwot.terr_qual_id43 = decode(l_Terr_Qual_Rec.qualifier_num(i),43,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id43),
10005 jwot.terr_qual_id44 = decode(l_Terr_Qual_Rec.qualifier_num(i),44,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id44),
10006 jwot.terr_qual_id45 = decode(l_Terr_Qual_Rec.qualifier_num(i),45,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id45),
10007 jwot.terr_qual_id46 = decode(l_Terr_Qual_Rec.qualifier_num(i),46,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id46),
10008 jwot.terr_qual_id47 = decode(l_Terr_Qual_Rec.qualifier_num(i),47,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id47),
10009 jwot.terr_qual_id48 = decode(l_Terr_Qual_Rec.qualifier_num(i),48,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id48),
10010 jwot.terr_qual_id49 = decode(l_Terr_Qual_Rec.qualifier_num(i),49,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id49),
10011 jwot.terr_qual_id50 = decode(l_Terr_Qual_Rec.qualifier_num(i),50,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id50),
10012 jwot.terr_qual_id51 = decode(l_Terr_Qual_Rec.qualifier_num(i),51,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id51),
10013 jwot.terr_qual_id52 = decode(l_Terr_Qual_Rec.qualifier_num(i),52,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id52),
10014 jwot.terr_qual_id53 = decode(l_Terr_Qual_Rec.qualifier_num(i),53,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id53),
10015 jwot.terr_qual_id54 = decode(l_Terr_Qual_Rec.qualifier_num(i),54,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id54),
10016 jwot.terr_qual_id55 = decode(l_Terr_Qual_Rec.qualifier_num(i),55,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id55),
10017 jwot.terr_qual_id56 = decode(l_Terr_Qual_Rec.qualifier_num(i),56,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id56),
10018 jwot.terr_qual_id57 = decode(l_Terr_Qual_Rec.qualifier_num(i),57,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id57),
10019 jwot.terr_qual_id58 = decode(l_Terr_Qual_Rec.qualifier_num(i),58,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id58),
10020 jwot.terr_qual_id59 = decode(l_Terr_Qual_Rec.qualifier_num(i),59,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id59),
10021 jwot.terr_qual_id60 = decode(l_Terr_Qual_Rec.qualifier_num(i),60,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id60),
10022 jwot.terr_qual_id61 = decode(l_Terr_Qual_Rec.qualifier_num(i),61,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id61),
10023 jwot.terr_qual_id62 = decode(l_Terr_Qual_Rec.qualifier_num(i),62,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id62),
10024 jwot.terr_qual_id63 = decode(l_Terr_Qual_Rec.qualifier_num(i),63,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id63),
10025 jwot.terr_qual_id64 = decode(l_Terr_Qual_Rec.qualifier_num(i),64,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id64),
10026 jwot.terr_qual_id65 = decode(l_Terr_Qual_Rec.qualifier_num(i),65,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id65),
10027 jwot.terr_qual_id66 = decode(l_Terr_Qual_Rec.qualifier_num(i),66,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id66),
10028 jwot.terr_qual_id67 = decode(l_Terr_Qual_Rec.qualifier_num(i),67,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id67),
10029 jwot.terr_qual_id68 = decode(l_Terr_Qual_Rec.qualifier_num(i),68,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id68),
10030 jwot.terr_qual_id69 = decode(l_Terr_Qual_Rec.qualifier_num(i),69,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id69),
10031 jwot.terr_qual_id70 = decode(l_Terr_Qual_Rec.qualifier_num(i),70,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id70),
10032 jwot.terr_qual_id71 = decode(l_Terr_Qual_Rec.qualifier_num(i),71,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id71),
10033 jwot.terr_qual_id72 = decode(l_Terr_Qual_Rec.qualifier_num(i),72,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id72),
10034 jwot.terr_qual_id73 = decode(l_Terr_Qual_Rec.qualifier_num(i),73,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id73),
10035 jwot.terr_qual_id74 = decode(l_Terr_Qual_Rec.qualifier_num(i),74,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id74),
10036 jwot.terr_qual_id75 = decode(l_Terr_Qual_Rec.qualifier_num(i),75,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id75)
10037 where TERR_ID = l_Terr_Qual_Rec.TERR_ID(i)
10038 and user_sequence = p_user_sequence
10039 and header = l_header
10040 and interface_type = l_intf_type;
10041
10042 if x_return_status = FND_API.G_RET_STS_ERROR then
10043 forall i in l_Terr_Qual_Rec.TERR_QUAL_ID.first..l_Terr_Qual_Rec.TERR_QUAL_ID.last
10044 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
10045 SET STATUS = x_return_status,
10046 ERROR_MSG = x_msg_data
10047 WHERE l_Terr_Qual_Rec.TERR_QUAL_ID(i) in
10048 ( jwot.TERR_QUAL_ID1, jwot.TERR_QUAL_ID2, jwot.TERR_QUAL_ID3,
10049 jwot.TERR_QUAL_ID4, jwot.TERR_QUAL_ID5, jwot.TERR_QUAL_ID6,
10050 jwot.TERR_QUAL_ID7, jwot.TERR_QUAL_ID8, jwot.TERR_QUAL_ID9,
10051 jwot.TERR_QUAL_ID10, jwot.TERR_QUAL_ID11, jwot.TERR_QUAL_ID12,
10052 jwot.TERR_QUAL_ID13, jwot.TERR_QUAL_ID14, jwot.TERR_QUAL_ID15,
10053 jwot.TERR_QUAL_ID16, jwot.TERR_QUAL_ID17, jwot.TERR_QUAL_ID18,
10054 jwot.TERR_QUAL_ID19, jwot.TERR_QUAL_ID20, jwot.TERR_QUAL_ID21,
10055 jwot.TERR_QUAL_ID22, jwot.TERR_QUAL_ID23,jwot.TERR_QUAL_ID24,
10056 jwot.TERR_QUAL_ID25, jwot.TERR_QUAL_ID26, jwot.TERR_QUAL_ID27,
10057 jwot.TERR_QUAL_ID28, jwot.TERR_QUAL_ID29,
10058 jwot.TERR_QUAL_ID30, jwot.TERR_QUAL_ID31,
10059 jwot.TERR_QUAL_ID32, jwot.TERR_QUAL_ID33,jwot.TERR_QUAL_ID34,
10060 jwot.TERR_QUAL_ID35, jwot.TERR_QUAL_ID36, jwot.TERR_QUAL_ID37,
10061 jwot.TERR_QUAL_ID38, jwot.TERR_QUAL_ID39,
10062 jwot.TERR_QUAL_ID40, jwot.TERR_QUAL_ID41,
10063 jwot.TERR_QUAL_ID42, jwot.TERR_QUAL_ID43,jwot.TERR_QUAL_ID44,
10064 jwot.TERR_QUAL_ID45, jwot.TERR_QUAL_ID46, jwot.TERR_QUAL_ID47,
10065 jwot.TERR_QUAL_ID48, jwot.TERR_QUAL_ID49,
10066 jwot.TERR_QUAL_ID50, jwot.TERR_QUAL_ID51,
10067 jwot.TERR_QUAL_ID52, jwot.TERR_QUAL_ID53,jwot.TERR_QUAL_ID54,
10068 jwot.TERR_QUAL_ID55, jwot.TERR_QUAL_ID56, jwot.TERR_QUAL_ID57,
10069 jwot.TERR_QUAL_ID58, jwot.TERR_QUAL_ID59,
10070 jwot.TERR_QUAL_ID60, jwot.TERR_QUAL_ID61,
10071 jwot.TERR_QUAL_ID62, jwot.TERR_QUAL_ID63,jwot.TERR_QUAL_ID64,
10072 jwot.TERR_QUAL_ID65, jwot.TERR_QUAL_ID66, jwot.TERR_QUAL_ID67,
10073 jwot.TERR_QUAL_ID68, jwot.TERR_QUAL_ID69,
10074 jwot.TERR_QUAL_ID70, jwot.TERR_QUAL_ID71,
10075 jwot.TERR_QUAL_ID72, jwot.TERR_QUAL_ID73,jwot.TERR_QUAL_ID74,
10076 jwot.TERR_QUAL_ID75
10077 )
10078 AND interface_type = l_intf_type
10079 and header = l_header
10080 and user_sequence = p_user_sequence;
10081 end if;
10082
10083 end if; -- terr_id count
10084 l_action_flag := 'U';
10085 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : Inside and Action Update' );
10086 x_return_status := FND_API.G_RET_STS_SUCCESS;
10087 open get_qual_csr(P_USER_SEQUENCE, l_action_flag, l_intf_type, l_header);
10088 fetch get_qual_csr bulk collect into
10089 l_Terr_Qual_Rec.TERR_QUAL_ID, l_Terr_Qual_Rec.terr_id,
10090 l_Terr_Qual_Rec.qual_value_id, l_Terr_Qual_Rec.qual_value1,
10091 l_Terr_Qual_Rec.qual_value2, l_Terr_Qual_Rec.qual_value3,
10092 l_Terr_Qual_Rec.org_id, l_Terr_Qual_Rec.last_updated_by,
10093 l_Terr_Qual_Rec.last_update_date, l_Terr_Qual_Rec.last_update_login,
10094 l_Terr_Qual_Rec.creation_date, l_Terr_Qual_Rec.created_by,
10095 l_Terr_Qual_Rec.qual_usg_id, l_Terr_Qual_Rec.qual_type,
10096 l_Terr_Qual_Rec.CONVERT_TO_ID_FLAG, l_Terr_Qual_Rec.qualifier_num,
10097 l_Terr_Qual_Rec.html_lov_sql1, l_Terr_Qual_Rec.qual_cond;
10098 close get_qual_csr;
10099 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : Action Update : l_Terr_Qual_Rec.TERR_ID.count ' || l_Terr_Qual_Rec.TERR_ID.count );
10100 if (l_action_flag = 'U' AND l_Terr_Qual_Rec.TERR_ID.count > 0) then
10101
10102 INSERT_TERR_QUAL (
10103 p_Terr_Qual_Rec => l_Terr_Qual_Rec,
10104 x_return_status => x_return_status,
10105 x_msg_data => x_msg_data);
10106
10107 if (x_return_status = FND_API.G_RET_STS_SUCCESS) then
10108 INSERT_TERR_VALUES(
10109 p_Terr_Qual_Rec => l_terr_qual_rec,
10110 p_terr_values_out_rec => l_terr_values_out_rec,
10111 x_return_status => x_return_status,
10112 x_msg_data => x_msg_data);
10113 end if;
10114
10115 forall i in l_Terr_Qual_Rec.TERR_ID.first..l_Terr_Qual_Rec.TERR_ID.last
10116 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
10117 set
10118 jwot.terr_qual_id1 = decode(l_Terr_Qual_Rec.qualifier_num(i),1,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id1),
10119 jwot.terr_qual_id2 = decode(l_Terr_Qual_Rec.qualifier_num(i),2,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id2),
10120 jwot.terr_qual_id3 = decode(l_Terr_Qual_Rec.qualifier_num(i),3,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id3),
10121 jwot.terr_qual_id4 = decode(l_Terr_Qual_Rec.qualifier_num(i),4,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id4),
10122 jwot.terr_qual_id5 = decode(l_Terr_Qual_Rec.qualifier_num(i),5,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id5),
10123 jwot.terr_qual_id6 = decode(l_Terr_Qual_Rec.qualifier_num(i),6,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id6),
10124 jwot.terr_qual_id7 = decode(l_Terr_Qual_Rec.qualifier_num(i),7,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id7),
10125 jwot.terr_qual_id8 = decode(l_Terr_Qual_Rec.qualifier_num(i),8,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id8),
10126 jwot.terr_qual_id9 = decode(l_Terr_Qual_Rec.qualifier_num(i),9,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id9),
10127 jwot.terr_qual_id10 = decode(l_Terr_Qual_Rec.qualifier_num(i),10,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id10),
10128 jwot.terr_qual_id11 = decode(l_Terr_Qual_Rec.qualifier_num(i),11,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id11),
10129 jwot.terr_qual_id12 = decode(l_Terr_Qual_Rec.qualifier_num(i),12,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id12),
10130 jwot.terr_qual_id13 = decode(l_Terr_Qual_Rec.qualifier_num(i),13,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id13),
10131 jwot.terr_qual_id14 = decode(l_Terr_Qual_Rec.qualifier_num(i),14,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id14),
10132 jwot.terr_qual_id15 = decode(l_Terr_Qual_Rec.qualifier_num(i),15,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id15),
10133 jwot.terr_qual_id16 = decode(l_Terr_Qual_Rec.qualifier_num(i),16,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id16),
10134 jwot.terr_qual_id17 = decode(l_Terr_Qual_Rec.qualifier_num(i),17,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id17),
10135 jwot.terr_qual_id18 = decode(l_Terr_Qual_Rec.qualifier_num(i),18,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id18),
10136 jwot.terr_qual_id19 = decode(l_Terr_Qual_Rec.qualifier_num(i),19,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id19),
10137 jwot.terr_qual_id20 = decode(l_Terr_Qual_Rec.qualifier_num(i),20,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id20),
10138 jwot.terr_qual_id21 = decode(l_Terr_Qual_Rec.qualifier_num(i),21,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id21),
10139 jwot.terr_qual_id22 = decode(l_Terr_Qual_Rec.qualifier_num(i),22,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id22),
10140 jwot.terr_qual_id23 = decode(l_Terr_Qual_Rec.qualifier_num(i),23,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id23),
10141 jwot.terr_qual_id24 = decode(l_Terr_Qual_Rec.qualifier_num(i),24,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id24),
10142 jwot.terr_qual_id25 = decode(l_Terr_Qual_Rec.qualifier_num(i),25,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id25),
10143 jwot.terr_qual_id26 = decode(l_Terr_Qual_Rec.qualifier_num(i),26,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id26),
10144 jwot.terr_qual_id27 = decode(l_Terr_Qual_Rec.qualifier_num(i),27,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id27),
10145 jwot.terr_qual_id28 = decode(l_Terr_Qual_Rec.qualifier_num(i),28,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id28),
10146 jwot.terr_qual_id29 = decode(l_Terr_Qual_Rec.qualifier_num(i),29,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id29),
10147 jwot.terr_qual_id30 = decode(l_Terr_Qual_Rec.qualifier_num(i),30,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id30),
10148 jwot.terr_qual_id31 = decode(l_Terr_Qual_Rec.qualifier_num(i),31,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id31),
10149 jwot.terr_qual_id32 = decode(l_Terr_Qual_Rec.qualifier_num(i),32,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id32),
10150 jwot.terr_qual_id33 = decode(l_Terr_Qual_Rec.qualifier_num(i),33,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id33),
10151 jwot.terr_qual_id34 = decode(l_Terr_Qual_Rec.qualifier_num(i),34,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id34),
10152 jwot.terr_qual_id35 = decode(l_Terr_Qual_Rec.qualifier_num(i),35,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id35),
10153 jwot.terr_qual_id36 = decode(l_Terr_Qual_Rec.qualifier_num(i),36,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id36),
10154 jwot.terr_qual_id37 = decode(l_Terr_Qual_Rec.qualifier_num(i),37,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id37),
10155 jwot.terr_qual_id38 = decode(l_Terr_Qual_Rec.qualifier_num(i),38,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id38),
10156 jwot.terr_qual_id39 = decode(l_Terr_Qual_Rec.qualifier_num(i),39,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id39),
10157 jwot.terr_qual_id40 = decode(l_Terr_Qual_Rec.qualifier_num(i),40,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id40),
10158 jwot.terr_qual_id41 = decode(l_Terr_Qual_Rec.qualifier_num(i),41,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id41),
10159 jwot.terr_qual_id42 = decode(l_Terr_Qual_Rec.qualifier_num(i),42,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id42),
10160 jwot.terr_qual_id43 = decode(l_Terr_Qual_Rec.qualifier_num(i),43,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id43),
10161 jwot.terr_qual_id44 = decode(l_Terr_Qual_Rec.qualifier_num(i),44,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id44),
10162 jwot.terr_qual_id45 = decode(l_Terr_Qual_Rec.qualifier_num(i),45,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id45),
10163 jwot.terr_qual_id46 = decode(l_Terr_Qual_Rec.qualifier_num(i),46,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id46),
10164 jwot.terr_qual_id47 = decode(l_Terr_Qual_Rec.qualifier_num(i),47,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id47),
10165 jwot.terr_qual_id48 = decode(l_Terr_Qual_Rec.qualifier_num(i),48,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id48),
10166 jwot.terr_qual_id49 = decode(l_Terr_Qual_Rec.qualifier_num(i),49,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id49),
10167 jwot.terr_qual_id50 = decode(l_Terr_Qual_Rec.qualifier_num(i),50,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id50),
10168 jwot.terr_qual_id51 = decode(l_Terr_Qual_Rec.qualifier_num(i),51,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id51),
10169 jwot.terr_qual_id52 = decode(l_Terr_Qual_Rec.qualifier_num(i),52,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id52),
10170 jwot.terr_qual_id53 = decode(l_Terr_Qual_Rec.qualifier_num(i),53,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id53),
10171 jwot.terr_qual_id54 = decode(l_Terr_Qual_Rec.qualifier_num(i),54,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id54),
10172 jwot.terr_qual_id55 = decode(l_Terr_Qual_Rec.qualifier_num(i),55,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id55),
10173 jwot.terr_qual_id56 = decode(l_Terr_Qual_Rec.qualifier_num(i),56,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id56),
10174 jwot.terr_qual_id57 = decode(l_Terr_Qual_Rec.qualifier_num(i),57,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id57),
10175 jwot.terr_qual_id58 = decode(l_Terr_Qual_Rec.qualifier_num(i),58,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id58),
10176 jwot.terr_qual_id59 = decode(l_Terr_Qual_Rec.qualifier_num(i),59,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id59),
10177 jwot.terr_qual_id60 = decode(l_Terr_Qual_Rec.qualifier_num(i),60,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id60),
10178 jwot.terr_qual_id61 = decode(l_Terr_Qual_Rec.qualifier_num(i),61,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id61),
10179 jwot.terr_qual_id62 = decode(l_Terr_Qual_Rec.qualifier_num(i),62,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id62),
10180 jwot.terr_qual_id63 = decode(l_Terr_Qual_Rec.qualifier_num(i),63,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id63),
10181 jwot.terr_qual_id64 = decode(l_Terr_Qual_Rec.qualifier_num(i),64,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id64),
10182 jwot.terr_qual_id65 = decode(l_Terr_Qual_Rec.qualifier_num(i),65,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id65),
10183 jwot.terr_qual_id66 = decode(l_Terr_Qual_Rec.qualifier_num(i),66,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id66),
10184 jwot.terr_qual_id67 = decode(l_Terr_Qual_Rec.qualifier_num(i),67,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id67),
10185 jwot.terr_qual_id68 = decode(l_Terr_Qual_Rec.qualifier_num(i),68,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id68),
10186 jwot.terr_qual_id69 = decode(l_Terr_Qual_Rec.qualifier_num(i),69,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id69),
10187 jwot.terr_qual_id70 = decode(l_Terr_Qual_Rec.qualifier_num(i),70,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id70),
10188 jwot.terr_qual_id71 = decode(l_Terr_Qual_Rec.qualifier_num(i),71,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id71),
10189 jwot.terr_qual_id72 = decode(l_Terr_Qual_Rec.qualifier_num(i),72,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id72),
10190 jwot.terr_qual_id73 = decode(l_Terr_Qual_Rec.qualifier_num(i),73,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id73),
10191 jwot.terr_qual_id74 = decode(l_Terr_Qual_Rec.qualifier_num(i),74,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id74),
10192 jwot.terr_qual_id75 = decode(l_Terr_Qual_Rec.qualifier_num(i),75,l_Terr_Qual_Rec.TERR_QUAL_ID(i),jwot.terr_qual_id75)
10193 where TERR_ID = l_Terr_Qual_Rec.TERR_ID(i)
10194 and user_sequence = p_user_sequence
10195 and header = l_header
10196 and interface_type = l_intf_type;
10197
10198 if x_return_status = FND_API.G_RET_STS_ERROR then
10199 forall i in l_Terr_Qual_Rec.TERR_QUAL_ID.first..l_Terr_Qual_Rec.TERR_QUAL_ID.last
10200 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
10201 SET STATUS = x_return_status,
10202 ERROR_MSG = x_msg_data
10203 WHERE l_Terr_Qual_Rec.TERR_QUAL_ID(i) in
10204 ( jwot.TERR_QUAL_ID1, jwot.TERR_QUAL_ID2, jwot.TERR_QUAL_ID3,
10205 jwot.TERR_QUAL_ID4, jwot.TERR_QUAL_ID5, jwot.TERR_QUAL_ID6,
10206 jwot.TERR_QUAL_ID7, jwot.TERR_QUAL_ID8, jwot.TERR_QUAL_ID9,
10207 jwot.TERR_QUAL_ID10, jwot.TERR_QUAL_ID11, jwot.TERR_QUAL_ID12,
10208 jwot.TERR_QUAL_ID13, jwot.TERR_QUAL_ID14, jwot.TERR_QUAL_ID15,
10209 jwot.TERR_QUAL_ID16, jwot.TERR_QUAL_ID17, jwot.TERR_QUAL_ID18,
10210 jwot.TERR_QUAL_ID19, jwot.TERR_QUAL_ID20, jwot.TERR_QUAL_ID21,
10211 jwot.TERR_QUAL_ID22, jwot.TERR_QUAL_ID23,
10212 jwot.TERR_QUAL_ID24, jwot.TERR_QUAL_ID25, jwot.TERR_QUAL_ID26, jwot.TERR_QUAL_ID27,
10213 jwot.TERR_QUAL_ID28, jwot.TERR_QUAL_ID29,
10214 jwot.TERR_QUAL_ID30, jwot.TERR_QUAL_ID31,
10215 jwot.TERR_QUAL_ID32, jwot.TERR_QUAL_ID33,jwot.TERR_QUAL_ID34,
10216 jwot.TERR_QUAL_ID35, jwot.TERR_QUAL_ID36, jwot.TERR_QUAL_ID37,
10217 jwot.TERR_QUAL_ID38, jwot.TERR_QUAL_ID39,
10218 jwot.TERR_QUAL_ID40, jwot.TERR_QUAL_ID41,
10219 jwot.TERR_QUAL_ID42, jwot.TERR_QUAL_ID43,jwot.TERR_QUAL_ID44,
10220 jwot.TERR_QUAL_ID45, jwot.TERR_QUAL_ID46, jwot.TERR_QUAL_ID47,
10221 jwot.TERR_QUAL_ID48, jwot.TERR_QUAL_ID49,
10222 jwot.TERR_QUAL_ID50, jwot.TERR_QUAL_ID51,
10223 jwot.TERR_QUAL_ID52, jwot.TERR_QUAL_ID53,jwot.TERR_QUAL_ID54,
10224 jwot.TERR_QUAL_ID55, jwot.TERR_QUAL_ID56, jwot.TERR_QUAL_ID57,
10225 jwot.TERR_QUAL_ID58, jwot.TERR_QUAL_ID59,
10226 jwot.TERR_QUAL_ID60, jwot.TERR_QUAL_ID61,
10227 jwot.TERR_QUAL_ID62, jwot.TERR_QUAL_ID63,jwot.TERR_QUAL_ID64,
10228 jwot.TERR_QUAL_ID65, jwot.TERR_QUAL_ID66, jwot.TERR_QUAL_ID67,
10229 jwot.TERR_QUAL_ID68, jwot.TERR_QUAL_ID69,
10230 jwot.TERR_QUAL_ID70, jwot.TERR_QUAL_ID71,
10231 jwot.TERR_QUAL_ID72, jwot.TERR_QUAL_ID73,jwot.TERR_QUAL_ID74,
10232 jwot.TERR_QUAL_ID75 )
10233 AND interface_type = l_intf_type
10234 and header = l_header
10235 and user_sequence = p_user_sequence;
10236 end if;
10237 end if; -- terr_id count
10238
10239 x_return_status := FND_API.G_RET_STS_SUCCESS;
10240 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : get_c_terr_value_csr before' );
10241 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : get_c_terr_value_csr l_action_flag ' || l_action_flag);
10242 open get_c_terr_value_csr(P_USER_SEQUENCE, l_intf_type, l_header);
10243 fetch get_c_terr_value_csr bulk collect into
10244 l_Terr_Qual_Rec.TERR_QUAL_ID, l_Terr_Qual_Rec.terr_id,
10245 l_Terr_Qual_Rec.qual_value_id, l_Terr_Qual_Rec.qual_value1,
10246 l_Terr_Qual_Rec.qual_value2, l_Terr_Qual_Rec.qual_value3,
10247 l_Terr_Qual_Rec.org_id, l_Terr_Qual_Rec.last_updated_by,
10248 l_Terr_Qual_Rec.last_update_date, l_Terr_Qual_Rec.last_update_login,
10249 l_Terr_Qual_Rec.creation_date, l_Terr_Qual_Rec.created_by,
10250 l_Terr_Qual_Rec.qual_usg_id, l_Terr_Qual_Rec.qual_type,
10251 l_Terr_Qual_Rec.CONVERT_TO_ID_FLAG, l_Terr_Qual_Rec.qualifier_num,
10252 l_Terr_Qual_Rec.html_lov_sql1, l_Terr_Qual_Rec.qual_cond;
10253 close get_c_terr_value_csr;
10254
10255 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL get_c_terr_value_csr : l_Terr_Qual_Rec.TERR_QUAL_ID.count ' || l_Terr_Qual_Rec.TERR_QUAL_ID.count);
10256 if (l_Terr_Qual_Rec.TERR_QUAL_ID.count > 0) then
10257 INSERT_TERR_VALUES(
10258 p_Terr_Qual_Rec => l_terr_qual_rec,
10259 p_terr_values_out_rec => l_terr_values_out_rec,
10260 x_return_status => x_return_status,
10261 x_msg_data => x_msg_data);
10262 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : get_c_terr_value_csr after : INSERT_TERR_VALUES : x_return_status ' || x_return_status );
10263 if x_return_status = FND_API.G_RET_STS_ERROR then
10264 forall i in l_Terr_Qual_Rec.TERR_QUAL_ID.first..l_Terr_Qual_Rec.TERR_QUAL_ID.last
10265 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
10266 SET STATUS = x_return_status,
10267 ERROR_MSG = x_msg_data
10268 WHERE l_Terr_Qual_Rec.TERR_QUAL_ID(i) in
10269 ( jwot.TERR_QUAL_ID1, jwot.TERR_QUAL_ID2, jwot.TERR_QUAL_ID3,
10270 jwot.TERR_QUAL_ID4, jwot.TERR_QUAL_ID5, jwot.TERR_QUAL_ID6,
10271 jwot.TERR_QUAL_ID7, jwot.TERR_QUAL_ID8, jwot.TERR_QUAL_ID9,
10272 jwot.TERR_QUAL_ID10, jwot.TERR_QUAL_ID11, jwot.TERR_QUAL_ID12,
10273 jwot.TERR_QUAL_ID13, jwot.TERR_QUAL_ID14, jwot.TERR_QUAL_ID15,
10274 jwot.TERR_QUAL_ID16, jwot.TERR_QUAL_ID17, jwot.TERR_QUAL_ID18,
10275 jwot.TERR_QUAL_ID19, jwot.TERR_QUAL_ID20, jwot.TERR_QUAL_ID21,
10276 jwot.TERR_QUAL_ID22, jwot.TERR_QUAL_ID23,
10277 jwot.TERR_QUAL_ID24, jwot.TERR_QUAL_ID25, jwot.TERR_QUAL_ID26, jwot.TERR_QUAL_ID27,
10278 jwot.TERR_QUAL_ID28, jwot.TERR_QUAL_ID29,
10279 jwot.TERR_QUAL_ID30, jwot.TERR_QUAL_ID31,
10280 jwot.TERR_QUAL_ID32, jwot.TERR_QUAL_ID33,jwot.TERR_QUAL_ID34,
10281 jwot.TERR_QUAL_ID35, jwot.TERR_QUAL_ID36, jwot.TERR_QUAL_ID37,
10282 jwot.TERR_QUAL_ID38, jwot.TERR_QUAL_ID39,
10283 jwot.TERR_QUAL_ID40, jwot.TERR_QUAL_ID41,
10284 jwot.TERR_QUAL_ID42, jwot.TERR_QUAL_ID43,jwot.TERR_QUAL_ID44,
10285 jwot.TERR_QUAL_ID45, jwot.TERR_QUAL_ID46, jwot.TERR_QUAL_ID47,
10286 jwot.TERR_QUAL_ID48, jwot.TERR_QUAL_ID49,
10287 jwot.TERR_QUAL_ID50, jwot.TERR_QUAL_ID51,
10288 jwot.TERR_QUAL_ID52, jwot.TERR_QUAL_ID53,jwot.TERR_QUAL_ID54,
10289 jwot.TERR_QUAL_ID55, jwot.TERR_QUAL_ID56, jwot.TERR_QUAL_ID57,
10290 jwot.TERR_QUAL_ID58, jwot.TERR_QUAL_ID59,
10291 jwot.TERR_QUAL_ID60, jwot.TERR_QUAL_ID61,
10292 jwot.TERR_QUAL_ID62, jwot.TERR_QUAL_ID63,jwot.TERR_QUAL_ID64,
10293 jwot.TERR_QUAL_ID65, jwot.TERR_QUAL_ID66, jwot.TERR_QUAL_ID67,
10294 jwot.TERR_QUAL_ID68, jwot.TERR_QUAL_ID69,
10295 jwot.TERR_QUAL_ID70, jwot.TERR_QUAL_ID71,
10296 jwot.TERR_QUAL_ID72, jwot.TERR_QUAL_ID73,jwot.TERR_QUAL_ID74,
10297 jwot.TERR_QUAL_ID75 )
10298 AND interface_type = l_intf_type
10299 and header = l_header
10300 and user_sequence = p_user_sequence;
10301 end if;
10302 end if; --get_c_terr_value_csr
10303 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : get_u_terr_value_csr before' );
10304 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : get_u_terr_value_csr l_action_flag ' || l_action_flag);
10305 open get_u_terr_value_csr(P_USER_SEQUENCE, l_action_flag, l_intf_type, l_header);
10306 fetch get_u_terr_value_csr bulk collect into
10307 l_Terr_Qual_Rec.TERR_QUAL_ID, l_Terr_Qual_Rec.terr_id,
10308 l_Terr_Qual_Rec.qual_value_id, l_Terr_Qual_Rec.qual_value1,
10309 l_Terr_Qual_Rec.qual_value2, l_Terr_Qual_Rec.qual_value3,
10310 l_Terr_Qual_Rec.org_id, l_Terr_Qual_Rec.last_updated_by,
10311 l_Terr_Qual_Rec.last_update_date, l_Terr_Qual_Rec.last_update_login,
10312 l_Terr_Qual_Rec.creation_date, l_Terr_Qual_Rec.created_by,
10313 l_Terr_Qual_Rec.qual_usg_id, l_Terr_Qual_Rec.qual_type,
10314 l_Terr_Qual_Rec.CONVERT_TO_ID_FLAG, l_Terr_Qual_Rec.qualifier_num,
10315 l_Terr_Qual_Rec.html_lov_sql1, l_Terr_Qual_Rec.qual_cond;
10316 close get_u_terr_value_csr;
10317 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL get_u_terr_value_csr : l_Terr_Qual_Rec.TERR_QUAL_ID.count ' || l_Terr_Qual_Rec.TERR_QUAL_ID.count);
10318 if (l_Terr_Qual_Rec.TERR_QUAL_ID.count > 0) then
10319 BEGIN
10320 --dbms_output.put_line('U: get_u_terr_value_csr: update TV, rowcount: ' || l_Terr_Qual_Rec.TERR_QUAL_ID.count);
10321
10322 x_return_status := FND_API.G_RET_STS_SUCCESS;
10323 for i in l_Terr_Qual_Rec.TERR_QUAL_ID.first..l_Terr_Qual_Rec.TERR_QUAL_ID.last loop
10324
10325 l_Terr_Values_Rec.LAST_UPDATE_DATE(i) := l_Terr_Qual_Rec.LAST_UPDATE_DATE(i);
10326 l_Terr_Values_Rec.LAST_UPDATED_BY(i) := l_Terr_Qual_Rec.LAST_UPDATED_BY(i);
10327 l_Terr_Values_Rec.CREATION_DATE(i) := l_Terr_Qual_Rec.CREATION_DATE(i);
10328 l_Terr_Values_Rec.CREATED_BY(i) := l_Terr_Qual_Rec.CREATED_BY(i);
10329 l_Terr_Values_Rec.LAST_UPDATE_LOGIN(i) := l_Terr_Qual_Rec.LAST_UPDATE_LOGIN(i);
10330 l_Terr_Values_Rec.TERR_QUAL_ID(i) := l_Terr_Qual_Rec.TERR_QUAL_ID(i);
10331 l_Terr_Values_Rec.COMPARISON_OPERATOR(i) := l_Terr_Qual_Rec.qual_cond(i);
10332 l_Terr_Values_Rec.ID_USED_FLAG(i) := l_Terr_Qual_Rec.CONVERT_TO_ID_FLAG(i);
10333 l_Terr_Values_Rec.ORG_ID(i) := l_Terr_Qual_Rec.ORG_ID(i);
10334 l_Terr_Values_Rec.TERR_VALUE_ID(i) := l_Terr_Qual_Rec.qual_value_id(i);
10335 l_Terr_Values_Rec.LOW_VALUE_CHAR(i):= NULL;
10336 l_Terr_Values_Rec.HIGH_VALUE_CHAR(i):= NULL;
10337 l_Terr_Values_Rec.LOW_VALUE_NUMBER(i):= NULL;
10338 l_Terr_Values_Rec.HIGH_VALUE_NUMBER(i):= NULL;
10339 l_Terr_Values_Rec.INTEREST_TYPE_ID(i):= NULL;
10340 l_Terr_Values_Rec.PRIMARY_INTEREST_CODE_ID(i):= NULL;
10341 l_Terr_Values_Rec.SECONDARY_INTEREST_CODE_ID(i):= NULL;
10342 l_Terr_Values_Rec.CURRENCY_CODE(i):= NULL;
10343 --l_Terr_Values_Rec.ID_USED_FLAG(i):= NULL;
10344 l_Terr_Values_Rec.LOW_VALUE_CHAR_ID(i):= NULL;
10345 --l_Terr_Values_Rec.ORG_ID(i):= NULL;
10346 l_Terr_Values_Rec.VALUE1_ID(i):= NULL;
10347 l_Terr_Values_Rec.VALUE2_ID(i):= NULL;
10348 l_Terr_Values_Rec.VALUE3_ID(i):= NULL;
10349 case
10350 when l_Terr_Qual_Rec.qual_type(i) = 'CHAR' then
10351 IF l_Terr_Qual_Rec.CONVERT_TO_ID_FLAG(i) = 'N' then
10352 l_Terr_Values_Rec.LOW_VALUE_CHAR(i) := l_Terr_Qual_Rec.qual_value1(i);
10353 if l_Terr_Qual_Rec.qual_value2.count > 0 then
10354 l_Terr_Values_Rec.HIGH_VALUE_CHAR(i) := l_Terr_Qual_Rec.qual_value2(i);
10355 else l_Terr_Values_Rec.HIGH_VALUE_CHAR(i) := NULL;
10356 end if;
10357 else
10358 l_Terr_Values_Rec.LOW_VALUE_CHAR_ID(i) := l_Terr_Qual_Rec.qual_value1(i);
10359 end if;
10360 when l_Terr_Qual_Rec.qual_type(i) = 'DEP_2FIELDS_1CHAR_1ID' then
10361 l_Terr_Values_Rec.LOW_VALUE_CHAR(i) := l_Terr_Qual_Rec.qual_value1(i);
10362 if l_Terr_Qual_Rec.qual_value2.count > 0 then
10363 l_Terr_Values_Rec.LOW_VALUE_CHAR_ID(i) := l_Terr_Qual_Rec.qual_value2(i);
10364 else l_Terr_Values_Rec.LOW_VALUE_CHAR_ID(i) := NULL;
10365 end if;
10366 when l_Terr_Qual_Rec.qual_type(i) in
10367 ('CHAR_2IDS', 'DEP_2FIELDS', 'DEP_2FIELDS_CHAR_2IDS') then
10368 l_Terr_Values_Rec.VALUE1_ID(i) := l_Terr_Qual_Rec.qual_value1(i);
10369 if l_Terr_Qual_Rec.qual_value2.count > 0 then
10370 l_Terr_Values_Rec.VALUE2_ID(i) := l_Terr_Qual_Rec.qual_value2(i);
10371 else l_Terr_Values_Rec.VALUE2_ID(i) := NULL;
10372 end if;
10373 when l_Terr_Qual_Rec.qual_type(i) = 'DEP_3FIELDS_CHAR_3IDS' then
10374 l_Terr_Values_Rec.VALUE1_ID(i) := l_Terr_Qual_Rec.qual_value1(i);
10375 if l_Terr_Qual_Rec.qual_value2.count > 0 then
10376 l_Terr_Values_Rec.VALUE2_ID(i) := l_Terr_Qual_Rec.qual_value2(i);
10377 else l_Terr_Values_Rec.VALUE2_ID(i) := NULL;
10378 end if;
10379 if l_Terr_Qual_Rec.qual_value3.count > 0 then
10380 l_Terr_Values_Rec.VALUE3_ID(i) := l_Terr_Qual_Rec.qual_value3(i);
10381 else l_Terr_Values_Rec.VALUE3_ID(i) := NULL;
10382 end if;
10383 when l_Terr_Qual_Rec.qual_type(i) = 'INTEREST_TYPE' then
10384 l_Terr_Values_Rec.INTEREST_TYPE_ID(i) := l_Terr_Qual_Rec.qual_value1(i);
10385 if l_Terr_Qual_Rec.qual_value2.count > 0 then
10386 l_Terr_Values_Rec.PRIMARY_INTEREST_CODE_ID(i) := l_Terr_Qual_Rec.qual_value2(i);
10387 else l_Terr_Values_Rec.PRIMARY_INTEREST_CODE_ID(i) := NULL;
10388 end if;
10389 if l_Terr_Qual_Rec.qual_value3.count > 0 then
10390 l_Terr_Values_Rec.SECONDARY_INTEREST_CODE_ID(i) := l_Terr_Qual_Rec.qual_value3(i);
10391 else l_Terr_Values_Rec.SECONDARY_INTEREST_CODE_ID(i) := NULL;
10392 end if;
10393 when l_Terr_Qual_Rec.qual_type(i) = 'NUMERIC' then
10394 l_Terr_Values_Rec.LOW_VALUE_NUMBER(i) := l_Terr_Qual_Rec.qual_value1(i);
10395 if l_Terr_Qual_Rec.qual_value2.count > 0 then
10396 l_Terr_Values_Rec.HIGH_VALUE_NUMBER(i) := l_Terr_Qual_Rec.qual_value2(i);
10397 else l_Terr_Values_Rec.HIGH_VALUE_NUMBER(i) := NULL;
10398 end if;
10399 when l_Terr_Qual_Rec.qual_type(i) = 'CURRENCY' then
10400 l_Terr_Values_Rec.LOW_VALUE_NUMBER(i) := l_Terr_Qual_Rec.qual_value1(i);
10401 if l_Terr_Qual_Rec.qual_value2.count > 0 then
10402 l_Terr_Values_Rec.HIGH_VALUE_NUMBER(i) := l_Terr_Qual_Rec.qual_value2(i);
10403 else l_Terr_Values_Rec.HIGH_VALUE_NUMBER(i) := NULL;
10404 end if;
10405 if l_Terr_Qual_Rec.qual_value3.count > 0 then
10406 l_Terr_Values_Rec.CURRENCY_CODE(i) := l_Terr_Qual_Rec.qual_value3(i);
10407 else l_Terr_Values_Rec.CURRENCY_CODE(i) := NULL;
10408 end if;
10409 else null;
10410 end case;
10411 end loop;
10412
10413 -- Check for duplicate value.
10414 x_return_status := FND_API.G_RET_STS_SUCCESS;
10415 Check_duplicate_Value_update(
10416 p_Terr_Values_Rec => l_Terr_Values_Rec ,
10417 x_return_status => x_return_status,
10418 x_msg_data => x_msg_data );
10419
10420 IF x_return_status = FND_API.G_RET_STS_SUCCESS THEN
10421 forall i in l_Terr_Values_Rec.TERR_VALUE_ID.first..l_Terr_Values_Rec.TERR_VALUE_ID.last
10422 Update JTF_TERR_VALUES_ALL
10423 SET
10424 LAST_UPDATED_BY = l_Terr_Values_Rec.LAST_UPDATED_BY(i),
10425 LAST_UPDATE_DATE = l_Terr_Values_Rec.LAST_UPDATE_DATE(i),
10426 LAST_UPDATE_LOGIN = l_Terr_Values_Rec.LAST_UPDATE_LOGIN(i),
10427 TERR_QUAL_ID = l_Terr_Values_Rec.TERR_QUAL_ID(i),
10428 COMPARISON_OPERATOR = l_Terr_Values_Rec.COMPARISON_OPERATOR(i),
10429 LOW_VALUE_CHAR = l_Terr_Values_Rec.LOW_VALUE_CHAR(i),
10430 HIGH_VALUE_CHAR = l_Terr_Values_Rec.HIGH_VALUE_CHAR(i),
10431 LOW_VALUE_NUMBER = l_Terr_Values_Rec.LOW_VALUE_NUMBER(i),
10432 HIGH_VALUE_NUMBER = l_Terr_Values_Rec.HIGH_VALUE_NUMBER(i),
10433 INTEREST_TYPE_ID = l_Terr_Values_Rec.INTEREST_TYPE_ID(i),
10434 PRIMARY_INTEREST_CODE_ID = l_Terr_Values_Rec.PRIMARY_INTEREST_CODE_ID(i),
10435 SECONDARY_INTEREST_CODE_ID = l_Terr_Values_Rec.SECONDARY_INTEREST_CODE_ID(i),
10436 CURRENCY_CODE = l_Terr_Values_Rec.CURRENCY_CODE(i),
10437 ID_USED_FLAG = l_Terr_Values_Rec.ID_USED_FLAG(i),
10438 LOW_VALUE_CHAR_ID = l_Terr_Values_Rec.LOW_VALUE_CHAR_ID(i),
10439 ORG_ID = l_Terr_Values_Rec.ORG_ID(i),
10440 VALUE1_ID = l_Terr_Values_Rec.VALUE1_ID(i),
10441 VALUE2_ID = l_Terr_Values_Rec.VALUE2_ID(i),
10442 VALUE3_ID = l_Terr_Values_Rec.VALUE3_ID(i)
10443 where TERR_VALUE_ID = l_Terr_Values_Rec.TERR_VALUE_ID(i);
10444
10445 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : U: get_u_terr_value_csr:TV, actual row processed: '||SQL%ROWCOUNT );
10446 END IF;
10447
10448 --dbms_output.put_line(' U: get_u_terr_value_csr:TV, actual row processed: '||SQL%ROWCOUNT);
10449
10450 EXCEPTION
10451 WHEN OTHERS THEN
10452 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : Inside exception others');
10453 x_return_status := FND_API.G_RET_STS_ERROR;
10454 fnd_message.clear;
10455 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_UPDATE_QUAL_VAL');
10456 X_Msg_Data := fnd_message.get();
10457
10458 forall i in l_Terr_Qual_Rec.TERR_QUAL_ID.first..l_Terr_Qual_Rec.TERR_QUAL_ID.last
10459 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
10460 SET STATUS = x_return_status,
10461 error_msg = 'U: ' || x_msg_data
10462 WHERE l_Terr_Qual_Rec.TERR_QUAL_ID(i) in
10463 ( jwot.TERR_QUAL_ID1, jwot.TERR_QUAL_ID2, jwot.TERR_QUAL_ID3,
10464 jwot.TERR_QUAL_ID4, jwot.TERR_QUAL_ID5, jwot.TERR_QUAL_ID6,
10465 jwot.TERR_QUAL_ID7, jwot.TERR_QUAL_ID8, jwot.TERR_QUAL_ID9,
10466 jwot.TERR_QUAL_ID10, jwot.TERR_QUAL_ID11, jwot.TERR_QUAL_ID12,
10467 jwot.TERR_QUAL_ID13, jwot.TERR_QUAL_ID14, jwot.TERR_QUAL_ID15,
10468 jwot.TERR_QUAL_ID16, jwot.TERR_QUAL_ID17, jwot.TERR_QUAL_ID18,
10469 jwot.TERR_QUAL_ID19, jwot.TERR_QUAL_ID20, jwot.TERR_QUAL_ID21,
10470 jwot.TERR_QUAL_ID22, jwot.TERR_QUAL_ID23,
10471 jwot.TERR_QUAL_ID24, jwot.TERR_QUAL_ID25, jwot.TERR_QUAL_ID26, jwot.TERR_QUAL_ID27,
10472 jwot.TERR_QUAL_ID28, jwot.TERR_QUAL_ID29,
10473 jwot.TERR_QUAL_ID30, jwot.TERR_QUAL_ID31,
10474 jwot.TERR_QUAL_ID32, jwot.TERR_QUAL_ID33,jwot.TERR_QUAL_ID34,
10475 jwot.TERR_QUAL_ID35, jwot.TERR_QUAL_ID36, jwot.TERR_QUAL_ID37,
10476 jwot.TERR_QUAL_ID38, jwot.TERR_QUAL_ID39,
10477 jwot.TERR_QUAL_ID40, jwot.TERR_QUAL_ID41,
10478 jwot.TERR_QUAL_ID42, jwot.TERR_QUAL_ID43,jwot.TERR_QUAL_ID44,
10479 jwot.TERR_QUAL_ID45, jwot.TERR_QUAL_ID46, jwot.TERR_QUAL_ID47,
10480 jwot.TERR_QUAL_ID48, jwot.TERR_QUAL_ID49,
10481 jwot.TERR_QUAL_ID50, jwot.TERR_QUAL_ID51,
10482 jwot.TERR_QUAL_ID52, jwot.TERR_QUAL_ID53,jwot.TERR_QUAL_ID54,
10483 jwot.TERR_QUAL_ID55, jwot.TERR_QUAL_ID56, jwot.TERR_QUAL_ID57,
10484 jwot.TERR_QUAL_ID58, jwot.TERR_QUAL_ID59,
10485 jwot.TERR_QUAL_ID60, jwot.TERR_QUAL_ID61,
10486 jwot.TERR_QUAL_ID62, jwot.TERR_QUAL_ID63,jwot.TERR_QUAL_ID64,
10487 jwot.TERR_QUAL_ID65, jwot.TERR_QUAL_ID66, jwot.TERR_QUAL_ID67,
10488 jwot.TERR_QUAL_ID68, jwot.TERR_QUAL_ID69,
10489 jwot.TERR_QUAL_ID70, jwot.TERR_QUAL_ID71,
10490 jwot.TERR_QUAL_ID72, jwot.TERR_QUAL_ID73,jwot.TERR_QUAL_ID74,
10491 jwot.TERR_QUAL_ID75 )
10492 AND interface_type = l_intf_type
10493 and header = l_header
10494 and action_flag = l_action_flag
10495 and user_sequence = p_user_sequence;
10496 END;
10497 end if; --get_u_terr_value_csr
10498
10499 open get_d_terr_value_csr(P_USER_SEQUENCE, l_action_flag, l_intf_type, l_header);
10500 fetch get_d_terr_value_csr bulk collect into
10501 l_Terr_Qual_Rec.TERR_QUAL_ID, l_Terr_Qual_Rec.terr_id,
10502 l_Terr_Qual_Rec.qual_value_id, l_Terr_Qual_Rec.qualifier_num;
10503 close get_d_terr_value_csr;
10504
10505 if (l_Terr_Qual_Rec.TERR_QUAL_ID.count > 0) then
10506 BEGIN
10507 --dbms_output.put_line('U: get_d_terr_value_csr: delete TV, rowcount: ' || l_Terr_Qual_Rec.TERR_QUAL_ID.count);
10508 x_return_status := FND_API.G_RET_STS_SUCCESS;
10509 forall i in l_Terr_Qual_Rec.qual_value_id.first..l_Terr_Qual_Rec.qual_value_id.last
10510 DELETE FROM JTF_TERR_VALUES_ALL
10511 where TERR_VALUE_ID = l_Terr_Qual_Rec.qual_value_id(i);
10512 --dbms_output.put_line(' U: get_d_terr_value_csr:actual row processed: '||SQL%ROWCOUNT);
10513
10514 forall i in l_Terr_Qual_Rec.TERR_QUAL_ID.first..l_Terr_Qual_Rec.TERR_QUAL_ID.last
10515 DELETE FROM JTF_TERR_QUAL_ALL jtq
10516 WHERE not exists
10517 ( select 1 from JTF_TERR_VALUES_ALL jtv
10518 where jtv.terr_qual_id = jtq.terr_qual_id)
10519 and jtq.terr_qual_id = l_Terr_Qual_Rec.TERR_QUAL_ID(i);
10520 --dbms_output.put_line(' U: get_d_terr_value_csr:TV, actual row processed: '||SQL%ROWCOUNT);
10521
10522 forall i in l_Terr_Qual_Rec.TERR_QUAL_ID.first..l_Terr_Qual_Rec.TERR_QUAL_ID.last
10523 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
10524 SET STATUS = x_return_status
10525 WHERE l_Terr_Qual_Rec.TERR_QUAL_ID(i) in
10526 ( jwot.TERR_QUAL_ID1, jwot.TERR_QUAL_ID2, jwot.TERR_QUAL_ID3,
10527 jwot.TERR_QUAL_ID4, jwot.TERR_QUAL_ID5, jwot.TERR_QUAL_ID6,
10528 jwot.TERR_QUAL_ID7, jwot.TERR_QUAL_ID8, jwot.TERR_QUAL_ID9,
10529 jwot.TERR_QUAL_ID10, jwot.TERR_QUAL_ID11, jwot.TERR_QUAL_ID12,
10530 jwot.TERR_QUAL_ID13, jwot.TERR_QUAL_ID14, jwot.TERR_QUAL_ID15,
10531 jwot.TERR_QUAL_ID16, jwot.TERR_QUAL_ID17, jwot.TERR_QUAL_ID18,
10532 jwot.TERR_QUAL_ID19, jwot.TERR_QUAL_ID20, jwot.TERR_QUAL_ID21,
10533 jwot.TERR_QUAL_ID22, jwot.TERR_QUAL_ID23,
10534 jwot.TERR_QUAL_ID24, jwot.TERR_QUAL_ID25, jwot.TERR_QUAL_ID26, jwot.TERR_QUAL_ID27,
10535 jwot.TERR_QUAL_ID28, jwot.TERR_QUAL_ID29,
10536 jwot.TERR_QUAL_ID30, jwot.TERR_QUAL_ID31,
10537 jwot.TERR_QUAL_ID32, jwot.TERR_QUAL_ID33,jwot.TERR_QUAL_ID34,
10538 jwot.TERR_QUAL_ID35, jwot.TERR_QUAL_ID36, jwot.TERR_QUAL_ID37,
10539 jwot.TERR_QUAL_ID38, jwot.TERR_QUAL_ID39,
10540 jwot.TERR_QUAL_ID40, jwot.TERR_QUAL_ID41,
10541 jwot.TERR_QUAL_ID42, jwot.TERR_QUAL_ID43,jwot.TERR_QUAL_ID44,
10542 jwot.TERR_QUAL_ID45, jwot.TERR_QUAL_ID46, jwot.TERR_QUAL_ID47,
10543 jwot.TERR_QUAL_ID48, jwot.TERR_QUAL_ID49,
10544 jwot.TERR_QUAL_ID50, jwot.TERR_QUAL_ID51,
10545 jwot.TERR_QUAL_ID52, jwot.TERR_QUAL_ID53,jwot.TERR_QUAL_ID54,
10546 jwot.TERR_QUAL_ID55, jwot.TERR_QUAL_ID56, jwot.TERR_QUAL_ID57,
10547 jwot.TERR_QUAL_ID58, jwot.TERR_QUAL_ID59,
10548 jwot.TERR_QUAL_ID60, jwot.TERR_QUAL_ID61,
10549 jwot.TERR_QUAL_ID62, jwot.TERR_QUAL_ID63,jwot.TERR_QUAL_ID64,
10550 jwot.TERR_QUAL_ID65, jwot.TERR_QUAL_ID66, jwot.TERR_QUAL_ID67,
10551 jwot.TERR_QUAL_ID68, jwot.TERR_QUAL_ID69,
10552 jwot.TERR_QUAL_ID70, jwot.TERR_QUAL_ID71,
10553 jwot.TERR_QUAL_ID72, jwot.TERR_QUAL_ID73,jwot.TERR_QUAL_ID74,
10554 jwot.TERR_QUAL_ID75 )
10555 AND interface_type = l_intf_type
10556 and header = l_header
10557 and action_flag = l_action_flag
10558 and user_sequence = p_user_sequence;
10559
10560 EXCEPTION
10561 WHEN OTHERS THEN
10562 x_return_status := FND_API.G_RET_STS_ERROR;
10563 fnd_message.clear;
10564 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_DELETE_QUAL_VAL');
10565 X_Msg_Data := fnd_message.get();
10566
10567 forall i in l_Terr_Qual_Rec.TERR_QUAL_ID.first..l_Terr_Qual_Rec.TERR_QUAL_ID.last
10568 UPDATE JTY_WEBADI_OTH_TERR_INTF jwot
10569 SET STATUS = x_return_status,
10570 error_msg = 'U: ' || x_msg_data
10571 WHERE l_Terr_Qual_Rec.TERR_QUAL_ID(i) in
10572 ( jwot.TERR_QUAL_ID1, jwot.TERR_QUAL_ID2, jwot.TERR_QUAL_ID3,
10573 jwot.TERR_QUAL_ID4, jwot.TERR_QUAL_ID5, jwot.TERR_QUAL_ID6,
10574 jwot.TERR_QUAL_ID7, jwot.TERR_QUAL_ID8, jwot.TERR_QUAL_ID9,
10575 jwot.TERR_QUAL_ID10, jwot.TERR_QUAL_ID11, jwot.TERR_QUAL_ID12,
10576 jwot.TERR_QUAL_ID13, jwot.TERR_QUAL_ID14, jwot.TERR_QUAL_ID15,
10577 jwot.TERR_QUAL_ID16, jwot.TERR_QUAL_ID17, jwot.TERR_QUAL_ID18,
10578 jwot.TERR_QUAL_ID19, jwot.TERR_QUAL_ID20, jwot.TERR_QUAL_ID21,
10579 jwot.TERR_QUAL_ID22, jwot.TERR_QUAL_ID23,
10580 jwot.TERR_QUAL_ID24, jwot.TERR_QUAL_ID25, jwot.TERR_QUAL_ID26, jwot.TERR_QUAL_ID27,
10581 jwot.TERR_QUAL_ID28, jwot.TERR_QUAL_ID29,
10582 jwot.TERR_QUAL_ID30, jwot.TERR_QUAL_ID31,
10583 jwot.TERR_QUAL_ID32, jwot.TERR_QUAL_ID33,jwot.TERR_QUAL_ID34,
10584 jwot.TERR_QUAL_ID35, jwot.TERR_QUAL_ID36, jwot.TERR_QUAL_ID37,
10585 jwot.TERR_QUAL_ID38, jwot.TERR_QUAL_ID39,
10586 jwot.TERR_QUAL_ID40, jwot.TERR_QUAL_ID41,
10587 jwot.TERR_QUAL_ID42, jwot.TERR_QUAL_ID43,jwot.TERR_QUAL_ID44,
10588 jwot.TERR_QUAL_ID45, jwot.TERR_QUAL_ID46, jwot.TERR_QUAL_ID47,
10589 jwot.TERR_QUAL_ID48, jwot.TERR_QUAL_ID49,
10590 jwot.TERR_QUAL_ID50, jwot.TERR_QUAL_ID51,
10591 jwot.TERR_QUAL_ID52, jwot.TERR_QUAL_ID53,jwot.TERR_QUAL_ID54,
10592 jwot.TERR_QUAL_ID55, jwot.TERR_QUAL_ID56, jwot.TERR_QUAL_ID57,
10593 jwot.TERR_QUAL_ID58, jwot.TERR_QUAL_ID59,
10594 jwot.TERR_QUAL_ID60, jwot.TERR_QUAL_ID61,
10595 jwot.TERR_QUAL_ID62, jwot.TERR_QUAL_ID63,jwot.TERR_QUAL_ID64,
10596 jwot.TERR_QUAL_ID65, jwot.TERR_QUAL_ID66, jwot.TERR_QUAL_ID67,
10597 jwot.TERR_QUAL_ID68, jwot.TERR_QUAL_ID69,
10598 jwot.TERR_QUAL_ID70, jwot.TERR_QUAL_ID71,
10599 jwot.TERR_QUAL_ID72, jwot.TERR_QUAL_ID73,jwot.TERR_QUAL_ID74,
10600 jwot.TERR_QUAL_ID75 )
10601 AND interface_type = l_intf_type
10602 and header = l_header
10603 and action_flag = l_action_flag
10604 and user_sequence = p_user_sequence;
10605 END;
10606 end if; --get_d_terr_value_csr
10607
10608 update JTY_WEBADI_OTH_TERR_INTF
10609 set status = x_return_status
10610 where interface_type = l_intf_type
10611 and header = l_header
10612 and status is null
10613 and user_sequence = p_user_sequence;
10614
10615 END UPDATE_TERR_QUAL;
10616
10617 PROCEDURE UPDATE_TERR_RSC(
10618 P_USER_SEQUENCE IN NUMBER,
10619 --p_action_flag IN VARCHAR2,
10620 x_return_status out nocopy varchar2,
10621 x_msg_data out nocopy varchar2
10622 ) IS
10623
10624 cursor GET_RSC_CSR(
10625 v_user_sequence number,
10626 v_intf_type varchar2,
10627 v_header varchar2,
10628 v_action_flag varchar2) IS
10629 SELECT jwot.LAY_SEQ_NUM, jwr.TERR_RSC_ID,
10630 jwot.LAST_UPDATE_DATE, jwot.LAST_UPDATED_BY, jwot.CREATION_DATE,
10631 jwot.CREATED_BY, jwot.LAST_UPDATE_LOGIN,
10632 jwot.TERR_ID, jwr.resource_id,
10633 decode(jwr.resource_type,0, 'RS_'||res.category,
10634 --decode(res.category, 'PARTNER', 'RS_PARTNER', 'EMPLOYEE', 'RS_EMPLOYEE',NULL)
10635 1,'RS_GROUP',2,'RS_TEAM',3,'RS_ROLE', null) RESOURCE_TYPE,
10636 jwr.role_code, null PRIMARY_CONTACT_FLAG,
10637 NVL(jwr.RES_START_DATE, jwot.TERR_START_DATE) START_DATE_ACTIVE,
10638 NVL(jwr.RES_END_DATE, jwot.TERR_END_DATE) END_DATE_ACTIVE,
10639 jwot.org_id, 'N' FULL_ACCESS_FLAG,
10640 jwr.group_id, NULL SECURITY_GROUP_ID,
10641 res.source_id person_id, NULL OBJECT_VERSION_NUMBER,
10642 jwr.ATTRIBUTE_CATEGORY, jwr.ATTRIBUTE1, jwr.ATTRIBUTE2,
10643 jwr.ATTRIBUTE3, jwr.ATTRIBUTE4, jwr.ATTRIBUTE5,
10644 jwr.ATTRIBUTE6, jwr.ATTRIBUTE7, jwr.ATTRIBUTE8,
10645 jwr.ATTRIBUTE9, jwr.ATTRIBUTE10, jwr.ATTRIBUTE11,
10646 jwr.ATTRIBUTE12, jwr.ATTRIBUTE13, jwr.ATTRIBUTE14,
10647 jwr.ATTRIBUTE15
10648 from
10649 JTY_WEBADI_OTH_TERR_INTF jwot,
10650 JTY_WEBADI_RESOURCES jwr,
10651 jtf_rs_resource_extns res
10652 where jwr.RESOURCE_ID = res.resource_id(+)
10653 and jwr.user_sequence = jwot.user_sequence
10654 and jwr.interface_type = jwot.interface_type
10655 and jwot.lay_seq_num = jwr.lay_seq_num
10656 and jwot.user_sequence = v_user_sequence
10657 and jwot.interface_type = v_intf_type
10658 and jwot.header = v_header
10659 and jwot.status is null
10660 and jwr.header = jwot.header
10661 and jwot.action_flag = v_action_flag;
10662
10663 cursor get_c_rsc_access_csr(
10664 v_user_sequence number,
10665 v_header varchar2,
10666 v_intf_type varchar2) is
10667 select sub.TERR_RSC_ACCESS_ID,
10668 jwot.LAST_UPDATE_DATE, jwot.LAST_UPDATED_BY,
10669 jwot.CREATION_DATE, jwot.CREATED_BY, jwot.LAST_UPDATE_LOGIN,
10670 sub.TERR_RSC_ID, jq.QUAL_TYPE_NAME ACCESS_TYPE,
10671 jwot.ORG_ID, sub.TRANS_ACCESS_CODE
10672 from JTY_WEBADI_QUAL_TYPE_HEADER jq,
10673 JTY_WEBADI_OTH_TERR_INTF jwot,
10674 (
10675 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10676 1 qual_type_num, TERR_RSC_ACCESS_ID1 TERR_RSC_ACCESS_ID,
10677 TRANS_ACCESS_CODE1 TRANS_ACCESS_CODE
10678 FROM JTY_WEBADI_RESOURCES jut
10679 where jut.USER_SEQUENCE = v_user_sequence
10680 and jut.TRANS_ACCESS_CODE1 is not null
10681 and jut.TERR_RSC_ACCESS_ID1 is null
10682 and jut.header = v_header
10683 and jut.INTERFACE_TYPE = v_intf_type
10684 union all
10685 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10686 2 qual_type_num, TERR_RSC_ACCESS_ID2 TERR_RSC_ACCESS_ID,
10687 TRANS_ACCESS_CODE2 TRANS_ACCESS_CODE
10688 FROM JTY_WEBADI_RESOURCES jut
10689 where jut.USER_SEQUENCE = v_user_sequence
10690 and jut.TRANS_ACCESS_CODE2 is not null
10691 and jut.TERR_RSC_ACCESS_ID2 is null
10692 and jut.header = v_header
10693 and jut.INTERFACE_TYPE = v_intf_type
10694 union all
10695 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10696 3 qual_type_num, TERR_RSC_ACCESS_ID3 TERR_RSC_ACCESS_ID,
10697 TRANS_ACCESS_CODE3 TRANS_ACCESS_CODE
10698 FROM JTY_WEBADI_RESOURCES jut
10699 where jut.USER_SEQUENCE = v_user_sequence
10700 and jut.TRANS_ACCESS_CODE3 is not null
10701 and jut.TERR_RSC_ACCESS_ID3 is null
10702 and jut.header = v_header
10703 and jut.INTERFACE_TYPE = v_intf_type
10704 union all
10705 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10706 4 qual_type_num, TERR_RSC_ACCESS_ID4 TERR_RSC_ACCESS_ID,
10707 TRANS_ACCESS_CODE4 TRANS_ACCESS_CODE
10708 FROM JTY_WEBADI_RESOURCES jut
10709 where jut.USER_SEQUENCE = v_user_sequence
10710 and jut.TRANS_ACCESS_CODE4 is not null
10711 and jut.TERR_RSC_ACCESS_ID4 is null
10712 and jut.header = v_header
10713 and jut.INTERFACE_TYPE = v_intf_type
10714 union all
10715 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10716 5 qual_type_num, TERR_RSC_ACCESS_ID5 TERR_RSC_ACCESS_ID,
10717 TRANS_ACCESS_CODE5 TRANS_ACCESS_CODE
10718 FROM JTY_WEBADI_RESOURCES jut
10719 where jut.USER_SEQUENCE = v_user_sequence
10720 and jut.TRANS_ACCESS_CODE5 is not null
10721 and jut.TERR_RSC_ACCESS_ID5 is null
10722 and jut.header = v_header
10723 and jut.INTERFACE_TYPE = v_intf_type
10724 union all
10725 select user_sequence, TERR_RSC_ID,lay_seq_num, header,
10726 6 qual_type_num, TERR_RSC_ACCESS_ID6 TERR_RSC_ACCESS_ID,
10727 TRANS_ACCESS_CODE6 TRANS_ACCESS_CODE
10728 FROM JTY_WEBADI_RESOURCES jut
10729 where jut.USER_SEQUENCE = v_user_sequence
10730 and jut.TRANS_ACCESS_CODE6 is not null
10731 and jut.TERR_RSC_ACCESS_ID6 is null
10732 and jut.header = v_header
10733 and jut.INTERFACE_TYPE = v_intf_type
10734 union all
10735 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10736 7 qual_type_num, TERR_RSC_ACCESS_ID7 TERR_RSC_ACCESS_ID,
10737 TRANS_ACCESS_CODE7 TRANS_ACCESS_CODE
10738 FROM JTY_WEBADI_RESOURCES jut
10739 where jut.USER_SEQUENCE = v_user_sequence
10740 and jut.TRANS_ACCESS_CODE7 is not null
10741 and jut.TERR_RSC_ACCESS_ID7 is null
10742 and jut.header = v_header
10743 and jut.INTERFACE_TYPE = v_intf_type
10744 union all
10745 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10746 8 qual_type_num, TERR_RSC_ACCESS_ID8 TERR_RSC_ACCESS_ID,
10747 TRANS_ACCESS_CODE8 TRANS_ACCESS_CODE
10748 FROM JTY_WEBADI_RESOURCES jut
10749 where jut.USER_SEQUENCE = v_user_sequence
10750 and jut.TRANS_ACCESS_CODE8 is not null
10751 and jut.TERR_RSC_ACCESS_ID8 is null
10752 and jut.header = v_header
10753 and jut.INTERFACE_TYPE = v_intf_type
10754 union all
10755 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10756 9 qual_type_num, TERR_RSC_ACCESS_ID9 TERR_RSC_ACCESS_ID,
10757 TRANS_ACCESS_CODE9 TRANS_ACCESS_CODE
10758 FROM JTY_WEBADI_RESOURCES jut
10759 where jut.USER_SEQUENCE = v_user_sequence
10760 and jut.TRANS_ACCESS_CODE9 is not null
10761 and jut.TERR_RSC_ACCESS_ID9 is null
10762 and jut.header = v_header
10763 and jut.INTERFACE_TYPE = v_intf_type
10764 union all
10765 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10766 10 qual_type_num, TERR_RSC_ACCESS_ID10 TERR_RSC_ACCESS_ID,
10767 TRANS_ACCESS_CODE10 TRANS_ACCESS_CODE
10768 FROM JTY_WEBADI_RESOURCES jut
10769 where jut.USER_SEQUENCE = v_user_sequence
10770 and jut.TRANS_ACCESS_CODE10 is not null
10771 and jut.TERR_RSC_ACCESS_ID10 is null
10772 and jut.header = v_header
10773 and jut.INTERFACE_TYPE = v_intf_type) sub
10774 where sub.user_sequence = jq.user_sequence
10775 and sub.qual_type_num = jq.QUAL_TYPE_NUM
10776 and sub.lay_seq_num = jwot.lay_seq_num
10777 and sub.user_sequence = jwot.user_sequence
10778 and sub.header = jwot.header
10779 and jwot.interface_type = v_intf_type
10780 and jwot.status is null;
10781
10782 cursor get_u_rsc_access_csr(
10783 v_user_sequence number,
10784 v_header varchar2,
10785 v_intf_type varchar2) is
10786 select sub.TERR_RSC_ACCESS_ID,
10787 jwot.LAST_UPDATE_DATE, jwot.LAST_UPDATED_BY,
10788 jwot.CREATION_DATE, jwot.CREATED_BY, jwot.LAST_UPDATE_LOGIN,
10789 sub.TERR_RSC_ID, jq.QUAL_TYPE_NAME ACCESS_TYPE,
10790 jwot.ORG_ID, sub.TRANS_ACCESS_CODE
10791 from JTY_WEBADI_QUAL_TYPE_HEADER jq,
10792 JTY_WEBADI_OTH_TERR_INTF jwot,
10793 (
10794 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10795 1 qual_type_num, TERR_RSC_ACCESS_ID1 TERR_RSC_ACCESS_ID,
10796 TRANS_ACCESS_CODE1 TRANS_ACCESS_CODE
10797 FROM JTY_WEBADI_RESOURCES jut
10798 where jut.USER_SEQUENCE = v_user_sequence
10799 and jut.TRANS_ACCESS_CODE1 is not null
10800 and jut.TERR_RSC_ACCESS_ID1 is not null
10801 and jut.header = v_header
10802 and jut.INTERFACE_TYPE = v_intf_type
10803 union all
10804 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10805 2 qual_type_num, TERR_RSC_ACCESS_ID2 TERR_RSC_ACCESS_ID,
10806 TRANS_ACCESS_CODE2 TRANS_ACCESS_CODE
10807 FROM JTY_WEBADI_RESOURCES jut
10808 where jut.USER_SEQUENCE = v_user_sequence
10809 and jut.TRANS_ACCESS_CODE2 is not null
10810 and jut.TERR_RSC_ACCESS_ID2 is not null
10811 and jut.header = v_header
10812 and jut.INTERFACE_TYPE = v_intf_type
10813 union all
10814 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10815 3 qual_type_num, TERR_RSC_ACCESS_ID3 TERR_RSC_ACCESS_ID,
10816 TRANS_ACCESS_CODE3 TRANS_ACCESS_CODE
10817 FROM JTY_WEBADI_RESOURCES jut
10818 where jut.USER_SEQUENCE = v_user_sequence
10819 and jut.TRANS_ACCESS_CODE3 is not null
10820 and jut.TERR_RSC_ACCESS_ID3 is not null
10821 and jut.header = v_header
10822 and jut.INTERFACE_TYPE = v_intf_type
10823 union all
10824 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10825 4 qual_type_num, TERR_RSC_ACCESS_ID4 TERR_RSC_ACCESS_ID,
10826 TRANS_ACCESS_CODE4 TRANS_ACCESS_CODE
10827 FROM JTY_WEBADI_RESOURCES jut
10828 where jut.USER_SEQUENCE = v_user_sequence
10829 and jut.TRANS_ACCESS_CODE4 is not null
10830 and jut.TERR_RSC_ACCESS_ID4 is not null
10831 and jut.header = v_header
10832 and jut.INTERFACE_TYPE = v_intf_type
10833 union all
10834 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10835 5 qual_type_num, TERR_RSC_ACCESS_ID5 TERR_RSC_ACCESS_ID,
10836 TRANS_ACCESS_CODE5 TRANS_ACCESS_CODE
10837 FROM JTY_WEBADI_RESOURCES jut
10838 where jut.USER_SEQUENCE = v_user_sequence
10839 and jut.TRANS_ACCESS_CODE5 is not null
10840 and jut.TERR_RSC_ACCESS_ID5 is not null
10841 and jut.header = v_header
10842 and jut.INTERFACE_TYPE = v_intf_type
10843 union all
10844 select user_sequence, TERR_RSC_ID,lay_seq_num, header,
10845 6 qual_type_num, TERR_RSC_ACCESS_ID6 TERR_RSC_ACCESS_ID,
10846 TRANS_ACCESS_CODE6 TRANS_ACCESS_CODE
10847 FROM JTY_WEBADI_RESOURCES jut
10848 where jut.USER_SEQUENCE = v_user_sequence
10849 and jut.TRANS_ACCESS_CODE6 is not null
10850 and jut.TERR_RSC_ACCESS_ID6 is not null
10851 and jut.header = v_header
10852 and jut.INTERFACE_TYPE = v_intf_type
10853 union all
10854 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10855 7 qual_type_num, TERR_RSC_ACCESS_ID7 TERR_RSC_ACCESS_ID,
10856 TRANS_ACCESS_CODE7 TRANS_ACCESS_CODE
10857 FROM JTY_WEBADI_RESOURCES jut
10858 where jut.USER_SEQUENCE = v_user_sequence
10859 and jut.TRANS_ACCESS_CODE7 is not null
10860 and jut.TERR_RSC_ACCESS_ID7 is not null
10861 and jut.header = v_header
10862 and jut.INTERFACE_TYPE = v_intf_type
10863 union all
10864 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10865 8 qual_type_num, TERR_RSC_ACCESS_ID8 TERR_RSC_ACCESS_ID,
10866 TRANS_ACCESS_CODE8 TRANS_ACCESS_CODE
10867 FROM JTY_WEBADI_RESOURCES jut
10868 where jut.USER_SEQUENCE = v_user_sequence
10869 and jut.TRANS_ACCESS_CODE8 is not null
10870 and jut.TERR_RSC_ACCESS_ID8 is not null
10871 and jut.header = v_header
10872 and jut.INTERFACE_TYPE = v_intf_type
10873 union all
10874 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10875 9 qual_type_num, TERR_RSC_ACCESS_ID9 TERR_RSC_ACCESS_ID,
10876 TRANS_ACCESS_CODE9 TRANS_ACCESS_CODE
10877 FROM JTY_WEBADI_RESOURCES jut
10878 where jut.USER_SEQUENCE = v_user_sequence
10879 and jut.TRANS_ACCESS_CODE9 is not null
10880 and jut.TERR_RSC_ACCESS_ID9 is not null
10881 and jut.header = v_header
10882 and jut.INTERFACE_TYPE = v_intf_type
10883 union all
10884 select user_sequence, TERR_RSC_ID, lay_seq_num, header,
10885 10 qual_type_num, TERR_RSC_ACCESS_ID10 TERR_RSC_ACCESS_ID,
10886 TRANS_ACCESS_CODE10 TRANS_ACCESS_CODE
10887 FROM JTY_WEBADI_RESOURCES jut
10888 where jut.USER_SEQUENCE = v_user_sequence
10889 and jut.TRANS_ACCESS_CODE10 is not null
10890 and jut.TERR_RSC_ACCESS_ID10 is not null
10891 and jut.header = v_header
10892 and jut.INTERFACE_TYPE = v_intf_type) sub
10893 where sub.user_sequence = jq.user_sequence
10894 and sub.qual_type_num = jq.QUAL_TYPE_NUM
10895 and sub.lay_seq_num = jwot.lay_seq_num
10896 and sub.user_sequence = jwot.user_sequence
10897 and sub.header = jwot.header
10898 and jwot.interface_type = v_intf_type
10899 and jwot.status is null;
10900
10901 TYPE rsc_rec_type IS RECORD
10902 ( LAY_SEQ_NUM number_tbl_type,
10903 TERR_RSC_ID number_tbl_type,
10904 LAST_UPDATE_DATE date_tbl_type,
10905 LAST_UPDATED_BY number_tbl_type,
10906 CREATION_DATE date_tbl_type,
10907 CREATED_BY number_tbl_type,
10908 LAST_UPDATE_LOGIN number_tbl_type,
10909 TERR_ID number_tbl_type,
10910 RESOURCE_ID number_tbl_type,
10911 RESOURCE_TYPE varchar2_tbl_type,
10912 ROLE_CODE varchar2_tbl_type,
10913 PRIMARY_CONTACT_FLAG varchar2_tbl_type,
10914 START_DATE_ACTIVE date_tbl_type,
10915 END_DATE_ACTIVE date_tbl_type,
10916 ORG_ID number_tbl_type,
10917 FULL_ACCESS_FLAG varchar2_tbl_type,
10918 GROUP_ID number_tbl_type,
10919 SECURITY_GROUP_ID number_tbl_type,
10920 PERSON_ID number_tbl_type,
10921 OBJECT_VERSION_NUMBER number_tbl_type,
10922 ATTRIBUTE_CATEGORY varchar2_tbl_type,
10923 ATTRIBUTE1 varchar2_tbl_type,
10924 ATTRIBUTE2 varchar2_tbl_type,
10925 ATTRIBUTE3 varchar2_tbl_type,
10926 ATTRIBUTE4 varchar2_tbl_type,
10927 ATTRIBUTE5 varchar2_tbl_type,
10928 ATTRIBUTE6 varchar2_tbl_type,
10929 ATTRIBUTE7 varchar2_tbl_type,
10930 ATTRIBUTE8 varchar2_tbl_type,
10931 ATTRIBUTE9 varchar2_tbl_type,
10932 ATTRIBUTE10 varchar2_tbl_type,
10933 ATTRIBUTE11 varchar2_tbl_type,
10934 ATTRIBUTE12 varchar2_tbl_type,
10935 ATTRIBUTE13 varchar2_tbl_type,
10936 ATTRIBUTE14 varchar2_tbl_type,
10937 ATTRIBUTE15 varchar2_tbl_type
10938 );
10939
10940 TYPE rsc_access_rec_type IS RECORD(
10941 TERR_RSC_ACCESS_ID number_tbl_type,
10942 LAST_UPDATE_DATE date_tbl_type,
10943 LAST_UPDATED_BY number_tbl_type,
10944 CREATION_DATE date_tbl_type,
10945 CREATED_BY number_tbl_type,
10946 LAST_UPDATE_LOGIN number_tbl_type,
10947 TERR_RSC_ID number_tbl_type,
10948 ACCESS_TYPE varchar2_tbl_type,
10949 TRANS_ACCESS_CODE varchar2_tbl_type,
10950 ORG_ID number_tbl_type);
10951
10952 l_rsc_rec rsc_rec_type;
10953 l_get_terr_rsc_rec rsc_rec_type;
10954 l_rsc_access_rec rsc_access_rec_type;
10955
10956 l_header varchar2(15) := 'RSC';
10957 l_intf_type varchar2(1) := 'U';
10958 l_action_flag varchar2(1);
10959 l_api_version_number CONSTANT NUMBER := 1.0;
10960 X_Msg_Count number;
10961
10962 -- cursor below has been added for bug 8295746
10963 CURSOR GET_RSC_TERR_CSR(
10964 v_user_sequence number,
10965 v_intf_type varchar2,
10966 v_header varchar2,
10967 v_action_flag varchar2) IS
10968 SELECT DISTINCT jwot.TERR_ID
10969 from
10970 JTY_WEBADI_OTH_TERR_INTF jwot,
10971 JTY_WEBADI_RESOURCES jwr,
10972 jtf_rs_resource_extns res
10973 where jwr.RESOURCE_ID = res.resource_id(+)
10974 and jwr.user_sequence = jwot.user_sequence
10975 and jwr.interface_type = jwot.interface_type
10976 and jwot.lay_seq_num = jwr.lay_seq_num
10977 and jwot.user_sequence = v_user_sequence
10978 and jwot.interface_type = v_intf_type
10979 and jwot.header = v_header
10980 and jwot.status is null
10981 and jwr.header = jwot.header
10982 and jwot.action_flag = v_action_flag;
10983
10984 BEGIN
10985
10986 --l_action_flag := p_action_flag;
10987 x_return_status := FND_API.G_RET_STS_SUCCESS;
10988 l_action_flag := 'C';
10989
10990 -- process resource records
10991 open get_rsc_csr(p_user_sequence, l_intf_type, l_header, l_action_flag);
10992 fetch get_rsc_csr bulk collect into l_rsc_rec.LAY_SEQ_NUM,
10993 l_rsc_rec.TERR_RSC_ID, l_rsc_rec.LAST_UPDATE_DATE, l_rsc_rec.LAST_UPDATED_BY,
10994 l_rsc_rec.CREATION_DATE, l_rsc_rec.CREATED_BY, l_rsc_rec.LAST_UPDATE_LOGIN,
10995 l_rsc_rec.TERR_ID, l_rsc_rec.RESOURCE_ID, l_rsc_rec.RESOURCE_TYPE,
10996 l_rsc_rec.ROLE_CODE, l_rsc_rec.PRIMARY_CONTACT_FLAG, l_rsc_rec.START_DATE_ACTIVE,
10997 l_rsc_rec.END_DATE_ACTIVE, l_rsc_rec.ORG_ID, l_rsc_rec.FULL_ACCESS_FLAG,
10998 l_rsc_rec.GROUP_ID, l_rsc_rec.SECURITY_GROUP_ID, l_rsc_rec.PERSON_ID,
10999 l_rsc_rec.OBJECT_VERSION_NUMBER, l_rsc_rec.ATTRIBUTE_CATEGORY, l_rsc_rec.ATTRIBUTE1,
11000 l_rsc_rec.ATTRIBUTE2, l_rsc_rec.ATTRIBUTE3, l_rsc_rec.ATTRIBUTE4,
11001 l_rsc_rec.ATTRIBUTE5, l_rsc_rec.ATTRIBUTE6, l_rsc_rec.ATTRIBUTE7,
11002 l_rsc_rec.ATTRIBUTE8, l_rsc_rec.ATTRIBUTE9, l_rsc_rec.ATTRIBUTE10,
11003 l_rsc_rec.ATTRIBUTE11, l_rsc_rec.ATTRIBUTE12, l_rsc_rec.ATTRIBUTE13,
11004 l_rsc_rec.ATTRIBUTE14, l_rsc_rec.ATTRIBUTE15;
11005 close get_rsc_csr;
11006
11007 -- direct insert into the table since the package JTF_TERRITORY_RESOURCE_PVT
11008 -- doesnot support flex field insert
11009 if (l_action_flag = 'C' AND l_rsc_rec.RESOURCE_ID.count > 0) then
11010 --dbms_output.put_line('Create territory resource information, rowcount: ' || l_rsc_rec.RESOURCE_ID.count);
11011 forall i in l_rsc_rec.RESOURCE_ID.first..l_rsc_rec.RESOURCE_ID.last
11012 INSERT INTO JTF_TERR_RSC_ALL (
11013 TERR_RSC_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY,
11014 CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN,
11015 TERR_ID, RESOURCE_ID, RESOURCE_TYPE,
11016 ROLE, PRIMARY_CONTACT_FLAG, START_DATE_ACTIVE,
11017 END_DATE_ACTIVE, ORG_ID, FULL_ACCESS_FLAG,
11018 GROUP_ID, SECURITY_GROUP_ID, PERSON_ID,
11019 OBJECT_VERSION_NUMBER, ATTRIBUTE_CATEGORY, ATTRIBUTE1,
11020 ATTRIBUTE2, ATTRIBUTE3, ATTRIBUTE4,
11021 ATTRIBUTE5, ATTRIBUTE6, ATTRIBUTE7,
11022 ATTRIBUTE8, ATTRIBUTE9, ATTRIBUTE10,
11023 ATTRIBUTE11, ATTRIBUTE12, ATTRIBUTE13,
11024 ATTRIBUTE14, ATTRIBUTE15)
11025 VALUES ( JTF_TERR_RSC_s.nextval, l_rsc_rec.LAST_UPDATE_DATE(i),
11026 l_rsc_rec.LAST_UPDATED_BY(i), l_rsc_rec.CREATION_DATE(i),
11027 l_rsc_rec.CREATED_BY(i), l_rsc_rec.LAST_UPDATE_LOGIN(i),
11028 l_rsc_rec.TERR_ID(i), l_rsc_rec.RESOURCE_ID(i), l_rsc_rec.RESOURCE_TYPE(i),
11029 l_rsc_rec.ROLE_CODE(i), l_rsc_rec.PRIMARY_CONTACT_FLAG(i), l_rsc_rec.START_DATE_ACTIVE(i),
11030 l_rsc_rec.END_DATE_ACTIVE(i), l_rsc_rec.ORG_ID(i), l_rsc_rec.FULL_ACCESS_FLAG(i),
11031 l_rsc_rec.GROUP_ID(i), l_rsc_rec.SECURITY_GROUP_ID(i), l_rsc_rec.PERSON_ID(i),
11032 l_rsc_rec.OBJECT_VERSION_NUMBER(i), l_rsc_rec.ATTRIBUTE_CATEGORY(i), l_rsc_rec.ATTRIBUTE1(i),
11033 l_rsc_rec.ATTRIBUTE2(i), l_rsc_rec.ATTRIBUTE3(i), l_rsc_rec.ATTRIBUTE4(i),
11034 l_rsc_rec.ATTRIBUTE5(i), l_rsc_rec.ATTRIBUTE6(i), l_rsc_rec.ATTRIBUTE7(i),
11035 l_rsc_rec.ATTRIBUTE8(i), l_rsc_rec.ATTRIBUTE9(i), l_rsc_rec.ATTRIBUTE10(i),
11036 l_rsc_rec.ATTRIBUTE11(i), l_rsc_rec.ATTRIBUTE12(i), l_rsc_rec.ATTRIBUTE13(i),
11037 l_rsc_rec.ATTRIBUTE14(i), l_rsc_rec.ATTRIBUTE15(i) )
11038 RETURNING terr_rsc_id, resource_id, terr_id
11039 bulk collect into l_get_terr_rsc_rec.terr_rsc_id,
11040 l_get_terr_rsc_rec.resource_id, l_get_terr_rsc_rec.terr_id;
11041
11042 --dbms_output.put_line(' # records processed for create: '||SQL%ROWCOUNT);
11043
11044 if (l_get_terr_rsc_rec.terr_rsc_id.count > 0) then
11045 forall i in l_get_terr_rsc_rec.terr_rsc_id.first..l_get_terr_rsc_rec.terr_rsc_id.last
11046 update JTY_WEBADI_RESOURCES
11047 set terr_rsc_id = l_get_terr_rsc_rec.terr_rsc_id(i)
11048 where resource_id = l_get_terr_rsc_rec.resource_id(i)
11049 -- and terr_id = l_get_terr_rsc_rec.terr_id(i)
11050 and interface_type = l_intf_type
11051 and user_sequence = p_user_sequence
11052 and header = l_header
11053 and terr_rsc_id is null;
11054 end if;
11055
11056 end if;
11057
11058 l_action_flag := 'U';
11059
11060 -- process resource records
11061 open get_rsc_csr(p_user_sequence, l_intf_type, l_header, l_action_flag);
11062 fetch get_rsc_csr bulk collect into l_rsc_rec.LAY_SEQ_NUM,
11063 l_rsc_rec.TERR_RSC_ID, l_rsc_rec.LAST_UPDATE_DATE, l_rsc_rec.LAST_UPDATED_BY,
11064 l_rsc_rec.CREATION_DATE, l_rsc_rec.CREATED_BY, l_rsc_rec.LAST_UPDATE_LOGIN,
11065 l_rsc_rec.TERR_ID, l_rsc_rec.RESOURCE_ID, l_rsc_rec.RESOURCE_TYPE,
11066 l_rsc_rec.ROLE_CODE, l_rsc_rec.PRIMARY_CONTACT_FLAG, l_rsc_rec.START_DATE_ACTIVE,
11067 l_rsc_rec.END_DATE_ACTIVE, l_rsc_rec.ORG_ID, l_rsc_rec.FULL_ACCESS_FLAG,
11068 l_rsc_rec.GROUP_ID, l_rsc_rec.SECURITY_GROUP_ID, l_rsc_rec.PERSON_ID,
11069 l_rsc_rec.OBJECT_VERSION_NUMBER, l_rsc_rec.ATTRIBUTE_CATEGORY, l_rsc_rec.ATTRIBUTE1,
11070 l_rsc_rec.ATTRIBUTE2, l_rsc_rec.ATTRIBUTE3, l_rsc_rec.ATTRIBUTE4,
11071 l_rsc_rec.ATTRIBUTE5, l_rsc_rec.ATTRIBUTE6, l_rsc_rec.ATTRIBUTE7,
11072 l_rsc_rec.ATTRIBUTE8, l_rsc_rec.ATTRIBUTE9, l_rsc_rec.ATTRIBUTE10,
11073 l_rsc_rec.ATTRIBUTE11, l_rsc_rec.ATTRIBUTE12, l_rsc_rec.ATTRIBUTE13,
11074 l_rsc_rec.ATTRIBUTE14, l_rsc_rec.ATTRIBUTE15;
11075 close get_rsc_csr;
11076
11077 -- direct insert into the table since the package JTF_TERRITORY_RESOURCE_PVT
11078 -- doesnot support flex field insert
11079 if (l_action_flag = 'U' AND l_rsc_rec.TERR_RSC_ID.count > 0) then
11080 --dbms_output.put_line('Update territory resource information, rowcount: ' || l_rsc_rec.TERR_RSC_ID.count);
11081
11082 forall i in l_rsc_rec.TERR_RSC_ID.first..l_rsc_rec.TERR_RSC_ID.last
11083 UPDATE JTF_TERR_RSC_ALL
11084 SET LAST_UPDATE_DATE = l_rsc_rec.LAST_UPDATE_DATE(i),
11085 LAST_UPDATED_BY = l_rsc_rec.LAST_UPDATED_BY(i),
11086 LAST_UPDATE_LOGIN = l_rsc_rec.LAST_UPDATE_LOGIN(i),
11087 TERR_ID = l_rsc_rec.TERR_ID(i),
11088 RESOURCE_ID = l_rsc_rec.RESOURCE_ID(i),
11089 RESOURCE_TYPE = l_rsc_rec.RESOURCE_TYPE(i),
11090 ROLE = l_rsc_rec.ROLE_CODE(i),
11091 START_DATE_ACTIVE = l_rsc_rec.START_DATE_ACTIVE(i),
11092 END_DATE_ACTIVE = l_rsc_rec.END_DATE_ACTIVE(i),
11093 ORG_ID = l_rsc_rec.ORG_ID(i),
11094 GROUP_ID = l_rsc_rec.GROUP_ID(i),
11095 PERSON_ID = l_rsc_rec.PERSON_ID(i),
11096 ATTRIBUTE_CATEGORY = l_rsc_rec.ATTRIBUTE_CATEGORY(i),
11097 ATTRIBUTE1 = l_rsc_rec.ATTRIBUTE1(i),
11098 ATTRIBUTE2 = l_rsc_rec.ATTRIBUTE2(i),
11099 ATTRIBUTE3 = l_rsc_rec.ATTRIBUTE3(i),
11100 ATTRIBUTE4 = l_rsc_rec.ATTRIBUTE4(i),
11101 ATTRIBUTE5 = l_rsc_rec.ATTRIBUTE5(i),
11102 ATTRIBUTE6 = l_rsc_rec.ATTRIBUTE6(i),
11103 ATTRIBUTE7 = l_rsc_rec.ATTRIBUTE7(i),
11104 ATTRIBUTE8 = l_rsc_rec.ATTRIBUTE8(i),
11105 ATTRIBUTE9 = l_rsc_rec.ATTRIBUTE9(i),
11106 ATTRIBUTE10 = l_rsc_rec.ATTRIBUTE10(i),
11107 ATTRIBUTE11 = l_rsc_rec.ATTRIBUTE11(i),
11108 ATTRIBUTE12 = l_rsc_rec.ATTRIBUTE12(i),
11109 ATTRIBUTE13 = l_rsc_rec.ATTRIBUTE13(i),
11110 ATTRIBUTE14 = l_rsc_rec.ATTRIBUTE14(i),
11111 ATTRIBUTE15 = l_rsc_rec.ATTRIBUTE15(i)
11112 WHERE TERR_RSC_ID = l_rsc_rec.TERR_RSC_ID(i);
11113
11114 --dbms_output.put_line(' # records processed for update: '||SQL%ROWCOUNT);
11115 end if;
11116
11117 --Added for bug 8295746
11118 FOR rsc_terr_id IN GET_RSC_TERR_CSR(p_user_sequence, l_intf_type, l_header, l_action_flag)
11119 LOOP
11120 JTY_TERR_ENGINE_GEN_PVT.update_resource_person_id( p_terr_id => rsc_terr_id.terr_id );
11121 END LOOP;
11122 -- End of addition
11123
11124 BEGIN
11125 x_return_status := FND_API.G_RET_STS_SUCCESS;
11126 open get_c_rsc_access_csr(P_USER_SEQUENCE, l_header, l_intf_type);
11127 fetch get_c_rsc_access_csr bulk collect into l_rsc_access_rec.TERR_RSC_ACCESS_ID,
11128 l_rsc_access_rec.LAST_UPDATE_DATE, l_rsc_access_rec.LAST_UPDATED_BY,
11129 l_rsc_access_rec.CREATION_DATE, l_rsc_access_rec.CREATED_BY,
11130 l_rsc_access_rec.LAST_UPDATE_LOGIN,
11131 l_rsc_access_rec.TERR_RSC_ID, l_rsc_access_rec.ACCESS_TYPE,
11132 l_rsc_access_rec.ORG_ID, l_rsc_access_rec.TRANS_ACCESS_CODE;
11133 close get_c_rsc_access_csr;
11134
11135 --dbms_output.put_line('Add Access to resource_id: '||l_terr_rsc_out_tbl(i).terr_rsc_id ||',access count: '||l_tr_access_tbl.count );
11136 if l_rsc_access_rec.TERR_RSC_ID.count > 0 then
11137 forall i in l_rsc_access_rec.TERR_RSC_ID.first..l_rsc_access_rec.TERR_RSC_ID.last
11138 INSERT INTO JTF_TERR_RSC_ACCESS_ALL(
11139 TERR_RSC_ACCESS_ID,
11140 LAST_UPDATE_DATE,
11141 LAST_UPDATED_BY,
11142 CREATION_DATE,
11143 CREATED_BY,
11144 LAST_UPDATE_LOGIN,
11145 TERR_RSC_ID,
11146 ACCESS_TYPE,
11147 TRANS_ACCESS_CODE,
11148 ORG_ID)
11149 VALUES (
11150 JTF_TERR_RSC_ACCESS_s.nextval,
11151 l_rsc_access_rec.LAST_UPDATE_DATE(i),
11152 l_rsc_access_rec.LAST_UPDATED_BY(i),
11153 l_rsc_access_rec.CREATION_DATE(i),
11154 l_rsc_access_rec.CREATED_BY(i),
11155 l_rsc_access_rec.LAST_UPDATE_LOGIN(i),
11156 l_rsc_access_rec.TERR_RSC_ID(i),
11157 l_rsc_access_rec.ACCESS_TYPE(i),
11158 l_rsc_access_rec.TRANS_ACCESS_CODE(i),
11159 l_rsc_access_rec.ORG_ID(i)
11160 );
11161
11162 forall i in l_rsc_access_rec.TERR_RSC_ID.first..l_rsc_access_rec.TERR_RSC_ID.last
11163 update JTY_WEBADI_OTH_TERR_INTF jwot
11164 set status = x_return_status
11165 where exists
11166 (select 1 from JTY_WEBADI_RESOURCES jwr
11167 where jwr.LAY_SEQ_NUM = jwot.LAY_SEQ_NUM
11168 and jwr.header = jwot.header
11169 and jwr.user_sequence = jwot.user_sequence
11170 and jwr.interface_type = jwot.interface_type
11171 and jwr.terr_rsc_id+0 = l_rsc_access_rec.terr_rsc_id(i))
11172 and jwot.USER_SEQUENCE = p_user_sequence
11173 and jwot.header = l_header
11174 and jwot.interface_type = l_intf_type
11175 and jwot.lay_seq_num is not null
11176 and jwot.status is null;
11177 end if; -- create resource access type
11178
11179 exception
11180 when others then
11181 x_return_status := FND_API.G_RET_STS_ERROR;
11182 fnd_message.clear;
11183 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_CREATE_ACCESS');
11184 X_Msg_Data := fnd_message.get();
11185
11186 forall i in l_rsc_access_rec.TERR_RSC_ID.first..l_rsc_access_rec.TERR_RSC_ID.last
11187 update JTY_WEBADI_OTH_TERR_INTF jwot
11188 set status = x_return_status,
11189 error_msg = x_msg_data
11190 where exists
11191 (select 1 from JTY_WEBADI_RESOURCES jwr
11192 where jwr.LAY_SEQ_NUM = jwot.LAY_SEQ_NUM
11193 and jwr.header = jwot.header
11194 and jwr.user_sequence = jwot.user_sequence
11195 and jwr.interface_type = jwot.interface_type
11196 and jwr.terr_rsc_id+0 = l_rsc_access_rec.terr_rsc_id(i))
11197 and jwot.USER_SEQUENCE = p_user_sequence
11198 and jwot.header = l_header
11199 and jwot.interface_type = l_intf_type
11200 and jwot.status is null;
11201 END;
11202
11203 BEGIN
11204 x_return_status := FND_API.G_RET_STS_SUCCESS;
11205 open get_u_rsc_access_csr(P_USER_SEQUENCE, l_header, l_intf_type);
11206 fetch get_u_rsc_access_csr bulk collect into l_rsc_access_rec.TERR_RSC_ACCESS_ID,
11207 l_rsc_access_rec.LAST_UPDATE_DATE, l_rsc_access_rec.LAST_UPDATED_BY,
11208 l_rsc_access_rec.CREATION_DATE, l_rsc_access_rec.CREATED_BY,
11209 l_rsc_access_rec.LAST_UPDATE_LOGIN,
11210 l_rsc_access_rec.TERR_RSC_ID, l_rsc_access_rec.ACCESS_TYPE,
11211 l_rsc_access_rec.ORG_ID, l_rsc_access_rec.TRANS_ACCESS_CODE;
11212 close get_u_rsc_access_csr;
11213
11214 --dbms_output.put_line('Add Access to resource_id: '||l_terr_rsc_out_tbl(i).terr_rsc_id ||',access count: '||l_tr_access_tbl.count );
11215 if l_rsc_access_rec.TERR_RSC_ID.count > 0 then
11216 forall i in l_rsc_access_rec.TERR_RSC_ID.first..l_rsc_access_rec.TERR_RSC_ID.last
11217 Update JTF_TERR_RSC_ACCESS_ALL
11218 SET
11219 LAST_UPDATE_DATE = l_rsc_access_rec.LAST_UPDATE_DATE(i),
11220 LAST_UPDATED_BY = l_rsc_access_rec.LAST_UPDATED_BY(i),
11221 LAST_UPDATE_LOGIN = l_rsc_access_rec.LAST_UPDATE_LOGIN(i),
11222 TERR_RSC_ID = l_rsc_access_rec.TERR_RSC_ID(i),
11223 ACCESS_TYPE = l_rsc_access_rec.ACCESS_TYPE(i),
11224 TRANS_ACCESS_CODE = l_rsc_access_rec.TRANS_ACCESS_CODE(i),
11225 ORG_ID = l_rsc_access_rec.ORG_ID(i)
11226 where TERR_RSC_ACCESS_ID = l_rsc_access_rec.TERR_RSC_ACCESS_ID(i);
11227
11228 forall i in l_rsc_access_rec.TERR_RSC_ID.first..l_rsc_access_rec.TERR_RSC_ID.last
11229 update JTY_WEBADI_OTH_TERR_INTF jwot
11230 set status = x_return_status
11231 where exists
11232 (select 1 from JTY_WEBADI_RESOURCES jwr
11233 where jwr.LAY_SEQ_NUM = jwot.LAY_SEQ_NUM
11234 and jwr.header = jwot.header
11235 and jwr.user_sequence = jwot.user_sequence
11236 and jwr.interface_type = jwot.interface_type
11237 and jwr.terr_rsc_id+0 = l_rsc_access_rec.terr_rsc_id(i))
11238 and jwot.USER_SEQUENCE = p_user_sequence
11239 and jwot.header = l_header
11240 and jwot.interface_type = l_intf_type
11241 and jwot.status is null;
11242 end if;
11243
11244 exception
11245 when others then
11246 x_return_status := FND_API.G_RET_STS_ERROR;
11247 fnd_message.clear;
11248 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_UPDATE_ACCESS');
11249 X_Msg_Data := fnd_message.get();
11250
11251 forall i in l_rsc_access_rec.TERR_RSC_ID.first..l_rsc_access_rec.TERR_RSC_ID.last
11252 update JTY_WEBADI_OTH_TERR_INTF jwot
11253 set status = x_return_status,
11254 error_msg = x_msg_data
11255 where exists
11256 (select 1 from JTY_WEBADI_RESOURCES jwr
11257 where jwr.LAY_SEQ_NUM = jwot.LAY_SEQ_NUM
11258 and jwr.header = jwot.header
11259 and jwr.user_sequence = jwot.user_sequence
11260 and jwr.interface_type = jwot.interface_type
11261 and jwr.terr_rsc_id+0 = l_rsc_access_rec.terr_rsc_id(i))
11262 and jwot.USER_SEQUENCE = p_user_sequence
11263 and jwot.header = l_header
11264 and jwot.interface_type = l_intf_type
11265 and jwot.status is null;
11266 END;
11267
11268 exception
11269 when others then
11270 x_return_status := FND_API.G_RET_STS_ERROR;
11271 fnd_message.clear;
11272 fnd_message.set_name ('JTF', 'JTY_OTH_TERR_UPDATE_RSC');
11273 X_Msg_Data := fnd_message.get();
11274
11275 update JTY_WEBADI_OTH_TERR_INTF jwot
11276 set status = x_return_status,
11277 error_msg = X_Msg_Data
11278 where exists
11279 (select 1 from JTY_WEBADI_RESOURCES jwr
11280 where jwr.LAY_SEQ_NUM = jwot.LAY_SEQ_NUM
11281 and jwr.header = jwot.header
11282 and jwr.user_sequence = jwot.user_sequence
11283 and jwr.interface_type = jwot.interface_type)
11284 and jwot.USER_SEQUENCE = p_user_sequence
11285 and jwot.header = l_header
11286 and jwot.interface_type = l_intf_type
11287 and jwot.status is null;
11288
11289 END UPDATE_TERR_RSC;
11290
11291 PROCEDURE UPDATE_TERR_DEF(
11292 x_errbuf OUT NOCOPY VARCHAR2,
11293 x_retcode OUT NOCOPY VARCHAR2,
11294 P_USER_SEQUENCE IN NUMBER,
11295 --p_ORG_id IN NUMBER,
11296 p_usage_id IN NUMBER,
11297 p_user_id IN NUMBER
11298 ) IS
11299
11300 --l_api_version_number CONSTANT NUMBER := 1.0;
11301 x_return_status varchar2(255);
11302 X_Msg_Count number;
11303 X_Msg_Data varchar2(255);
11304
11305 l_rowid varchar2(30) := null;
11306 l_action_flag varchar2(1);
11307 l_header varchar2(30);
11308 l_intf_type varchar2(1) := 'U';
11309 l_row_count number;
11310 l_row_count2 number;
11311 l_sql varchar2(5000);
11312 l_login_id number := fnd_global.login_id;
11313
11314 l_status varchar2_tbl_type;
11315 l_error_msg varchar2_tbl_type;
11316 l_lay_seq_num number_tbl_type;
11317
11318 BEGIN
11319 debugmsg('UPDATE_TERR_DEF: P_USER_SEQUENCE : ' || P_USER_SEQUENCE);
11320 x_return_status := FND_API.G_RET_STS_SUCCESS;
11321 --l_action_flag := p_action_flag;
11322 --fnd_file.put_line( FND_FILE.OUTPUT, 'Program starting....., sequence: '||p_USER_SEQUENCE ||', user_id: '||p_user_id);
11323 --dbms_output.put_line('Program starting....., sequence: '||p_USER_SEQUENCE ||', user_id: '||p_user_id);
11324
11325 begin
11326 -- remove old inserted values from the interface table
11327 -- added 05/26/2006, bug 5249085
11328 delete from JTY_WEBADI_OTH_TERR_INTF
11329 where interface_type = l_intf_type
11330 and status is not null;
11331 --dbms_output.put_line('removed old data, row count: '||SQL%ROWCOUNT);
11332 commit;
11333
11334 exception
11335 when others then
11336 rollback;
11337 end;
11338
11339 -- initial operating unit
11340 mo_global.init('JTF');
11341
11342 -- get hierarchy for territory
11343 --dbms_output.put_line('get hierarchy');
11344 debugmsg('UPDATE_TERR_DEF: get hierarchy : Before ' );
11345 get_hierarchy
11346 ( p_user_sequence => p_user_sequence,
11347 p_intf_type => l_intf_type,
11348 x_return_status => x_return_status,
11349 x_msg_data => x_msg_data );
11350
11351 --dbms_output.put_line('get hierarchy completed, status: ' ||x_return_status);
11352 debugmsg('UPDATE_TERR_DEF: get hierarchy completed, status: ' ||x_return_status );
11353
11354 if x_return_status = FND_API.G_RET_STS_SUCCESS then
11355 --dbms_output.put_line('set create record ');
11356 -- set all create records id to null
11357 debugmsg('UPDATE_TERR_DEF: SET_CREATE_RECORDS : Before ' );
11358 SET_CREATE_RECORDS(
11359 p_user_sequence => p_user_sequence,
11360 p_intf_type => l_intf_type);
11361
11362 --dbms_output.put_line('update terr qual id');
11363 debugmsg('UPDATE_TERR_DEF: update terr qual id : Before ' );
11364 l_header := 'QUAL';
11365 UPDATE_TERR_QUAL_ID(
11366 P_USER_SEQUENCE => p_user_sequence,
11367 P_INTF_TYPE => l_intf_type,
11368 P_HEADER => l_header);
11369 debugmsg('UPDATE_TERR_DEF: validate_territory_records : Before ' );
11370 -- validate all records
11371 --dbms_output.put_line('validating record');
11372 validate_territory_records
11373 ( p_user_sequence => p_user_sequence,
11374 P_INTF_TYPE => l_intf_type,
11375 x_return_status => x_return_status,
11376 X_MSG_DATA => x_msg_data);
11377 --dbms_output.put_line('validating record completed, status: '||x_return_status);
11378 debugmsg('UPDATE_TERR_DEF: validating record completed, status: '||x_return_status );
11379
11380 if x_return_status = FND_API.G_RET_STS_SUCCESS then
11381 -- process qualifier records
11382 --dbms_output.put_line(' Call delete records procedure...');
11383 l_action_flag := 'D';
11384 delete_records(
11385 P_USER_SEQUENCE => p_user_sequence,
11386 P_INTF_TYPE => l_intf_type ,
11387 p_action_flag => l_action_flag);
11388
11389 -- process territory definition records
11390 --dbms_output.put_line(' process terr header records... ');
11391 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR (C) : Before' );
11392 /*bug-9244529
11393 Rather than creating new territory, first update the existing territory. The corresponding change has been done by changing l_action_flag FROM 'C' to 'U'
11394
11395 */
11396
11397 l_action_flag := 'U';
11398 UPDATE_TERR(
11399 p_user_sequence => p_user_sequence,
11400 p_action_flag => l_action_flag,
11401 x_return_status => x_return_status,
11402 x_msg_data => x_msg_data);
11403
11404 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR (C) completed, status: '||x_return_status );
11405
11406 if x_return_status = FND_API.G_RET_STS_SUCCESS then
11407 -- process terr update
11408 --dbms_output.put_line(' process terr update... ');
11409
11410 /*bug-9244529
11411
11412 */
11413 l_action_flag := 'C';
11414 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR (U) : Before' );
11415 UPDATE_TERR(
11416 p_user_sequence => p_user_sequence,
11417 p_action_flag => l_action_flag,
11418 x_return_status => x_return_status,
11419 x_msg_data => x_msg_data);
11420
11421 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR (U) completed, status: '||x_return_status );
11422
11423 if x_return_status = FND_API.G_RET_STS_SUCCESS then
11424 -- process resources
11425 --dbms_output.put_line(' process resource records');
11426 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_RSC : Before' );
11427 UPDATE_TERR_RSC(P_USER_SEQUENCE => p_user_sequence,
11428 --p_action_flag => l_action_flag,
11429 x_return_status => x_return_status,
11430 x_msg_data => x_msg_data);
11431
11432 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_RSC completed, status: '||x_return_status );
11433
11434 if x_return_status = FND_API.G_RET_STS_SUCCESS then
11435 -- process qualifier
11436 --dbms_output.put_line(' process qualifier records');
11437 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : Before' );
11438 UPDATE_TERR_QUAL(P_USER_SEQUENCE => p_user_sequence,
11439 --p_action_flag => l_action_flag,
11440 x_return_status => x_return_status,
11441 x_msg_data => x_msg_data);
11442 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL completed, status: '||x_return_status );
11443 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : x_msg_data : '||x_msg_data );
11444 else
11445 select NVL(status,'S') status, NVL(error_msg,'Success') error_msg, lay_seq_num
11446 bulk collect into l_status, l_error_msg, l_lay_seq_num
11447 from JTY_WEBADI_OTH_TERR_INTF
11448 where interface_type = l_intf_type
11449 and user_sequence = p_user_sequence;
11450
11451 -- rollback all updated info
11452 debugmsg('UPDATE_TERR_DEF: UPDATE_TERR_QUAL : rollback all updated info : ' );
11453 rollback;
11454
11455 forall i in l_lay_seq_num.first..l_lay_seq_num.last
11456 update JTY_WEBADI_OTH_TERR_INTF
11457 set status = l_status(i),
11458 error_msg = l_error_msg(i)
11459 where lay_seq_num = l_lay_seq_num(i)
11460 and interface_type = l_intf_type
11461 and user_sequence = p_user_sequence;
11462 end if;-- qualifier
11463 else
11464
11465 select NVL(status,'S') status, NVL(error_msg,'Success') error_msg, lay_seq_num
11466 bulk collect into l_status, l_error_msg, l_lay_seq_num
11467 from JTY_WEBADI_OTH_TERR_INTF
11468 where interface_type = l_intf_type
11469 and user_sequence = p_user_sequence;
11470
11471 -- rollback all updated info
11472 rollback;
11473
11474 forall i in l_lay_seq_num.first..l_lay_seq_num.last
11475 update JTY_WEBADI_OTH_TERR_INTF
11476 set status = l_status(i),
11477 error_msg = l_error_msg(i)
11478 where lay_seq_num = l_lay_seq_num(i)
11479 and interface_type = l_intf_type
11480 and user_sequence = p_user_sequence;
11481 end if; -- resource
11482 else
11483
11484 select NVL(status,'S') status, NVL(error_msg,'Success') error_msg, lay_seq_num
11485 bulk collect into l_status, l_error_msg, l_lay_seq_num
11486 from JTY_WEBADI_OTH_TERR_INTF
11487 where interface_type = l_intf_type
11488 and user_sequence = p_user_sequence;
11489
11490 -- rollback all updated info
11491 rollback;
11492
11493 forall i in l_lay_seq_num.first..l_lay_seq_num.last
11494 update JTY_WEBADI_OTH_TERR_INTF
11495 set status = l_status(i),
11496 error_msg = l_error_msg(i)
11497 where lay_seq_num = l_lay_seq_num(i)
11498 and interface_type = l_intf_type
11499 and user_sequence = p_user_sequence;
11500 end if; -- resource
11501
11502 else
11503
11504 select NVL(status,'S') status, NVL(error_msg,'Success') error_msg, lay_seq_num
11505 bulk collect into l_status, l_error_msg, l_lay_seq_num
11506 from JTY_WEBADI_OTH_TERR_INTF
11507 where interface_type = l_intf_type
11508 and user_sequence = p_user_sequence;
11509
11510 -- rollback all updated info
11511 rollback;
11512
11513 forall i in l_lay_seq_num.first..l_lay_seq_num.last
11514 update JTY_WEBADI_OTH_TERR_INTF
11515 set status = l_status(i),
11516 error_msg = l_error_msg(i)
11517 where lay_seq_num = l_lay_seq_num(i)
11518 and interface_type = l_intf_type
11519 and user_sequence = p_user_sequence;
11520 end if; -- territory
11521 else
11522 select NVL(status,'S') status, NVL(error_msg,'Success') error_msg, lay_seq_num
11523 bulk collect into l_status, l_error_msg, l_lay_seq_num
11524 from JTY_WEBADI_OTH_TERR_INTF
11525 where interface_type = l_intf_type
11526 and user_sequence = p_user_sequence;
11527
11528 -- rollback all updated info
11529 rollback;
11530
11531 forall i in l_lay_seq_num.first..l_lay_seq_num.last
11532 update JTY_WEBADI_OTH_TERR_INTF
11533 set status = l_status(i),
11534 error_msg = l_error_msg(i)
11535 where lay_seq_num = l_lay_seq_num(i)
11536 and interface_type = l_intf_type
11537 and user_sequence = p_user_sequence;
11538 end if; -- validation
11539 debugmsg('UPDATE_TERR_DEF: End : ' );
11540 x_errbuf := FND_API.G_RET_STS_SUCCESS;
11541 x_retcode := 0;
11542 --commit;
11543
11544 exception
11545 WHEN others THEN
11546 debugmsg('UPDATE_TERR_DEF: End : exception : Others : ' || SQLERRM(SQLCODE()) );
11547 --fnd_file.put_line( FND_FILE.OUTPUT,'Exception: Others in upload');
11548 --fnd_file.put_line( FND_FILE.OUTPUT,' SQLERRM: ' || SQLERRM);
11549 --dbms_output.put_line( 'Exception: Others in upload');
11550 --dbms_output.put_line( ' SQLERRM: ' || SQLERRM);
11551 x_errbuf := sqlcode||': '||SQLERRM;
11552 x_retcode := 2;
11553
11554 END UPDATE_TERR_DEF;
11555
11556 END JTY_WEBADI_OTH_TERR_UPDATE_PKG;