[Home] [Help]
494:
495: -- check if the name is duplicated with in the parent of p_child_id
496: -- Added Subtype and language check for bug 4703418 on 28-Nov-2005 (Nishant)
497: SELECT count(*) INTO l_count
498: FROM hz_geography_identifiers
499: WHERE identifier_type='NAME'
500: AND identifier_subtype = p_child_identifier_subtype
501: AND language_code = p_child_language
502: AND UPPER(identifier_value) = UPPER(p_child_name)
538:
539: -- check if the name is duplicated with in the parent of p_child_id
540: -- Added Subtype and language check for bug 4703418 on 28-Nov-2005 (Nishant)
541: SELECT count(*) INTO l_count
542: FROM hz_geography_identifiers
543: WHERE identifier_type='CODE'
544: AND identifier_subtype = p_child_identifier_subtype
545: AND language_code = p_child_language
546: AND identifier_value = UPPER(p_child_code)
683: ); */
684: BEGIN
685: SELECT identifier_subtype,language_code INTO
686: l_identifier_subtype,l_language_code
687: FROM hz_geography_identifiers
688: WHERE geography_id = p_master_relation_rec.geography_id
689: AND identifier_type = 'NAME'
690: AND primary_flag = 'Y'
691: AND geography_use = 'MASTER_REF';
719: ); */
720: BEGIN
721: SELECT identifier_subtype,language_code INTO
722: l_identifier_subtype,l_language_code
723: FROM hz_geography_identifiers
724: WHERE geography_id = p_master_relation_rec.geography_id
725: AND identifier_type = 'CODE'
726: AND primary_flag = 'Y'
727: AND geography_use = 'MASTER_REF';
1245: CLOSE c_get_all_parents;
1246: ELSE
1247: -- Bug 5411429 : check for the duplicate name/code for Country geographies.
1248: SELECT count(*) INTO l_count
1249: FROM hz_geography_identifiers
1250: WHERE identifier_type = p_geo_identifier_rec.identifier_type
1251: AND identifier_subtype = l_identifier_subtype
1252: AND language_code = p_geo_identifier_rec.language_code
1253: AND UPPER(identifier_value) = UPPER(p_geo_identifier_rec.identifier_value)
1280:
1281: IF (p_geo_identifier_rec.identifier_type = 'NAME' AND p_geo_identifier_rec.identifier_subtype <> 'STANDARD_NAME') THEN
1282:
1283: SELECT count(*) INTO l_count from
1284: hz_geography_identifiers
1285: WHERE geography_id = p_geo_identifier_rec.geography_id
1286: AND language_code = l_language_code;
1287:
1288: IF l_count = 0 THEN
1293: IF p_geo_identifier_rec.primary_flag = 'Y' THEN
1294: IF (p_geo_identifier_rec.identifier_type='NAME' AND p_geo_identifier_rec.identifier_subtype = 'STANDARD_NAME') THEN
1295: -- check if there exists a STANDARD_NAME + Primary Flag = Y
1296: SELECT count(*) INTO l_count
1297: FROM hz_geography_identifiers
1298: WHERE geography_id = p_geo_identifier_rec.geography_id
1299: AND identifier_type = 'NAME'
1300: AND identifier_subtype = 'STANDARD_NAME'
1301: AND primary_flag = 'Y'
1302: AND language_code = l_language_code;
1303:
1304: IF l_count > 0 THEN
1305: -- update STANDARD_NAME+Y to STANDARD_NAME+N
1306: UPDATE hz_geography_identifiers
1307: SET primary_flag = 'N'
1308: WHERE geography_id = p_geo_identifier_rec.geography_id
1309: AND identifier_type = 'NAME'
1310: AND identifier_subtype = 'STANDARD_NAME'
1316: END IF;
1317:
1318: --check if there exists a primary row already for this geography_id
1319: SELECT count(*) INTO l_count
1320: FROM HZ_GEOGRAPHY_IDENTIFIERS
1321: WHERE geography_id = p_geo_identifier_rec.geography_id
1322: AND identifier_type = p_geo_identifier_rec.identifier_type
1323: AND primary_flag='Y';
1324:
1323: AND primary_flag='Y';
1324:
1325: IF l_count > 0 THEN
1326: -- set the primary_flag of the existing primary identifier to 'N'
1327: UPDATE hz_geography_identifiers
1328: SET primary_flag = 'N'
1329: WHERE geography_id=p_geo_identifier_rec.geography_id
1330: AND identifier_type = p_geo_identifier_rec.identifier_type
1331: AND primary_flag = 'Y';
1334: END IF;
1335:
1336: ----dbms_output.put_line('before identifier insert');
1337:
1338: -- call table handler to insert the row in hz_geography_identifiers
1339:
1340: HZ_GEOGRAPHY_IDENTIFIERS_PKG.insert_row(
1341: x_rowid => l_rowid,
1342: x_geography_id => p_geo_identifier_rec.geography_id,
1336: ----dbms_output.put_line('before identifier insert');
1337:
1338: -- call table handler to insert the row in hz_geography_identifiers
1339:
1340: HZ_GEOGRAPHY_IDENTIFIERS_PKG.insert_row(
1341: x_rowid => l_rowid,
1342: x_geography_id => p_geo_identifier_rec.geography_id,
1343: x_identifier_subtype => l_identifier_subtype,
1344: x_identifier_value => l_identifier_value,
1510: BEGIN
1511:
1512: SELECT rowid,geography_type,geography_use,primary_flag,object_version_number
1513: INTO l_rowid,l_geography_type,l_geography_use,l_old_primary_flag,l_object_version_number
1514: FROM hz_geography_identifiers
1515: WHERE geography_id = p_geo_identifier_rec.geography_id
1516: AND identifier_type = p_geo_identifier_rec.identifier_type
1517: AND identifier_subtype = p_geo_identifier_rec.identifier_subtype
1518: AND identifier_value = p_geo_identifier_rec.identifier_value
1521:
1522: --validate object_version_number
1523: IF l_object_version_number <> p_object_version_number THEN
1524: FND_MESSAGE.SET_NAME('AR', 'HZ_API_RECORD_CHANGED');
1525: FND_MESSAGE.SET_TOKEN('TABLE', 'hz_geography_identifiers');
1526: FND_MSG_PUB.ADD;
1527: RAISE FND_API.G_EXC_ERROR;
1528: ELSE
1529: p_object_version_number := l_object_version_number + 1;
1601: IF p_geo_identifier_rec.identifier_type = 'NAME' THEN
1602: -- check if the name is duplicated with in the parent of p_child_id
1603: -- Added Subtype and language check for bug 4703418 on 28-Nov-2005 (Nishant)
1604: SELECT count(*) INTO l_count
1605: FROM hz_geography_identifiers
1606: WHERE identifier_type='NAME'
1607: AND identifier_subtype = l_new_geo_subtype
1608: AND language_code = p_geo_identifier_rec.language_code
1609: AND UPPER(identifier_value) = UPPER(l_new_geo_value)
1630: ELSIF p_geo_identifier_rec.identifier_type = 'CODE' THEN
1631: -- check if the name is duplicated with in the parent of p_child_id
1632: -- Added Subtype and language check for bug 4703418 on 28-Nov-2005 (Nishant)
1633: SELECT count(*) INTO l_count
1634: FROM hz_geography_identifiers
1635: WHERE identifier_type='CODE'
1636: AND identifier_subtype = l_new_geo_subtype
1637: AND language_code = p_geo_identifier_rec.language_code
1638: AND identifier_value = UPPER(l_new_geo_value)
1661: CLOSE c_get_all_parents;
1662: ELSE
1663: -- Bug 5411429 : check for the duplicate name/code for Country geographies.
1664: SELECT count(*) INTO l_count
1665: FROM hz_geography_identifiers
1666: WHERE identifier_type = p_geo_identifier_rec.identifier_type
1667: AND identifier_subtype = l_new_geo_subtype
1668: AND language_code = p_geo_identifier_rec.language_code
1669: AND UPPER(identifier_value) = UPPER(l_new_geo_value)
1696: IF (l_old_primary_flag = 'N' AND p_geo_identifier_rec.primary_flag = 'Y') THEN
1697:
1698: --check if there exists a primary row already for this geography_id
1699: SELECT count(*) INTO l_count
1700: FROM HZ_GEOGRAPHY_IDENTIFIERS
1701: WHERE geography_id = p_geo_identifier_rec.geography_id
1702: AND identifier_type = p_geo_identifier_rec.identifier_type
1703: AND primary_flag='Y'
1704: AND language_code = p_geo_identifier_rec.language_code;
1705:
1706: -- --dbms_output.put_line ( 'l_count for primary row '||to_char(l_count));
1707: IF l_count > 0 THEN
1708: -- set the primary_flag of the existing primary identifier to 'N'
1709: UPDATE hz_geography_identifiers
1710: SET primary_flag = 'N'
1711: WHERE geography_id=p_geo_identifier_rec.geography_id
1712: AND identifier_type = p_geo_identifier_rec.identifier_type
1713: AND primary_flag = 'Y'
1715: -- --dbms_output.put_line ( 'After update of primary from Y to N');
1716: END IF;
1717: END IF;
1718:
1719: hz_geography_identifiers_pkg.update_row(
1720: x_rowid => l_rowid,
1721: x_geography_id => p_geo_identifier_rec.geography_id,
1722: x_identifier_subtype => l_new_geo_subtype,
1723: x_identifier_value => l_new_geo_value,
1800: l_delete_flag := 'Y';
1801:
1802: -- primary identifier can not be deleted
1803: SELECT primary_flag INTO l_primary_flag
1804: FROM hz_geography_identifiers
1805: WHERE geography_id = p_geography_id
1806: AND identifier_type = p_identifier_type
1807: AND identifier_subtype = p_identifier_subtype
1808: AND identifier_value = p_identifier_value
1819: -- If a STANDARD_NAME is being deleted , if there exists another name mark it as STANDARD and delete
1820: -- this row else if another name doesn't exist then delete the row.
1821: IF (p_identifier_type = 'NAME' AND p_identifier_subtype = 'STANDARD_NAME') THEN
1822: select count(*) INTO l_count
1823: from hz_geography_identifiers
1824: where geography_id = p_geography_id
1825: AND language_code = p_language_code
1826: AND identifier_type = 'NAME'
1827: ;
1826: AND identifier_type = 'NAME'
1827: ;
1828: IF l_count > 1 THEN
1829: -- update an identifier to STANDARD
1830: UPDATE hz_geography_identifiers
1831: SET identifier_subtype = 'STANDARD_NAME'
1832: WHERE geography_id = p_geography_id
1833: AND identifier_type= p_identifier_type
1834: AND identifier_subtype <> p_identifier_subtype
1841: END IF;
1842: END IF;
1843:
1844: IF l_delete_flag = 'Y' THEN
1845: HZ_GEOGRAPHY_IDENTIFIERS_PKG.delete_row(
1846: x_geography_id => p_geography_id,
1847: x_identifier_subtype => p_identifier_subtype,
1848: x_identifier_value => p_identifier_value,
1849: x_language_code => p_language_code,
2014: END IF;
2015: END;
2016:
2017:
2018: -- create an identifier for this geography in HZ_GEOGRAPHY_IDENTIFIERS
2019: -- construct Identifier record for identifier_type 'NAME'/'CODE'
2020: l_geo_identifier_rec.geography_id := x_geography_id;
2021: l_geo_identifier_rec.identifier_subtype := 'STANDARD_NAME';
2022: l_geo_identifier_rec.identifier_value := p_master_geography_rec.geography_name;
2404:
2405: -- check if this geography already exists for given parent
2406: SELECT COUNT(*)
2407: INTO l_count
2408: FROM hz_geography_identifiers id
2409: WHERE UPPER(id.identifier_value) = l_master_geography_rec.geography_name
2410: AND id.geography_use = 'MASTER_REF'
2411: AND id.identifier_type = 'NAME'
2412: AND id.identifier_subtype = 'STANDARD_NAME'
3512: WHEN DUP_VAL_ON_INDEX THEN
3513: ROLLBACK TO create_geo_identifier;
3514: x_return_status := FND_API.G_RET_STS_ERROR;
3515: HZ_UTILITY_V2PUB.find_index_name(p_index_name);
3516: IF p_index_name = 'HZ_GEOGRAPHY_IDENTIFIERS_U1' THEN
3517: FND_MESSAGE.SET_NAME('AR', 'HZ_API_DUPLICATE_COLUMN');
3518: FND_MESSAGE.SET_TOKEN('COLUMN', 'geography_id,identifier_type,identifier_subtype,identifier_value,language_code');
3519: FND_MSG_PUB.ADD;
3520: END IF;