The following lines contain the word 'select', 'insert', 'update' or 'delete':
delete from AMS_PROD_TEMPLATES_TL T
where not exists
(select NULL
from AMS_PROD_TEMPLATES_B B
where B.TEMPLATE_ID = T.TEMPLATE_ID
);
update AMS_PROD_TEMPLATES_TL T set (
TEMPLATE_NAME,
DESCRIPTION
) = (select
B.TEMPLATE_NAME,
B.DESCRIPTION
from AMS_PROD_TEMPLATES_TL B
where B.TEMPLATE_ID = T.TEMPLATE_ID
and B.LANGUAGE = T.SOURCE_LANG)
where (
T.TEMPLATE_ID,
T.LANGUAGE
) in (select
SUBT.TEMPLATE_ID,
SUBT.LANGUAGE
from AMS_PROD_TEMPLATES_TL SUBB, AMS_PROD_TEMPLATES_TL SUBT
where SUBB.template_ID = SUBT.template_ID
and SUBB.LANGUAGE = SUBT.SOURCE_LANG
and (SUBB.TEMPLATE_NAME <> SUBT.TEMPLATE_NAME
or SUBB.DESCRIPTION <> SUBT.DESCRIPTION
or (SUBB.DESCRIPTION is null and SUBT.DESCRIPTION is not null)
or (SUBB.DESCRIPTION is not null and SUBT.DESCRIPTION is null)
));
insert into AMS_PROD_TEMPLATES_TL (
template_ID,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_LOGIN,
template_NAME,
DESCRIPTION,
LANGUAGE,
SOURCE_LANG
) select
B.template_ID,
B.LAST_UPDATE_DATE,
B.LAST_UPDATED_BY,
B.CREATION_DATE,
B.CREATED_BY,
B.LAST_UPDATE_LOGIN,
B.template_NAME,
B.DESCRIPTION,
L.LANGUAGE_CODE,
B.SOURCE_LANG
from AMS_PROD_TEMPLATES_TL B, FND_LANGUAGES L
where L.INSTALLED_FLAG in ('I', 'B')
and B.LANGUAGE = userenv('LANG')
and not exists
(select NULL
from AMS_PROD_TEMPLATES_TL T
where T.template_ID = B.template_ID
and T.LANGUAGE = L.LANGUAGE_CODE);
update AMS_PROD_TEMPLATES_TL set
template_name = nvl(x_template_name, template_name),
description = nvl(x_description, description),
source_lang = userenv('LANG'),
last_update_date = sysdate,
last_updated_by = decode(x_owner, 'SEED', 1, 0),
last_update_login = 0
where template_id = x_template_id
and userenv('LANG') in (language, source_lang);
select object_version_number
from AMS_PROD_TEMPLATES_B
where template_id = X_TEMPLATE_ID;
select 'x'
from AMS_PROD_TEMPLATES_B
where template_id = X_TEMPLATE_ID;
select AMS_PROD_TEMPLATES_B_S.nextval
from dual;
select last_updated_by, nvl(object_version_number,1)
from AMS_PROD_TEMPLATES_B
where template_id = X_TEMPLATE_ID;
INSERT INTO AMS_PROD_TEMPLATES_B(
template_id,
last_update_date,
last_updated_by,
creation_date,
created_by,
object_version_number,
last_update_login,
product_service_flag
) VALUES (
l_template_id
,SYSDATE
,l_user_id
,SYSDATE
,l_user_id
,1
,0
,X_PRODUCT_SERVICE_FLAG);
INSERT INTO AMS_PROD_TEMPLATES_TL(
template_id
,language
,source_lang
,last_update_date
,last_updated_by
,last_update_login
,creation_date
,created_by
,template_name
,description
) SELECT
l_template_id,
l.language_code,
USERENV('LANG'),
sysdate,
l_user_id,
0,
sysdate,
l_user_id,
X_TEMPLATE_NAME,
X_DESCRIPTION
FROM fnd_languages l
WHERE l.installed_flag IN ('I','B')
AND NOT EXISTS(
SELECT NULL
FROM AMS_PROD_TEMPLATES_TL t
WHERE t.template_id = DECODE( l_template_id, FND_API.g_miss_num, NULL, l_template_id)
AND t.language = l.language_code ) ;
Update AMS_PROD_TEMPLATES_B
SET last_update_date = sysdate,
last_updated_by = l_user_id,
object_version_number = l_obj_verno +1,
last_update_login = 0,
product_service_flag = X_PRODUCT_SERVICE_FLAG
WHERE TEMPLATE_ID = X_TEMPLATE_ID
AND object_version_number = l_obj_verno;
UPDATE AMS_PROD_TEMPLATES_TL
SET template_name = X_TEMPLATE_NAME
,description = X_DESCRIPTION
,last_update_date = sysdate
,last_updated_by = l_user_id
,last_update_login = 0
,source_lang = USERENV('LANG')
WHERE TEMPLATE_ID = X_TEMPLATE_ID
AND USERENV('LANG') IN (language, source_lang);