File indexing completed on 2024-04-06 12:03:15
0001
0002
0003
0004
0005
0006
0007
0008
0009 CREATE OR REPLACE PROCEDURE master_payload_o2o (
0010 i_object_name IN VARCHAR2
0011 )
0012 AS
0013
0014 schema VARCHAR2(32) := NULL;
0015 top_level_table VARCHAR2(32) := NULL;
0016 schema_table VARCHAR(65) := NULL;
0017 start_time TIMESTAMP := NULL;
0018 plsql_block VARCHAR2(256) := NULL;
0019 last_id NUMBER(10) := NULL;
0020 cnt1 NUMBER(10) := 0;
0021 cnt2 NUMBER(10) := 0;
0022
0023 BEGIN
0024
0025
0026
0027 BEGIN
0028 SELECT schema, top_level_table INTO schema, top_level_table
0029 FROM O2O_SETUP WHERE object_name = i_object_name;
0030 EXCEPTION
0031 WHEN NO_DATA_FOUND THEN
0032 raise_application_error(-20101, 'Object ' || i_object_name || ' not found in O2O_SETUP table');
0033 END;
0034
0035 schema_table := schema || '.' || top_level_table;
0036
0037
0038 BEGIN
0039 EXECUTE IMMEDIATE 'SELECT count(*) FROM ' || schema_table INTO cnt1;
0040 EXECUTE IMMEDIATE 'SELECT max(IOV_VALUE_ID) FROM ' || schema_table INTO last_id;
0041 EXCEPTION
0042 WHEN OTHERS THEN
0043 raise_application_error(-20102, 'Cannot read top-level-table ' || schema_table, TRUE);
0044 END;
0045
0046
0047
0048
0049 IF last_id IS NULL THEN
0050 last_id := -1;
0051 END IF;
0052
0053
0054 SELECT systimestamp INTO start_time FROM dual;
0055
0056
0057 BEGIN
0058 plsql_block := 'BEGIN ' || schema || '.' || i_object_name || '_payload_o2o(:last_id); END;';
0059 EXECUTE IMMEDIATE plsql_block USING last_id;
0060 EXCEPTION
0061 WHEN OTHERS THEN
0062 raise_application_error(-20103, 'Cannot read ' || i_object_name || '_payload_o2o procedure', TRUE);
0063 END;
0064
0065
0066 EXECUTE IMMEDIATE 'SELECT count(*) FROM ' || schema_table INTO cnt2;
0067 EXECUTE IMMEDIATE 'SELECT max(IOV_VALUE_ID) FROM ' || schema_table INTO last_id;
0068
0069
0070 IF cnt2 != cnt1 THEN
0071 INSERT INTO o2o_log (object_name, last_id, num_transferred, transfer_start, transfer_duration)
0072 VALUES (i_object_name, last_id, cnt2 - cnt1, start_time, start_time - systimestamp);
0073 END IF;
0074 COMMIT;
0075
0076 END;
0077 /
0078 show errors;