The following lines contain the word 'select', 'insert', 'update' or 'delete':
Select ece_stage_id_s.NEXTVAL
from dual;
select ece_document_id_s.NEXTVAL
from dual;
Build and Parses the Insert Statement for insert into ece_stage for each Level.
The Cursor handles are stored in the ec_utils.g_int_levels(i).cursor_handle.
**/
procedure parse_insert_statement
(
i_level in pls_integer
)
is
i_Insert_Cursor pls_integer;
cInsert_stmt varchar2(32000) := 'INSERT INTO ECE_STAGE ( ';
ec_debug.push('EC_OUTBOUND.PARSE_INSERT_STATEMENT');
cInsert_stmt := cInsert_stmt||' Stage_id, Document_Id , Transaction_type , Transaction_Level ,';
cInsert_stmt := cInsert_stmt||' Line_Number , Parent_Stage_Id , Run_Id , Document_Number ,Status ,';
cInsert_stmt := cInsert_stmt||' creation_date , created_by , last_update_date , last_updated_by ,';
--- Build Insert Statement
cInsert_stmt := cInsert_stmt||' '||ec_utils.g_file_tbl(i).staging_column|| ',';
cInsert_stmt := RTRIM(cInsert_stmt,',')||')';
cInsert_stmt := cInsert_stmt||cValue_stmt;
ec_debug.pl(3,'EC','ECE_STAGE_INSERT_LEVEL','LEVEL',i_level,null);
ec_debug.pl(3,cInsert_stmt);
i_Insert_Cursor := dbms_sql.Open_Cursor;
ec_debug.pl(3,'i_insert_cursor',i_insert_cursor);
ec_utils.g_ext_levels(i_level).cursor_handle := i_insert_cursor;
dbms_sql.parse(i_Insert_Cursor,cInsert_stmt,dbms_sql.native);
ec_debug.pl(0,'EC','ECE_PROGRAM_ERROR','PROGRESS_LEVEL','EC_OUTBOUND.PARSE_INSERT_STATEMENT');
ece_error_handling_pvt.print_parse_error (error_position,cInsert_stmt);
ec_debug.pop('EC_OUTBOUND.PARSE_INSERT_STATEMENT');
ec_debug.pl(0,'EC','ECE_PROGRAM_ERROR','PROGRESS_LEVEL','EC_OUTBOUND.PARSE_INSERT_STATEMENT');
END parse_insert_statement;
Prepares the Select statement for the ec_views on the base Oracle Applications tables.
**/
procedure select_clause
(
i_level IN pls_integer,
i_Where_string OUT NOCOPY VARCHAR2
) IS
cSelect_stmt VARCHAR2(32000) := 'SELECT ';
EC_DEBUG.PUSH('EC_OUTBOUND.SELECT_CLAUSE');
-- build SELECT statement
cSelect_stmt := cSelect_stmt || ' ' || cWord1 ||
nvl(ec_utils.g_file_tbl(i).base_column_Name,'NULL') || cWord2 || ',';
cSelect_stmt := RTRIM(cSelect_stmt, ',');
i_Where_string := cSelect_stmt||' '||cFrom_stmt||' '||cWhere_Stmt;
EC_DEBUG.POP('EC_OUTBOUND.SELECT_CLAUSE');
EC_DEBUG.PL(0,'EC','ECE_PROGRAM_ERROR','PROGRESS_LEVEL','EC_OUTBOUND.SELECT_CLAUSE');
END select_clause;
1. Select statement on the ec_views.
2. Insert statement for ece_stage table.
3. Parses and loads Custom Procedures into memory table.
4. Loads mappings required by these procedures into memory tables.
**/
procedure load_objects
is
i_counter pls_integer :=0;
select_clause
(
i,
ec_utils.g_int_levels(i).sql_stmt
);
-- Parse the Select Statement for Each level
BEGIN
dbms_sql.parse (
ec_utils.g_int_levels(i).cursor_handle,
ec_utils.g_int_levels(i).sql_stmt,
dbms_sql.native
);
-- Parse the Insert Statement for Staging table.
parse_insert_statement
(
i
);
Bind the values to the Insert statement for the ece_stage table.
**/
procedure bind_insert_statement
(
i_level in pls_integer
)
is
i_Insert_Cursor pls_integer := ec_utils.g_ext_levels(i_level).cursor_handle;
ec_debug.push('EC_OUTBOUND.BIND_INSERT_STATEMENT');
dbms_sql.bind_variable (i_Insert_Cursor,'a1',to_number(ec_utils.g_ext_levels(i_level).Stage_Id));
dbms_sql.bind_variable (i_Insert_Cursor,'a2',to_number(ec_utils.g_ext_levels(i_level).Document_Id));
dbms_sql.bind_variable (i_Insert_Cursor,'a3',ec_utils.g_transaction_type);
dbms_sql.bind_variable (i_Insert_Cursor,'a4',to_number(i_level));
dbms_sql.bind_variable (i_Insert_Cursor,'a5',to_number(ec_utils.g_ext_levels(i_level).Line_Number));
dbms_sql.bind_variable (i_Insert_Cursor,'a6',ec_utils.g_ext_levels(i_level).Parent_Stage_Id);
dbms_sql.bind_variable (i_Insert_Cursor,'a7',ec_utils.g_run_id);
dbms_sql.bind_variable (i_Insert_Cursor,'a8',ec_utils.g_ext_levels(i_level).Document_Number);
dbms_sql.bind_variable (i_Insert_Cursor,'a9',i_status);
dbms_sql.bind_variable (i_Insert_Cursor,'w1',sysdate);
dbms_sql.bind_variable (i_Insert_Cursor,'w2',fnd_global.user_id);
dbms_sql.bind_variable (i_Insert_Cursor,'w3',sysdate);
dbms_sql.bind_variable (i_Insert_Cursor,'w4',fnd_global.user_id);
ec_debug.pl(3,'LAST_UPDATE_DATE',sysdate);
ec_debug.pl(3,'LAST_UPDATED_BY',fnd_global.user_id);
i_Insert_Cursor,
'b'||k,ins_value,
500
);
dummy := dbms_sql.execute(i_Insert_Cursor);
ec_debug.pl(3,'EC','ECE_STAGE_INSERTED',null);
ec_debug.pl(0,'EC','ECE_STAGE_INSERT_FAILED','LEVEL',i_level);
ec_debug.pl(0,'EC','ECE_PROGRAM_ERROR','PROGRESS_LEVEL','EC_OUTBOUND.BIND_INSERT_STATEMENT');
ec_debug.pl(0,'EC','ECE_PROGRAM_ERROR','PROGRESS_LEVEL','EC_OUTBOUND.BIND_INSERT_STATEMENT');
ec_debug.pop('EC_OUTBOUND.BIND_INSERT_STATEMENT');
ec_debug.pl(0,'EC','ECE_PROGRAM_ERROR','PROGRESS_LEVEL','EC_OUTBOUND.BIND_INSERT_STATEMENT');
END bind_insert_statement;
Inserts the data into the staging table.
**/
procedure insert_into_stage
(
i_level in pls_integer
)
is
i_parent_stage_id pls_integer;
ec_debug.push('EC_OUTBOUND.INSERT_INTO_STAGE');
-- Insert data into Stage table
if i_level = 1
then
--Generate Document Id
open seq_document_id;
bind_insert_statement
(
i_level
);
ec_debug.pop('EC_OUTBOUND.INSERT_INTO_STAGE');
ec_debug.pl(0,'EC','ECE_PROGRAM_ERROR','PROGRESS_LEVEL','EC_OUTBOUND.INSERT_INTO_STAGE');
END insert_into_stage;
--Insert into Staging
insert_into_stage
(
ec_utils.g_int_ext_levels(k).external_level
);
--Insert into Staging
insert_into_stage
(
ec_utils.g_int_ext_levels(k).external_level
);
ec_utils.g_file_tbl.DELETE;
ec_utils.g_int_levels.DELETE;
ec_utils.g_ext_levels.DELETE;
ec_utils.g_int_ext_levels.DELETE;
ec_utils.g_stage_data.DELETE;
ec_utils.g_parameter_stack.DELETE;
ec_utils.g_procedure_stack.DELETE;
ec_utils.g_procedure_mappings.DELETE;
ec_utils.g_stack_pointer.DELETE;
select ece_output_runs_s.NEXTVAL
into i_run_id
from dual;
This file will delete all records in a staging table without using the
expense parsing of dbms_sql package. The RUN_ID parameter is the only required parameter.
The DOCUMENT_ID parameter can be optionally used to delete one document from the staging table
at a time.
**/
procedure delete_stage_data
(
i_run_id IN number,
i_document_id IN number DEFAULT NULL
) IS
BEGIN
if ec_debug.G_debug_level >= 2 then
ec_debug.push('EC_OUTBOUND.DELETE_STAGE_DATA');
ec_debug.pl(0,'EC','ECE_PARAM_MISSING','PARAMETER','I_RUN_ID', 'PROCEDURE','EC_OUTBOUND.DELETE_STAGE_DATA');
Delete all indicated records from ECE_STAGE
**/
DELETE FROM ece_stage
WHERE run_id = i_run_id
AND (document_id = i_document_id OR i_document_id IS NULL);
Output a warning message if no rows are deleted
**/
if ec_debug.G_debug_level >= 1 then
ec_debug.pl(1,'NO rows deleted from ECE_STAGE');
ec_debug.pl(3,'Number of rows deleted from ECE_STAGE',SQL%ROWCOUNT);
ec_debug.pop('EC_OUTBOUND.DELETE_STAGE_DATA');
ec_debug.pl(0,'EC','ECE_PROGRAM_ERROR','PROGRESS_LEVEL','EC_OUTBOUND.DELETE_STAGE_DATA');
END delete_stage_data;