The following lines contain the word 'select', 'insert', 'update' or 'delete':
select fepd.module_id
into l_module_id
from FLM_EKB_PREFERENCE_definitions fepd
where fepd.preference_id = p_pref_id;
select level_id
into l_level_id
from
(
select level_id
from FLM_EKB_preference_levels v
where
v.module_id = l_module_id and
v.level_code <= l_level_code and
( v.organization_id is null or v.organization_id = p_org_id) and
exists
(
select 1
from flm_ekb_preference_values v1
where v1.preference_id = p_pref_id and
v1.level_id = v.level_id
)
order by v.level_code desc
)
where rownum = 1;
select attribute_value_code
into l_attr_val_code
from
(
select attribute_value_code
from FLM_EKB_PREFERENCE_VALUES
where (level_id = p_level_id or level_id = 1)
and preference_id = p_pref_id
order by level_id desc
)
where rownum = 1;
select attribute_value_code
into l_attr_val_code
from
(
select attribute_value_code
from FLM_EKB_PREFERENCE_VALUES
where (level_id = p_level_id or level_id = 1)
and preference_id = p_pref_id
and attribute_name = p_attr_name
order by level_id desc
)
where rownum = 1;
select attribute_name, attribute_value_code
from FLM_EKB_PREFERENCE_VALUES
where level_id = p_level_id
and preference_id = FLM_KANBAN_CONSTANTS.UNMOVED_CARD_LEADTIME_PER
and attribute_value_code is NOT NULL;
select attribute_name
from FLM_EKB_PREFERENCE_VALUES
where level_id = p_level_id
and preference_id = FLM_KANBAN_CONSTANTS.UNMOVED_CARD_LEADTIME_PER
and nvl(attribute_enable_flag,1) = 1;
select preference_type
from flm_ekb_preference_definitions
where preference_id = cl_pref_id;
select decode( (select count(v.attribute_value_code)
from flm_ekb_preference_values v,
flm_ekb_preference_levels l
where v.PREFERENCE_ID = p_preference_id
and v.LEVEL_ID = l.LEVEL_ID
and nvl(l.organization_id, -99) = nvl(cl_org_id, -99)
),
0, 'INHERIT',
1, (select v.attribute_value_code
from flm_ekb_preference_values v,
flm_ekb_preference_levels l
where v.PREFERENCE_ID = p_preference_id
and v.LEVEL_ID = l.LEVEL_ID
and nvl(l.organization_id, -99) = nvl(cl_org_id, -99)),
'INHERIT') AS single_value_code
from dual;
select count(v.attribute_value_code) as multi_value_count
from flm_ekb_preference_values v,
flm_ekb_preference_levels l
where v.PREFERENCE_ID = p_preference_id
and v.LEVEL_ID = l.LEVEL_ID
and nvl(l.organization_id, -99) = nvl(cl_org_id, -99);
select count(*) as multi_value_count
from flm_ekb_preference_values v,
flm_ekb_preference_levels l
where v.PREFERENCE_ID = p_preference_id
and v.LEVEL_ID = l.LEVEL_ID
and nvl(l.organization_id, -99) = nvl(cl_org_id, -99);
select ml.meaning
from mfg_lookups ml
where ml.lookup_code = to_number(cl_value_code) and
ml.lookup_type = c1_lookup_type;
/* (select wp.preference_value_lookup_type
from flm_ekb_preference_definitions wp
where wp.preference_id = p_preference_id);*/
/*TODO: insert a fnd message and get from there*/
/*return fnd_message.get_string('WIP', 'WIP_PREFERENCE_ENTERED');*/
select wp.preference_value_lookup_type
into l_lookup_type
from flm_ekb_preference_definitions wp
where wp.preference_id = p_preference_id;
/*function insertRowPrefValues()*/
procedure insertRow(p_preference_id number,
p_level_id number,
p_sequence_number number,
p_attribute_name varchar2,
p_attribute_value_code varchar2,
p_enable_flag number,
p_user_id number) is
begin
insert into flm_ekb_preference_values
(
PREFERENCE_VALUE_ID,
PREFERENCE_ID,
LEVEL_ID,
SEQUENCE_NUMBER,
ATTRIBUTE_NAME,
ATTRIBUTE_VALUE_CODE,
ATTRIBUTE_ENABLE_FLAG,
CREATED_BY,
CREATION_DATE,
LAST_UPDATED_BY,
LAST_UPDATE_DATE,
LAST_UPDATE_LOGIN,
OBJECT_VERSION_NUMBER
)
VALUES
(
flm_ekb_pref_val_seq.nextval, --get from a sequence--PREFERENCE_VALUE_ID,
p_preference_id, --PREFERENCE_ID,
p_level_id, --LEVEL_ID,
p_sequence_number, --SEQUENCE_NUMBER,
p_attribute_name, --ATTRIBUTE_NAME,
p_attribute_value_code, --ATTRIBUTE_VALUE_CODE,
p_enable_flag, --ATTRIBUTE_ENABLE_FLAG
p_user_id, --CREATED_BY,
sysdate, --CREATION_DATE,
p_user_id, --LAST_UPDATED_BY,
sysdate, --LAST_UPDATE_DATE,
p_user_id, --LAST_UPDATE_LOGIN,
1 --OBJECT_VERSION_NUMBER
);
function insertRowLevels(p_org_id number, p_module_id number, p_user_id number) return number is
l_level_code number;
insert into flm_ekb_preference_levels
(
LEVEL_ID,
LEVEL_CODE,
ORGANIZATION_ID,
MODULE_ID,
CREATED_BY,
CREATION_DATE,
LAST_UPDATED_BY,
LAST_UPDATE_DATE,
LAST_UPDATE_LOGIN,
OBJECT_VERSION_NUMBER
)
values
(
l_level_id, --LEVEL_ID,
l_level_code, --LEVEL_CODE,
p_org_id, --ORGANIZATION_ID,
p_module_id, --MODULE_ID,
p_user_id, --CREATED_BY,
sysdate, --CREATION_DATE,
p_user_id, --LAST_UPDATED_BY,
sysdate, --LAST_UPDATE_DATE,
p_user_id, --LAST_UPDATE_LOGIN,
1 --OBJECT_VERSION_NUMBER
);
select level_id into l_level_id
from flm_ekb_preference_levels
where organization_id = p_org_id;
procedure insertRowsPrefValues(p_preference_id number, p_org_id number, p_user_id number) is
l_level_id number;
select ml.lookup_code
from mfg_lookups ml
where lookup_type = 'MTL_KANBAN_SUPPLY_STATUS'
and to_number(ml.lookup_code) <= 8 /*only system/custom statuses till 8 will be honored in ekanban*/
and ml.enabled_flag = 'Y' /*consider only enabled status*/
and (ml.end_date_active is null OR ml.end_date_active > sysdate) /*consider status with future end date*/
order by lookup_code asc;
p_procName =>'flm_kanban_config_params.insertRowsPrefValues',
p_params => l_params,
x_returnStatus => l_retstatus);
select fepd.module_id
into l_module_id
from FLM_EKB_PREFERENCE_definitions fepd
where fepd.preference_id = p_preference_id;
/*get level for the org. if level_id not found, then insert into levels table*/
if(p_org_id is null) then
l_level_id := 1;/*setting level for Site when org_id is null*/
insert the row and carry out other insertion into values table for unmove_card preference*/
l_level_id := insertRowLevels(p_org_id, l_module_id, p_user_id);
select count(*) into l_count
from FLM_EKB_PREFERENCE_VALUES
where level_id = l_level_id
and preference_id = p_preference_id;
select max(sequence_number)
into l_seq_max
from flm_ekb_preference_values
where preference_id = 13;
select attribute_value_code
into l_value
from flm_ekb_preference_values
where preference_id = p_preference_id
and attribute_name = l_code
and sequence_number <= l_seq_max
and level_id = l_level_id;
select attribute_enable_flag
into l_enable_flag
from flm_ekb_preference_values
where preference_id = p_preference_id
and attribute_name = l_code
and sequence_number <= l_seq_max
and level_id = l_level_id;
insertRow(p_preference_id, l_level_id, l_seq, l_code, l_value, l_enable_flag, p_user_id);
/*now delete the previously existing rows*/
flm_ekanban_logger.log(flm_ekanban_logger.FULL_LOGGING, 'deleting previously existing rows', l_retstatus);
delete from flm_ekb_preference_values
where preference_id = 13
and sequence_number <= l_seq_max
and level_id = l_level_id
and attribute_name in (
select attribute_name from flm_ekb_preference_values
where preference_id = 13
and sequence_number > l_seq_max
and level_id = l_level_id);
/*TODO: if needed we can update sequence_number for remaining rows
but currently dont see a need for it*/
end if;--p_preference_id=13
/*for Unmoved Cards, insert rows from mfg_lookup (current statuses)
for other preferences, insert from Site level*/
if(p_preference_id=13) then
/*insert rows for all system/custom statuses*/
l_seq := 0;
select attribute_value_code
into l_value
from flm_ekb_preference_values
where preference_id = p_preference_id
and attribute_name = l_code
and level_id = 1;
insertRow(13, l_level_id, l_seq, l_code, l_value, l_enable_flag, p_user_id);
flm_ekanban_logger.log(flm_ekanban_logger.FULL_LOGGING, 'inserting into flm_ekb_preference_values at Org from Site', l_retstatus);
insert into flm_ekb_preference_values
(
PREFERENCE_VALUE_ID,
PREFERENCE_ID,
LEVEL_ID,
SEQUENCE_NUMBER,
ATTRIBUTE_NAME,
ATTRIBUTE_VALUE_CODE,
CREATED_BY,
CREATION_DATE,
LAST_UPDATED_BY,
LAST_UPDATE_DATE,
LAST_UPDATE_LOGIN,
OBJECT_VERSION_NUMBER
)
select
flm_ekb_pref_val_seq.nextval,
fepv.preference_id,
l_level_id,
fepv.sequence_number,
fepv.attribute_name,
fepv.attribute_value_code,
p_user_id,
sysdate, --CREATION_DATE,
p_user_id, --LAST_UPDATED_BY,
sysdate, --LAST_UPDATE_DATE,
p_user_id, --LAST_UPDATE_LOGIN,
1 --OBJECT_VERSION_NUMBER
from flm_ekb_preference_values fepv
where preference_id = p_preference_id
and level_id = 1;
p_procName =>'flm_kanban_config_params.insertRowsPrefValues',
p_procReturnStatus => l_retstatus,
p_msg => 'success',
x_returnStatus => l_retstatus);
procedure delete_disabled_card_status(p_org_id number) is
l_level_id number;
delete from flm_ekb_preference_values
where preference_id = 13
and level_id = l_level_id
and attribute_name not in (
select ml.lookup_code
from mfg_lookups ml
where lookup_type = 'MTL_KANBAN_SUPPLY_STATUS'
and to_number(ml.lookup_code) <= 8 /*only system/custom statuses till 8 will be honored in ekanban*/
and ml.enabled_flag = 'Y' /*consider only enabled status*/
and (ml.end_date_active is null OR ml.end_date_active > sysdate));
procedure delete_preference_values(p_preference_id number, p_org_id number) is
l_level_id number;
delete from flm_ekb_preference_values
where preference_id = p_preference_id
and level_id = l_level_id;
select ml.meaning into l_label_meaning
from mfg_lookups ml
where lookup_code = p_label_code and
lookup_type in
(
select preference_name_lookup_type from flm_ekb_preference_definitions
where preference_id = p_preference_id
);
select ml.meaning
from mfg_lookups ml
where ml.lookup_code = to_number(p_lookup_code)
and ml.lookup_type = p_lookup_type;
select fepd.PREFERENCE_NAME_LOOKUP_TYPE
from flm_ekb_preference_definitions fepd
where fepd.preference_id = p_preference_id;
select ml.meaning from mfg_lookups ml
where ml.lookup_type = 'MTL_KANBAN_SUPPLY_STATUS'
and ml.lookup_code not in
(
select attribute_name
from flm_ekb_preference_values v
where preference_id = 13
and level_id = p_level_id
)
and ml.enabled_flag = 'Y'
and (ml.end_date_active is null OR ml.end_date_active > sysdate)
and ml.lookup_code <= '8';
select v.attribute_name
from flm_ekb_preference_values v
where v.attribute_name in
(
--list of disabled codes
select to_char(ml.lookup_code)
from mfg_lookups ml
where lookup_type = 'MTL_KANBAN_SUPPLY_STATUS'
and (enabled_flag = 'N' or ml.end_date_active <= sysdate)
)
and v.level_id = p_level_id;
select ml.meaning into l_meaning
from mfg_lookups ml
where ml.lookup_type = 'MTL_KANBAN_SUPPLY_STATUS'
and ml.lookup_code = c_new_disabled_status.attribute_name;
l_ret_val := 'Following statuses will be deleted on clicking "Apply": ' || l_ret_val;