The following lines contain the word 'select', 'insert', 'update' or 'delete':
| that they were inserted by datamerge. |
| |
| The ADD_ROW routine will see whether a row exists by selecting |
| based on the primary key, and updates the row if it exists, |
| or inserts the row if it doesn't already exist. |
| |
| This module is called by AutoInstall (afplss.drv) on install and |
| upgrade. The WHENEVER SQLERROR and EXIT (at bottom) are required. |
| |
| HISTORY |
| bkkumar #2858504 Added legacy_ record_flag in the tbh calls |
| 04-jun-2003 |
*=======================================================================*/
l_rowid VARCHAR2(25);
x_last_update_date IN DATE DEFAULT NULL,
x_last_updated_by IN NUMBER DEFAULT NULL,
x_last_update_login IN NUMBER DEFAULT NULL,
x_clprl_id IN NUMBER DEFAULT NULL
) AS
/*
|| Created By : rasingh
|| Created On : 13-NOV-2000
|| Purpose : Initialises the Old and New references for the columns of the table.
|| Known limitations, enhancements or remarks :
|| Change History :
|| Who When What
|| (reverse chronological order - newest change first)
*/
CURSOR cur_old_ref_values IS
SELECT *
FROM IGF_AP_TD_ITEM_INST_ALL
WHERE rowid = x_rowid;
IF ((cur_old_ref_values%NOTFOUND) AND (p_action NOT IN ('INSERT', 'VALIDATE_INSERT'))) THEN
CLOSE cur_old_ref_values;
fnd_message.set_name ('FND', 'FORM_RECORD_DELETED');
IF (p_action = 'UPDATE') THEN
new_references.creation_date := old_references.creation_date;
new_references.last_update_date := x_last_update_date;
new_references.last_updated_by := x_last_updated_by;
new_references.last_update_login := x_last_update_login;
fnd_message.set_name ('FND', 'FORM_RECORD_DELETED');
fnd_message.set_name ('FND', 'FORM_RECORD_DELETED');
SELECT rowid
FROM igf_ap_td_item_inst_all
WHERE base_id = x_base_id
AND item_sequence_number = x_item_sequence_number
FOR UPDATE NOWAIT;
SELECT rowid
FROM igf_ap_td_item_inst_all
WHERE base_id = x_base_id
AND item_sequence_number = x_item_sequence_number
AND ((l_rowid IS NULL) OR (rowid <> l_rowid));
SELECT rowid
FROM igf_ap_td_item_inst_all
WHERE ((base_id = x_base_id));
SELECT rowid
FROM igf_ap_td_item_inst_all
WHERE ((item_sequence_number = x_todo_number));
x_last_update_date IN DATE DEFAULT NULL,
x_last_updated_by IN NUMBER DEFAULT NULL,
x_last_update_login IN NUMBER DEFAULT NULL,
x_clprl_id IN NUMBER DEFAULT NULL
) AS
/*
|| Created By : rasingh
|| Created On : 13-NOV-2000
|| Purpose : Initialises the columns, Checks Constraints, Calls the
|| Trigger Handlers for the table, before any DML operation.
|| Known limitations, enhancements or remarks :
|| Change History :
|| Who When What
|| masehgal 26-Apr-2002 # 2303509 Added call to check Uniqueness
|| (reverse chronological order - newest change first)
*/
BEGIN
set_column_values (
p_action,
x_rowid,
x_base_id,
x_item_sequence_number,
x_status,
x_status_date,
x_add_date,
x_corsp_date,
x_corsp_count,
x_inactive_flag,
x_freq_attempt,
x_max_attempt,
x_required_for_application,
x_legacy_record_flag,
x_creation_date,
x_created_by,
x_last_update_date,
x_last_updated_by,
x_last_update_login,
x_clprl_id
);
IF (p_action = 'INSERT') THEN
-- Call all the procedures related to Before Insert.
IF ( get_pk_for_validation(
new_references.base_id,
new_references.item_sequence_number
)
) THEN
fnd_message.set_name('IGS','IGS_GE_RECORD_ALREADY_EXISTS');
ELSIF (p_action = 'UPDATE') THEN
-- Call all the procedures related to Before Update.
check_parent_existance;
ELSIF (p_action = 'VALIDATE_INSERT') THEN
-- Call all the procedures related to Before Insert.
IF ( get_pk_for_validation (
new_references.base_id,
new_references.item_sequence_number
)
) THEN
fnd_message.set_name('IGS','IGS_GE_RECORD_ALREADY_EXISTS');
SELECT appl_setup.*
FROM igf_ap_appl_setup_all appl_setup,
igf_ap_td_item_mst_all td_mst,
igf_ap_td_item_inst_all td_inst
WHERE td_mst.ci_cal_type = appl_setup.ci_cal_type
AND td_mst.ci_sequence_number = appl_setup.ci_sequence_number
AND td_mst.application_code = appl_setup.application_code
AND td_mst.todo_number = td_inst.item_sequence_number
AND td_inst.base_id = cp_base_id
AND td_inst.item_sequence_number = cp_item_sequence_number
AND appl_setup.question_id NOT IN (SELECT question_id
FROM igf_ap_st_inst_appl_all
WHERE base_id = td_inst.base_id);
SELECT appl.rowid row_id,
appl.*
FROM igf_ap_appl_status_all appl
WHERE appl.base_id = cp_base_id
AND appl.application_code = cp_application_code;
SELECT application_code,
system_todo_type_code
FROM igf_ap_td_item_mst_all
WHERE todo_number = cp_item_sequence_number;
IF p_action = 'INSERT' THEN
/*
For an institutional application to do item, on insert,
create all the questions in the IGF_AP_ST_INST_APPL_ALL,
and create a record for the status also.
*/
lv_base_id := new_references.base_id;
igf_ap_st_inst_appl_pkg.insert_row(
x_rowid => lv_rowid,
x_inst_app_id => lv_inst_app_id,
x_base_id => lv_base_id,
x_question_id => l_inst_appl.question_id,
x_question_value => NULL,
x_application_code => l_inst_appl.application_code,
x_mode => 'R'
);
igf_ap_appl_status_pkg.insert_row(
x_rowid => lv_rowid,
x_base_id => lv_base_id,
x_application_code => l_appl_code.application_code,
x_application_status_code => new_references.status,
x_mode => 'R'
);
IF p_action = 'UPDATE' THEN
IF NVL(old_references.status,'*') <> NVL(new_references.status,'**') THEN
/*
On update of a institutional application to do item, update the status of the to do item also
*/
OPEN c_appl_status(new_references.base_id,l_appl_code.application_code);
igf_ap_appl_status_pkg.update_row(
x_rowid => l_appl_status.row_id,
x_base_id => l_appl_status.base_id,
x_application_code => l_appl_status.application_code,
x_application_status_code => new_references.status,
x_mode => 'R'
);
igf_ap_st_inst_appl_pkg.insert_row(
x_rowid => lv_rowid,
x_inst_app_id => lv_inst_app_id,
x_base_id => lv_base_id,
x_question_id => l_inst_appl.question_id,
x_question_value => NULL,
x_application_code => l_inst_appl.application_code,
x_mode => 'R'
);
PROCEDURE insert_row (
x_rowid IN OUT NOCOPY VARCHAR2,
x_base_id IN NUMBER,
x_item_sequence_number IN NUMBER,
x_status IN VARCHAR2,
x_status_date IN DATE,
x_add_date IN DATE,
x_corsp_date IN DATE,
x_corsp_count IN NUMBER,
x_inactive_flag IN VARCHAR2,
x_freq_attempt IN NUMBER DEFAULT NULL,
x_max_attempt IN NUMBER DEFAULT NULL,
x_required_for_application IN VARCHAR2 DEFAULT NULL,
x_mode IN VARCHAR2 DEFAULT 'R',
x_legacy_record_flag IN VARCHAR2,
x_clprl_id IN NUMBER
) AS
/*
|| Created By : rasingh
|| Created On : 13-NOV-2000
|| Purpose : Handles the INSERT DML logic for the table.
|| Known limitations, enhancements or remarks :
|| Change History :
|| Who When What
|| (reverse chronological order - newest change first)
*/
CURSOR c IS
SELECT rowid
FROM igf_ap_td_item_inst_all
WHERE base_id = x_base_id
AND item_sequence_number = x_item_sequence_number;
x_last_update_date DATE;
x_last_updated_by NUMBER;
x_last_update_login NUMBER;
x_last_update_date := SYSDATE;
x_last_updated_by := 1;
x_last_update_login := 0;
x_last_updated_by := fnd_global.user_id;
IF (x_last_updated_by IS NULL) THEN
x_last_updated_by := -1;
x_last_update_login := fnd_global.login_id;
IF (x_last_update_login IS NULL) THEN
x_last_update_login := -1;
p_action => 'INSERT',
x_rowid => x_rowid,
x_base_id => x_base_id,
x_item_sequence_number => x_item_sequence_number,
x_status => x_status,
x_status_date => x_status_date,
x_add_date => x_add_date,
x_corsp_date => x_corsp_date,
x_corsp_count => x_corsp_count,
x_inactive_flag => x_inactive_flag,
x_freq_attempt => x_freq_attempt,
x_max_attempt => x_max_attempt,
x_required_for_application => x_required_for_application,
x_legacy_record_flag => x_legacy_record_flag,
x_creation_date => x_last_update_date,
x_created_by => x_last_updated_by,
x_last_update_date => x_last_update_date,
x_last_updated_by => x_last_updated_by,
x_last_update_login => x_last_update_login,
x_clprl_id => x_clprl_id
);
INSERT INTO igf_ap_td_item_inst_all (
base_id,
item_sequence_number,
status,
status_date,
add_date,
corsp_date,
corsp_count,
inactive_flag,
freq_attempt,
max_attempt,
required_for_application,
legacy_record_flag,
creation_date,
created_by,
last_update_date,
last_updated_by,
last_update_login,
org_id,
clprl_id
) VALUES (
new_references.base_id,
new_references.item_sequence_number,
new_references.status,
new_references.status_date,
new_references.add_date,
new_references.corsp_date,
new_references.corsp_count,
new_references.inactive_flag,
new_references.freq_attempt,
new_references.max_attempt,
new_references.required_for_application,
new_references.legacy_record_flag,
x_last_update_date,
x_last_updated_by,
x_last_update_date,
x_last_updated_by,
x_last_update_login,
l_org_id,
new_references.clprl_id
);
after_dml(p_action => 'INSERT');
END insert_row;
SELECT
status,
status_date,
add_date,
corsp_date,
corsp_count,
inactive_flag,
freq_attempt,
max_attempt,
required_for_application,
org_id,
legacy_record_flag,
clprl_id
FROM igf_ap_td_item_inst_all
WHERE rowid = x_rowid
FOR UPDATE NOWAIT;
fnd_message.set_name('FND', 'FORM_RECORD_DELETED');
PROCEDURE update_row (
x_rowid IN VARCHAR2,
x_base_id IN NUMBER,
x_item_sequence_number IN NUMBER,
x_status IN VARCHAR2,
x_status_date IN DATE,
x_add_date IN DATE,
x_corsp_date IN DATE,
x_corsp_count IN NUMBER,
x_inactive_flag IN VARCHAR2,
x_freq_attempt IN NUMBER DEFAULT NULL,
x_max_attempt IN NUMBER DEFAULT NULL,
x_required_for_application IN VARCHAR2 DEFAULT NULL,
x_mode IN VARCHAR2 DEFAULT 'R' ,
x_legacy_record_flag IN VARCHAR2,
x_clprl_id IN NUMBER
) AS
/*
|| Created By : rasingh
|| Created On : 13-NOV-2000
|| Purpose : Handles the UPDATE DML logic for the table.
|| Known limitations, enhancements or remarks :
|| Change History :
|| Who When What
|| (reverse chronological order - newest change first)
*/
x_last_update_date DATE ;
x_last_updated_by NUMBER;
x_last_update_login NUMBER;
x_last_update_date := SYSDATE;
x_last_updated_by := 1;
x_last_update_login := 0;
x_last_updated_by := fnd_global.user_id;
IF x_last_updated_by IS NULL THEN
x_last_updated_by := -1;
x_last_update_login := fnd_global.login_id;
IF (x_last_update_login IS NULL) THEN
x_last_update_login := -1;
p_action => 'UPDATE',
x_rowid => x_rowid,
x_base_id => x_base_id,
x_item_sequence_number => x_item_sequence_number,
x_status => x_status,
x_status_date => x_status_date,
x_add_date => x_add_date,
x_corsp_date => x_corsp_date,
x_corsp_count => x_corsp_count,
x_inactive_flag => x_inactive_flag,
x_freq_attempt => x_freq_attempt,
x_max_attempt => x_max_attempt,
x_required_for_application => x_required_for_application,
x_legacy_record_flag => x_legacy_record_flag,
x_creation_date => x_last_update_date,
x_created_by => x_last_updated_by,
x_last_update_date => x_last_update_date,
x_last_updated_by => x_last_updated_by,
x_last_update_login => x_last_update_login,
x_clprl_id => x_clprl_id
);
UPDATE igf_ap_td_item_inst_all
SET
status = new_references.status,
status_date = new_references.status_date,
add_date = new_references.add_date,
corsp_date = new_references.corsp_date,
corsp_count = new_references.corsp_count,
inactive_flag = new_references.inactive_flag,
freq_attempt = new_references.freq_attempt,
max_attempt = new_references.max_attempt,
required_for_application = new_references.required_for_application,
legacy_record_flag = new_references.legacy_record_flag,
last_update_date = x_last_update_date,
last_updated_by = x_last_updated_by,
last_update_login = x_last_update_login,
clprl_id = new_references.clprl_id
WHERE rowid = x_rowid;
after_dml(p_action => 'UPDATE');
END update_row;
|| Purpose : Adds a row if there is no existing row, otherwise updates existing row in the table.
|| Known limitations, enhancements or remarks :
|| Change History :
|| Who When What
|| (reverse chronological order - newest change first)
*/
CURSOR c1 IS
SELECT rowid
FROM igf_ap_td_item_inst_all
WHERE base_id = x_base_id
AND item_sequence_number = x_item_sequence_number;
insert_row (
x_rowid,
x_base_id,
x_item_sequence_number,
x_status,
x_status_date,
x_add_date,
x_corsp_date,
x_corsp_count,
x_inactive_flag,
x_freq_attempt,
x_max_attempt,
x_required_for_application,
x_mode,
x_legacy_record_flag,
x_clprl_id
);
update_row (
x_rowid,
x_base_id,
x_item_sequence_number,
x_status,
x_status_date,
x_add_date,
x_corsp_date,
x_corsp_count,
x_inactive_flag,
x_freq_attempt,
x_max_attempt,
x_required_for_application,
x_mode,
x_legacy_record_flag,
x_clprl_id
);
PROCEDURE delete_row (
x_rowid IN VARCHAR2
) AS
/*
|| Created By : rasingh
|| Created On : 13-NOV-2000
|| Purpose : Handles the DELETE DML logic for the table.
|| Known limitations, enhancements or remarks :
|| Change History :
|| Who When What
|| (reverse chronological order - newest change first)
*/
BEGIN
before_dml (
p_action => 'DELETE',
x_rowid => x_rowid
);
DELETE FROM igf_ap_td_item_inst_all
WHERE rowid = x_rowid;
END delete_row;