The following lines contain the word 'select', 'insert', 'update' or 'delete':
g_insert_count NUMBER := 0;
error_delete_hierarchies NUMBER := -20102;
error_update_hierarchies NUMBER := -20105;
SELECT /* $Header: AFFFCHYB.pls 120.2.12010000.1 2008/07/25 14:13:37 appldev ship $ */
*
INTO x_vset
FROM fnd_flex_value_sets
WHERE flex_value_set_id = To_number(p_flex_value_set);
SELECT /* $Header: AFFFCHYB.pls 120.2.12010000.1 2008/07/25 14:13:37 appldev ship $ */
*
INTO x_vset
FROM fnd_flex_value_sets
WHERE flex_value_set_name = p_flex_value_set;
INSERT /* $Header: AFFFCHYB.pls 120.2.12010000.1 2008/07/25 14:13:37 appldev ship $ */
INTO fnd_flex_value_hierarchies
(flex_value_set_id, parent_flex_value,
child_flex_value_low, child_flex_value_high,
last_update_date, last_updated_by,
creation_date, created_by)
VALUES
(g_vset.flex_value_set_id*(-1), p_root_parent_flex_value,
p_child_flex_value_low, p_child_flex_value_high,
Sysdate, g_user_id,
Sysdate, g_user_id);
g_insert_count := g_insert_count + 1;
IF (g_insert_count = g_commit_size) THEN
COMMIT;
g_insert_count := 0;
SELECT /* $Header: AFFFCHYB.pls 120.2.12010000.1 2008/07/25 14:13:37 appldev ship $ */
parent_flex_value,
child_flex_value_low,
child_flex_value_high,
range_attribute
FROM fnd_flex_value_norm_hierarchy
WHERE flex_value_set_id = g_vset.flex_value_set_id
AND parent_flex_value >= p_child_flex_value_low
AND parent_flex_value <= p_child_flex_value_high
ORDER BY range_attribute, parent_flex_value,
child_flex_value_low, child_flex_value_high;
SELECT /* $Header: AFFFCHYB.pls 120.2.12010000.1 2008/07/25 14:13:37 appldev ship $ */
parent_flex_value,
child_flex_value_low,
child_flex_value_high,
range_attribute
FROM fnd_flex_value_norm_hierarchy
WHERE flex_value_set_id = g_vset.flex_value_set_id
ORDER BY range_attribute, parent_flex_value,
child_flex_value_low, child_flex_value_high;
g_insert_count := 0;
IF (g_insert_count > 0) THEN
COMMIT;
g_insert_count := 0;
DELETE /* $Header: AFFFCHYB.pls 120.2.12010000.1 2008/07/25 14:13:37 appldev ship $ */
FROM fnd_flex_value_hierarchies
WHERE flex_value_set_id = g_vset.flex_value_set_id;
INSERT /* $Header: AFFFCHYB.pls 120.2.12010000.1 2008/07/25 14:13:37 appldev ship $ */
INTO fnd_flex_value_hier_all
(flex_value_set_id, parent_flex_value, range_attribute,
child_flex_value_low, child_flex_value_high, hierarchy_level,
last_update_date, last_updated_by,
creation_date, created_by)
VALUES
(g_vset.flex_value_set_id*(-1), p_root_parent_flex_value, p_range_attribute,
p_child_flex_value_low, p_child_flex_value_high, p_hierarchy_level,
Sysdate, g_user_id,
Sysdate, g_user_id);
g_insert_count := g_insert_count + 1;
IF (g_insert_count = g_commit_size) THEN
COMMIT;
g_insert_count := 0;
SELECT /* $Header: AFFFCHYB.pls 120.2.12010000.1 2008/07/25 14:13:37 appldev ship $ */
parent_flex_value,
child_flex_value_low,
child_flex_value_high,
range_attribute
FROM fnd_flex_value_norm_hierarchy
WHERE flex_value_set_id = g_vset.flex_value_set_id
AND parent_flex_value >= p_child_flex_value_low
AND parent_flex_value <= p_child_flex_value_high
ORDER BY range_attribute, parent_flex_value,
child_flex_value_low, child_flex_value_high;
SELECT /* $Header: AFFFCHYB.pls 120.2.12010000.1 2008/07/25 14:13:37 appldev ship $ */
parent_flex_value,
child_flex_value_low,
child_flex_value_high,
range_attribute
FROM fnd_flex_value_norm_hierarchy
WHERE flex_value_set_id = g_vset.flex_value_set_id
ORDER BY range_attribute, parent_flex_value,
child_flex_value_low, child_flex_value_high;
g_insert_count := 0;
IF (g_insert_count > 0) THEN
COMMIT;
g_insert_count := 0;
DELETE /* $Header: AFFFCHYB.pls 120.2.12010000.1 2008/07/25 14:13:37 appldev ship $ */
FROM fnd_flex_value_hier_all
WHERE flex_value_set_id = g_vset.flex_value_set_id;
PROCEDURE delete_value_hierarchies
--
-- Delete the old data.
--
IS
l_row_count NUMBER;
DELETE /* $Header: AFFFCHYB.pls 120.2.12010000.1 2008/07/25 14:13:37 appldev ship $ */
FROM fnd_flex_value_hierarchies
WHERE flex_value_set_id = g_vset.flex_value_set_id and
rownum < 1000;
raise_exception_error(error_delete_hierarchies,
'Unable to delete data in FND_FLEX_VALUE_HIERARCHIES table.');
END delete_value_hierarchies;
PROCEDURE delete_value_hierarchies_all
--
-- Delete the old data.
--
IS
l_row_count NUMBER;
DELETE /* $Header: AFFFCHYB.pls 120.2.12010000.1 2008/07/25 14:13:37 appldev ship $ */
FROM fnd_flex_value_hier_all
WHERE flex_value_set_id = g_vset.flex_value_set_id and
rownum < 1000;
raise_exception_error(error_delete_hierarchies,
'Unable to delete data in FND_FLEX_VALUE_HIER_ALL table.');
END delete_value_hierarchies_all;
PROCEDURE update_value_hierarchies
--
-- Update the newly compiled data with the vset id.
--
IS
l_row_count NUMBER;
UPDATE /* $Header: AFFFCHYB.pls 120.2.12010000.1 2008/07/25 14:13:37 appldev ship $ */
fnd_flex_value_hierarchies
SET flex_value_set_id = g_vset.flex_value_set_id
WHERE flex_value_set_id = g_vset.flex_value_set_id*(-1) and
rownum < 1000;
raise_exception_error(error_update_hierarchies,
'Unable to update data in FND_FLEX_VALUE_HIERARCHIES table.');
END update_value_hierarchies;
PROCEDURE update_value_hierarchies_all
--
-- Update the newly compiled data with the vset id.
--
IS
l_row_count NUMBER;
UPDATE /* $Header: AFFFCHYB.pls 120.2.12010000.1 2008/07/25 14:13:37 appldev ship $ */
fnd_flex_value_hier_all
SET flex_value_set_id=g_vset.flex_value_set_id
WHERE flex_value_set_id = g_vset.flex_value_set_id*(-1) and
rownum < 1000;
raise_exception_error(error_update_hierarchies,
'Unable to update data in FND_FLEX_VALUE_HIERARCHIES table.');
END update_value_hierarchies_all;
delete_value_hierarchies();
update_value_hierarchies();
delete_value_hierarchies_all();
update_value_hierarchies_all();
reinserting them in a normalized state. Hierarchy value rules
are checked by security. The problem is that when
all the hier rules are deleted and before they are reinserted there
is a time frame where there is a security breach. Values that
should be secured, will not be sec in that time frame. We recoded
the logic so that we first insert the hierachy rules with a
vsetid*(-1). Once done with the insert we create a lock so
that no one can access the data, and then we delete the rows
with orig vsetid and then we update the vsetid*(-1) with the
orig vsetid. After that is done, we release the lock. If another
process wants to read the hier security data it cannot until the
lock is released. At this time the only code that is reading the
hier rules data is fnd_flex_server.check_value_security and
this is called in FND_FLEX_SERVER1.check_security. In the function
check_security() we check to see if a lock exists and if there is a
lock we do not process until the lock is released meaning the data
is now updated and correct.
*******************************************************************/
--
-- Finish hierarchy processing.
--
finish_hierarchy_processing();