1: package body FND_TERRITORIES_PKG as
2: /* $Header: AFNLDTIB.pls 120.7 2010/12/17 15:45:02 jvalenti ship $ */
3:
4: procedure INSERT_ROW (
5: X_ROWID in out nocopy VARCHAR2,
20: X_LAST_UPDATED_BY in NUMBER,
21: X_LAST_UPDATE_LOGIN in NUMBER
22: ) is
23: begin
24: FND_TERRITORIES_PKG.INSERT_ROW(
25: X_ROWID,
26: X_TERRITORY_CODE,
27: X_EU_CODE,
28: X_ISO_NUMERIC_CODE,
62: X_LAST_UPDATE_LOGIN in NUMBER,
63: X_OBSOLETE_FLAG in VARCHAR2
64: ) is
65: begin
66: FND_TERRITORIES_PKG.INSERT_ROW(
67: X_ROWID,
68: X_TERRITORY_CODE,
69: X_EU_CODE,
70: X_ISO_NUMERIC_CODE,
105: X_LAST_UPDATE_LOGIN in NUMBER,
106: X_OBSOLETE_FLAG in VARCHAR2,
107: X_ISO_TERRITORY_CODE in VARCHAR2
108: ) is
109: cursor C is select ROWID from FND_TERRITORIES
110: where TERRITORY_CODE = X_TERRITORY_CODE
111: ;
112: obsolete_flag varchar2(1);
113: begin
113: begin
114:
115: obsolete_flag := nvl(X_OBSOLETE_FLAG, 'N');
116:
117: insert into FND_TERRITORIES (
118: EU_CODE,
119: TERRITORY_CODE,
120: ISO_NUMERIC_CODE,
121: ALTERNATE_TERRITORY_CODE,
149: obsolete_flag,
150: X_ISO_TERRITORY_CODE
151: );
152:
153: insert into FND_TERRITORIES_TL (
154: TERRITORY_CODE,
155: TERRITORY_SHORT_NAME,
156: CREATED_BY,
157: CREATION_DATE,
175: from FND_LANGUAGES L
176: where L.INSTALLED_FLAG in ('I', 'B')
177: and not exists
178: (select NULL
179: from FND_TERRITORIES_TL T
180: where T.TERRITORY_CODE = X_TERRITORY_CODE
181: and T.LANGUAGE = L.LANGUAGE_CODE);
182:
183: open c;
211: ADDRESS_STYLE,
212: ADDRESS_VALIDATION,
213: BANK_INFO_STYLE,
214: BANK_INFO_VALIDATION
215: from FND_TERRITORIES
216: where TERRITORY_CODE = X_TERRITORY_CODE
217: for update of TERRITORY_CODE nowait;
218: recinfo c%rowtype;
219:
220: cursor c1 is select
221: TERRITORY_SHORT_NAME,
222: DESCRIPTION,
223: decode(LANGUAGE, userenv('LANG'), 'Y', 'N') BASELANG
224: from FND_TERRITORIES_TL
225: where TERRITORY_CODE = X_TERRITORY_CODE
226: and userenv('LANG') in (LANGUAGE, SOURCE_LANG)
227: for update of TERRITORY_CODE nowait;
228: begin
289: X_LAST_UPDATED_BY in NUMBER,
290: X_LAST_UPDATE_LOGIN in NUMBER
291: ) is
292: begin
293: FND_TERRITORIES_PKG.UPDATE_ROW(
294: X_TERRITORY_CODE,
295: X_EU_CODE,
296: X_ISO_NUMERIC_CODE,
297: X_ALTERNATE_TERRITORY_CODE,
325: X_LAST_UPDATE_LOGIN in NUMBER,
326: X_OBSOLETE_FLAG in VARCHAR2
327: ) is
328: begin
329: FND_TERRITORIES_PKG.UPDATE_ROW(
330: X_TERRITORY_CODE,
331: X_EU_CODE,
332: X_ISO_NUMERIC_CODE,
333: X_ALTERNATE_TERRITORY_CODE,
370:
371: begin
372:
373: select
374: decode(x_iso_territory_code,fnd_territories_pkg.null_char,null,
375: null,u.iso_territory_code,x_iso_territory_code),
376: decode(x_eu_code,fnd_territories_pkg.null_char,null,
377: null,u.eu_code,x_eu_code)
378: into l_iso_territory_code,l_eu_code
372:
373: select
374: decode(x_iso_territory_code,fnd_territories_pkg.null_char,null,
375: null,u.iso_territory_code,x_iso_territory_code),
376: decode(x_eu_code,fnd_territories_pkg.null_char,null,
377: null,u.eu_code,x_eu_code)
378: into l_iso_territory_code,l_eu_code
379: from fnd_territories u
380: where territory_code = x_territory_code;
375: null,u.iso_territory_code,x_iso_territory_code),
376: decode(x_eu_code,fnd_territories_pkg.null_char,null,
377: null,u.eu_code,x_eu_code)
378: into l_iso_territory_code,l_eu_code
379: from fnd_territories u
380: where territory_code = x_territory_code;
381:
382: if (X_OBSOLETE_FLAG is NULL) then
383: update FND_TERRITORIES set
379: from fnd_territories u
380: where territory_code = x_territory_code;
381:
382: if (X_OBSOLETE_FLAG is NULL) then
383: update FND_TERRITORIES set
384: EU_CODE = L_EU_CODE,
385: ISO_NUMERIC_CODE = X_ISO_NUMERIC_CODE,
386: ALTERNATE_TERRITORY_CODE = X_ALTERNATE_TERRITORY_CODE,
387: NLS_TERRITORY = X_NLS_TERRITORY,
394: LAST_UPDATE_LOGIN = X_LAST_UPDATE_LOGIN,
395: ISO_TERRITORY_CODE = L_ISO_TERRITORY_CODE
396: where TERRITORY_CODE = X_TERRITORY_CODE;
397: else
398: update FND_TERRITORIES set
399: EU_CODE = L_EU_CODE,
400: ISO_NUMERIC_CODE = X_ISO_NUMERIC_CODE,
401: ALTERNATE_TERRITORY_CODE = X_ALTERNATE_TERRITORY_CODE,
402: NLS_TERRITORY = X_NLS_TERRITORY,
415: if (sql%notfound) then
416: raise no_data_found;
417: end if;
418:
419: update FND_TERRITORIES_TL set
420: TERRITORY_SHORT_NAME = X_TERRITORY_SHORT_NAME,
421: DESCRIPTION = X_DESCRIPTION,
422: LAST_UPDATE_DATE = X_LAST_UPDATE_DATE,
423: LAST_UPDATED_BY = X_LAST_UPDATED_BY,
434: procedure DELETE_ROW (
435: X_TERRITORY_CODE in VARCHAR2
436: ) is
437: begin
438: delete from FND_TERRITORIES_TL
439: where TERRITORY_CODE = X_TERRITORY_CODE;
440:
441: if (sql%notfound) then
442: raise no_data_found;
441: if (sql%notfound) then
442: raise no_data_found;
443: end if;
444:
445: delete from FND_TERRITORIES
446: where TERRITORY_CODE = X_TERRITORY_CODE;
447:
448: if (sql%notfound) then
449: raise no_data_found;
458: /* as a quick workaround to fix the time-consuming table handler issue */
459: /* Eventually we'll need to turn them into a separate fix_language procedure */
460: /*
461:
462: delete from FND_TERRITORIES_TL T
463: where not exists
464: (select NULL
465: from FND_TERRITORIES B
466: where B.TERRITORY_CODE = T.TERRITORY_CODE
461:
462: delete from FND_TERRITORIES_TL T
463: where not exists
464: (select NULL
465: from FND_TERRITORIES B
466: where B.TERRITORY_CODE = T.TERRITORY_CODE
467: );
468:
469: update FND_TERRITORIES_TL T set (
465: from FND_TERRITORIES B
466: where B.TERRITORY_CODE = T.TERRITORY_CODE
467: );
468:
469: update FND_TERRITORIES_TL T set (
470: TERRITORY_SHORT_NAME,
471: DESCRIPTION
472: ) = (select
473: B.TERRITORY_SHORT_NAME,
471: DESCRIPTION
472: ) = (select
473: B.TERRITORY_SHORT_NAME,
474: B.DESCRIPTION
475: from FND_TERRITORIES_TL B
476: where B.TERRITORY_CODE = T.TERRITORY_CODE
477: and B.LANGUAGE = T.SOURCE_LANG)
478: where (
479: T.TERRITORY_CODE,
480: T.LANGUAGE
481: ) in (select
482: SUBT.TERRITORY_CODE,
483: SUBT.LANGUAGE
484: from FND_TERRITORIES_TL SUBB, FND_TERRITORIES_TL SUBT
485: where SUBB.TERRITORY_CODE = SUBT.TERRITORY_CODE
486: and SUBB.LANGUAGE = SUBT.SOURCE_LANG
487: and (SUBB.TERRITORY_SHORT_NAME <> SUBT.TERRITORY_SHORT_NAME
488: or SUBB.DESCRIPTION <> SUBT.DESCRIPTION
490: or (SUBB.DESCRIPTION is not null and SUBT.DESCRIPTION is null)
491: ));
492: */
493:
494: insert into FND_TERRITORIES_TL (
495: TERRITORY_CODE,
496: TERRITORY_SHORT_NAME,
497: CREATED_BY,
498: CREATION_DATE,
512: B.LAST_UPDATE_LOGIN,
513: B.DESCRIPTION,
514: L.LANGUAGE_CODE,
515: B.SOURCE_LANG
516: from FND_TERRITORIES_TL B, FND_LANGUAGES L
517: where L.INSTALLED_FLAG in ('I', 'B')
518: and B.LANGUAGE = userenv('LANG')
519: and not exists
520: (select NULL
517: where L.INSTALLED_FLAG in ('I', 'B')
518: and B.LANGUAGE = userenv('LANG')
519: and not exists
520: (select NULL
521: from FND_TERRITORIES_TL T
522: where T.TERRITORY_CODE = B.TERRITORY_CODE
523: and T.LANGUAGE = L.LANGUAGE_CODE);
524: end ADD_LANGUAGE;
525:
594: f_ludate := nvl(to_date(X_LAST_UPDATE_DATE, 'YYYY/MM/DD'), sysdate);
595:
596: select last_updated_by, last_update_date
597: into db_luby, db_ludate
598: from FND_TERRITORIES_TL
599: where TERRITORY_CODE = X_TERRITORY_CODE
600: and language = userenv('LANG');
601:
602: if (fnd_load_util.upload_test(f_luby, f_ludate, db_luby,
600: and language = userenv('LANG');
601:
602: if (fnd_load_util.upload_test(f_luby, f_ludate, db_luby,
603: db_ludate, X_CUSTOM_MODE)) then
604: update FND_TERRITORIES_TL set
605: DESCRIPTION = X_DESCRIPTION,
606: TERRITORY_SHORT_NAME = X_TERRITORY_SHORT_NAME,
607: LAST_UPDATE_DATE = f_ludate,
608: LAST_UPDATED_BY = f_luby,
733:
734: begin
735: select last_updated_by, last_update_date
736: into db_luby, db_ludate
737: from FND_TERRITORIES
738: where TERRITORY_CODE = X_TERRITORY_CODE;
739:
740: -- Bug4493112 Moved decode select statement from UPDATE_ROW to LOAD_ROW.
741: -- Bug4648984 Moved sql to inside exception block to handle the
741: -- Bug4648984 Moved sql to inside exception block to handle the
742: -- no data found.
743:
744: select
745: decode(x_iso_numeric_code, fnd_territories_pkg.null_char, null,
746: null, u.iso_numeric_code,
747: x_iso_numeric_code),
748: decode(x_alternate_territory_code,fnd_territories_pkg.null_char, null,
749: null, u.alternate_territory_code,
744: select
745: decode(x_iso_numeric_code, fnd_territories_pkg.null_char, null,
746: null, u.iso_numeric_code,
747: x_iso_numeric_code),
748: decode(x_alternate_territory_code,fnd_territories_pkg.null_char, null,
749: null, u.alternate_territory_code,
750: x_alternate_territory_code),
751: decode(x_nls_territory, fnd_territories_pkg.null_char, null,
752: null, u.nls_territory,
747: x_iso_numeric_code),
748: decode(x_alternate_territory_code,fnd_territories_pkg.null_char, null,
749: null, u.alternate_territory_code,
750: x_alternate_territory_code),
751: decode(x_nls_territory, fnd_territories_pkg.null_char, null,
752: null, u.nls_territory,
753: x_nls_territory),
754: decode(x_address_style, fnd_territories_pkg.null_char, null,
755: null, u.address_style,
750: x_alternate_territory_code),
751: decode(x_nls_territory, fnd_territories_pkg.null_char, null,
752: null, u.nls_territory,
753: x_nls_territory),
754: decode(x_address_style, fnd_territories_pkg.null_char, null,
755: null, u.address_style,
756: x_address_style),
757: decode(x_address_validation, fnd_territories_pkg.null_char, null,
758: null, u.address_validation,
753: x_nls_territory),
754: decode(x_address_style, fnd_territories_pkg.null_char, null,
755: null, u.address_style,
756: x_address_style),
757: decode(x_address_validation, fnd_territories_pkg.null_char, null,
758: null, u.address_validation,
759: x_address_validation),
760: decode(x_bank_info_style, fnd_territories_pkg.null_char, null,
761: null, u.bank_info_style,
756: x_address_style),
757: decode(x_address_validation, fnd_territories_pkg.null_char, null,
758: null, u.address_validation,
759: x_address_validation),
760: decode(x_bank_info_style, fnd_territories_pkg.null_char, null,
761: null, u.bank_info_style,
762: x_bank_info_style),
763: decode(x_bank_info_validation, fnd_territories_pkg.null_char, null,
764: null, u.bank_info_validation,
759: x_address_validation),
760: decode(x_bank_info_style, fnd_territories_pkg.null_char, null,
761: null, u.bank_info_style,
762: x_bank_info_style),
763: decode(x_bank_info_validation, fnd_territories_pkg.null_char, null,
764: null, u.bank_info_validation,
765: x_bank_info_validation),
766: decode(x_eu_code, fnd_territories_pkg.null_char, null,
767: null, u.eu_code,
762: x_bank_info_style),
763: decode(x_bank_info_validation, fnd_territories_pkg.null_char, null,
764: null, u.bank_info_validation,
765: x_bank_info_validation),
766: decode(x_eu_code, fnd_territories_pkg.null_char, null,
767: null, u.eu_code,
768: x_eu_code),
769: decode(x_iso_territory_code, fnd_territories_pkg.null_char, null,
770: null, u.iso_territory_code,
765: x_bank_info_validation),
766: decode(x_eu_code, fnd_territories_pkg.null_char, null,
767: null, u.eu_code,
768: x_eu_code),
769: decode(x_iso_territory_code, fnd_territories_pkg.null_char, null,
770: null, u.iso_territory_code,
771: x_iso_territory_code)
772: into l_iso_numeric_code, l_alternate_territory_code, l_nls_territory,
773: l_address_style, l_address_validation, l_bank_info_style,
771: x_iso_territory_code)
772: into l_iso_numeric_code, l_alternate_territory_code, l_nls_territory,
773: l_address_style, l_address_validation, l_bank_info_style,
774: l_bank_info_validation, l_eu_code, l_iso_territory_code
775: from fnd_territories u
776: where territory_code = x_territory_code;
777:
778: -- Bug4493112 Modified code to use local variables in UPDATE_ROW and
779: -- INSERT_ROW procedure calls.
779: -- INSERT_ROW procedure calls.
780:
781: if (fnd_load_util.upload_test(f_luby, f_ludate, db_luby,
782: db_ludate, X_CUSTOM_MODE)) then
783: FND_TERRITORIES_PKG.UPDATE_ROW(
784: X_TERRITORY_CODE,
785: L_EU_CODE,
786: L_ISO_NUMERIC_CODE,
787: L_ALTERNATE_TERRITORY_CODE,
804: -- bug7270106 - Need to correctly translate the provided NULL value
805: -- for inserting.
806:
807: select
808: decode(x_iso_numeric_code, fnd_territories_pkg.null_char, null,
809: null, null,x_iso_numeric_code),
810: decode(x_alternate_territory_code,fnd_territories_pkg.null_char, null,
811: null, null, x_alternate_territory_code),
812: decode(x_nls_territory, fnd_territories_pkg.null_char, null,
806:
807: select
808: decode(x_iso_numeric_code, fnd_territories_pkg.null_char, null,
809: null, null,x_iso_numeric_code),
810: decode(x_alternate_territory_code,fnd_territories_pkg.null_char, null,
811: null, null, x_alternate_territory_code),
812: decode(x_nls_territory, fnd_territories_pkg.null_char, null,
813: null, null, x_nls_territory),
814: decode(x_address_style, fnd_territories_pkg.null_char, null,
808: decode(x_iso_numeric_code, fnd_territories_pkg.null_char, null,
809: null, null,x_iso_numeric_code),
810: decode(x_alternate_territory_code,fnd_territories_pkg.null_char, null,
811: null, null, x_alternate_territory_code),
812: decode(x_nls_territory, fnd_territories_pkg.null_char, null,
813: null, null, x_nls_territory),
814: decode(x_address_style, fnd_territories_pkg.null_char, null,
815: null, null, x_address_style),
816: decode(x_address_validation, fnd_territories_pkg.null_char, null,
810: decode(x_alternate_territory_code,fnd_territories_pkg.null_char, null,
811: null, null, x_alternate_territory_code),
812: decode(x_nls_territory, fnd_territories_pkg.null_char, null,
813: null, null, x_nls_territory),
814: decode(x_address_style, fnd_territories_pkg.null_char, null,
815: null, null, x_address_style),
816: decode(x_address_validation, fnd_territories_pkg.null_char, null,
817: null, null, x_address_validation),
818: decode(x_bank_info_style, fnd_territories_pkg.null_char, null,
812: decode(x_nls_territory, fnd_territories_pkg.null_char, null,
813: null, null, x_nls_territory),
814: decode(x_address_style, fnd_territories_pkg.null_char, null,
815: null, null, x_address_style),
816: decode(x_address_validation, fnd_territories_pkg.null_char, null,
817: null, null, x_address_validation),
818: decode(x_bank_info_style, fnd_territories_pkg.null_char, null,
819: null, null, x_bank_info_style),
820: decode(x_bank_info_validation, fnd_territories_pkg.null_char, null,
814: decode(x_address_style, fnd_territories_pkg.null_char, null,
815: null, null, x_address_style),
816: decode(x_address_validation, fnd_territories_pkg.null_char, null,
817: null, null, x_address_validation),
818: decode(x_bank_info_style, fnd_territories_pkg.null_char, null,
819: null, null, x_bank_info_style),
820: decode(x_bank_info_validation, fnd_territories_pkg.null_char, null,
821: null, null, x_bank_info_validation),
822: decode(x_eu_code, fnd_territories_pkg.null_char, null,
816: decode(x_address_validation, fnd_territories_pkg.null_char, null,
817: null, null, x_address_validation),
818: decode(x_bank_info_style, fnd_territories_pkg.null_char, null,
819: null, null, x_bank_info_style),
820: decode(x_bank_info_validation, fnd_territories_pkg.null_char, null,
821: null, null, x_bank_info_validation),
822: decode(x_eu_code, fnd_territories_pkg.null_char, null,
823: null, null, x_eu_code),
824: decode(x_iso_territory_code, fnd_territories_pkg.null_char, null,
818: decode(x_bank_info_style, fnd_territories_pkg.null_char, null,
819: null, null, x_bank_info_style),
820: decode(x_bank_info_validation, fnd_territories_pkg.null_char, null,
821: null, null, x_bank_info_validation),
822: decode(x_eu_code, fnd_territories_pkg.null_char, null,
823: null, null, x_eu_code),
824: decode(x_iso_territory_code, fnd_territories_pkg.null_char, null,
825: null, null, x_iso_territory_code)
826: into l_iso_numeric_code, l_alternate_territory_code, l_nls_territory,
820: decode(x_bank_info_validation, fnd_territories_pkg.null_char, null,
821: null, null, x_bank_info_validation),
822: decode(x_eu_code, fnd_territories_pkg.null_char, null,
823: null, null, x_eu_code),
824: decode(x_iso_territory_code, fnd_territories_pkg.null_char, null,
825: null, null, x_iso_territory_code)
826: into l_iso_numeric_code, l_alternate_territory_code, l_nls_territory,
827: l_address_style, l_address_validation, l_bank_info_style,
828: l_bank_info_validation, l_eu_code, l_iso_territory_code
827: l_address_style, l_address_validation, l_bank_info_style,
828: l_bank_info_validation, l_eu_code, l_iso_territory_code
829: from dual;
830:
831: FND_TERRITORIES_PKG.INSERT_ROW(
832: X_ROWID,
833: X_TERRITORY_CODE,
834: L_EU_CODE,
835: L_ISO_NUMERIC_CODE,
850: L_ISO_TERRITORY_CODE);
851: end;
852: end LOAD_ROW;
853:
854: end FND_TERRITORIES_PKG;