The following lines contain the word 'select', 'insert', 'update' or 'delete':
l_last_update_date DATE ;
l_last_updated_by NUMBER ;
l_last_update_login NUMBER ;
SELECT 1
FROM as_statuses_vl
WHERE TRIM(NLS_UPPER(status_code)) = p_status_code; -- trimmed value passed while opening
IF (p_status_rec.last_update_date = FND_API.G_MISS_DATE)
OR TRIM(p_status_rec.last_update_date) IS NULL
THEN
l_last_update_date := sysdate;
l_last_update_date := p_status_rec.last_update_date;
IF (p_status_rec.last_update_login = FND_API.G_MISS_NUM)
OR TRIM(p_status_rec.last_update_login) IS NULL
THEN
l_last_update_login := fnd_global.login_id;
l_last_update_login := p_status_rec.last_update_login;
IF (p_status_rec.last_updated_by = FND_API.G_MISS_NUM)
OR TRIM(p_status_rec.last_updated_by) IS NULL
THEN
l_last_updated_by := fnd_global.user_id;
l_last_updated_by := p_status_rec.last_updated_by ;
fnd_message.set_name('AS', 'AS_STATUS_INSERT_FAILED');
AS_STATUSES_PKG.INSERT_ROW(
l_row_id,
p_status_rec.status_code,
p_status_rec.enabled_flag,
p_status_rec.lead_flag,
p_status_rec.opp_flag,
p_status_rec.opp_open_status_flag,
p_status_rec.opp_decision_date_flag,
p_status_rec.status_rank,
p_status_rec.forecast_rollup_flag,
p_status_rec.win_loss_indicator,
NULL,
l_attribute_category,
l_attribute1,
l_attribute2,
l_attribute3,
l_attribute4,
l_attribute5,
l_attribute6,
l_attribute7,
l_attribute8,
l_attribute9,
l_attribute10,
l_attribute11,
l_attribute12,
l_attribute13,
l_attribute14,
l_attribute15,
p_status_rec.meaning,
l_description,
l_creation_date,
l_created_by,
l_last_update_date,
l_last_updated_by,
l_last_update_login);
PROCEDURE update_status (
p_api_version_number IN NUMBER,
p_init_msg_list IN VARCHAR2 ,
p_commit IN VARCHAR2 ,
p_validation_level IN NUMBER,
p_status_rec IN STATUS_Rec_Type ,
x_return_status OUT VARCHAR2,
x_msg_count OUT NUMBER,
x_msg_data OUT VARCHAR2)
IS
-- Declaration of local variables and cursors
l_api_version NUMBER:= p_api_version_number;
l_api_name CONSTANT VARCHAR(30) DEFAULT 'UPDATE_STATUS';
l_last_update_date DATE ;
v_last_update_date DATE ;
l_last_updated_by NUMBER ;
l_last_update_login NUMBER ;
l_current_last_update_date DATE;
CURSOR get_update_row_cur(p_status_code in VARCHAR2) IS
SELECT last_update_date,
enabled_flag,
lead_flag,
opp_flag,
opp_open_status_flag ,
opp_decision_date_flag,
forecast_rollup_flag,
win_loss_indicator,
attribute_category,
attribute1,
attribute2,
attribute3,
attribute4,
attribute5,
attribute6,
attribute7,
attribute8,
attribute9,
attribute10,
attribute11,
attribute12,
attribute13,
attribute14,
attribute15,
meaning,
description,
status_rank
FROM as_statuses_vl
WHERE TRIM(NLS_UPPER(status_code)) = p_status_code; -- trimmed value passed while opening
CURSOR lock_row_for_update(p_status_code in VARCHAR2) IS
SELECT last_update_date
FROM as_statuses_vl
WHERE TRIM(NLS_UPPER(status_code)) = p_status_code; -- trimmed value passed while opening
SAVEPOINT update_status;
OPEN get_update_row_cur(TRIM(NLS_UPPER(p_status_rec.status_code)));
FETCH get_update_row_cur
INTO l_last_update_date,
l_enabled_flag,
l_lead_flag,
l_opp_flag,
l_opp_open_status_flag ,
l_opp_decision_date_flag,
l_forecast_rollup_flag,
l_win_loss_indicator,
l_attribute_category,
l_attribute1,
l_attribute2,
l_attribute3,
l_attribute4,
l_attribute5,
l_attribute6,
l_attribute7,
l_attribute8,
l_attribute9,
l_attribute10,
l_attribute11,
l_attribute12,
l_attribute13,
l_attribute14,
l_attribute15,
l_meaning,
l_description,
l_status_rank;
IF get_update_row_cur%NOTFOUND
THEN
CLOSE get_update_row_cur;
IF p_status_rec.last_update_date = FND_API.G_MISS_DATE
OR TRIM(p_status_rec.last_update_date) IS NULL
THEN
l_last_update_date := SYSDATE;
l_last_update_date := p_status_rec.last_update_date ;
IF p_status_rec.last_update_login = FND_API.G_MISS_NUM
OR TRIM(p_status_rec.last_update_login) IS NULL
THEN
l_last_update_login := fnd_global.login_id;
l_last_update_login := p_status_rec.last_update_login;
IF p_status_rec.last_updated_by = FND_API.G_MISS_NUM
OR TRIM(p_status_rec.last_updated_by) IS NULL
THEN
l_last_updated_by := fnd_global.user_id;
l_last_updated_by := p_status_rec.last_updated_by;
fnd_message.set_name('AS', 'AS_STATUS_UPDATE_FAILED');
OPEN lock_row_for_update(TRIM(NLS_UPPER(p_status_rec.status_code)));
FETCH lock_row_for_update INTO l_current_last_update_date;
IF lock_row_for_update%NOTFOUND
THEN
CLOSE lock_row_for_update;
IF l_last_update_date <> l_current_last_update_date
THEN
fnd_message.set_name('AS', 'AS_RECORD_UPDATED');
AS_STATUSES_PKG.UPDATE_ROW(
p_status_rec.status_code,
v_enabled_flag,
v_lead_flag,
v_opp_flag,
v_opp_open_status_flag,
v_opp_decision_date_flag,
v_status_rank,
v_forecast_rollup_flag,
v_win_loss_indicator,
NULL,
v_attribute_category,
v_attribute1,
v_attribute2,
v_attribute3,
v_attribute4,
v_attribute5,
v_attribute6,
v_attribute7,
v_attribute8,
v_attribute9,
v_attribute10,
v_attribute11,
v_attribute12,
v_attribute13,
v_attribute14,
v_attribute15,
v_meaning,
v_description,
l_last_update_date,
l_last_updated_by,
l_last_update_login);
CLOSE get_update_row_cur; -- closed after update...
CLOSE lock_row_for_update ;
ROLLBACK TO update_status;
ROLLBACK TO update_status;
ROLLBACK TO update_status;
END update_status;