690: fetch_count NUMBER;
691: ignore NUMBER;
692: indx NUMBER := 1;
693:
694: id_table dbms_sql.Number_Table;
695: from_table dbms_sql.Date_Table;
696: to_table dbms_sql.Date_Table;
697: select_string VARCHAR2(4000);
698: update_string VARCHAR2(4000);
691: ignore NUMBER;
692: indx NUMBER := 1;
693:
694: id_table dbms_sql.Number_Table;
695: from_table dbms_sql.Date_Table;
696: to_table dbms_sql.Date_Table;
697: select_string VARCHAR2(4000);
698: update_string VARCHAR2(4000);
699: BEGIN
692: indx NUMBER := 1;
693:
694: id_table dbms_sql.Number_Table;
695: from_table dbms_sql.Date_Table;
696: to_table dbms_sql.Date_Table;
697: select_string VARCHAR2(4000);
698: update_string VARCHAR2(4000);
699: BEGIN
700: --sanity check
713: select_string := select_string || ':' || to_char(i) || ')';
714: END IF;
715: END LOOP;
716:
717: --use dbms_sql to execute the sql
718: c1 := dbms_sql.open_cursor;
719: dbms_sql.parse(c1, select_string, dbms_sql.native);
720:
721: --bind using the dest plan_ids from the phtable
714: END IF;
715: END LOOP;
716:
717: --use dbms_sql to execute the sql
718: c1 := dbms_sql.open_cursor;
719: dbms_sql.parse(c1, select_string, dbms_sql.native);
720:
721: --bind using the dest plan_ids from the phtable
722: i := p_phtable.FIRST;
715: END LOOP;
716:
717: --use dbms_sql to execute the sql
718: c1 := dbms_sql.open_cursor;
719: dbms_sql.parse(c1, select_string, dbms_sql.native);
720:
721: --bind using the dest plan_ids from the phtable
722: i := p_phtable.FIRST;
723: j := 1;
721: --bind using the dest plan_ids from the phtable
722: i := p_phtable.FIRST;
723: j := 1;
724: WHILE (i IS NOT NULL) LOOP
725: dbms_sql.bind_variable(c1, ':' || to_char(j), p_phtable(i).dest_id);
726: i := p_phtable.NEXT(i);
727: j := j + 1;
728: END LOOP;
729:
727: j := j + 1;
728: END LOOP;
729:
730: --set up the bulk collect arrays
731: dbms_sql.define_array(c1, 1, id_table, 20, indx);
732: dbms_sql.define_array(c1, 2, from_table, 20, indx);
733: dbms_sql.define_array(c1, 3, to_table, 20, indx);
734:
735: --execute the sql and collect the results
728: END LOOP;
729:
730: --set up the bulk collect arrays
731: dbms_sql.define_array(c1, 1, id_table, 20, indx);
732: dbms_sql.define_array(c1, 2, from_table, 20, indx);
733: dbms_sql.define_array(c1, 3, to_table, 20, indx);
734:
735: --execute the sql and collect the results
736: ignore := dbms_sql.execute(c1);
729:
730: --set up the bulk collect arrays
731: dbms_sql.define_array(c1, 1, id_table, 20, indx);
732: dbms_sql.define_array(c1, 2, from_table, 20, indx);
733: dbms_sql.define_array(c1, 3, to_table, 20, indx);
734:
735: --execute the sql and collect the results
736: ignore := dbms_sql.execute(c1);
737: loop
732: dbms_sql.define_array(c1, 2, from_table, 20, indx);
733: dbms_sql.define_array(c1, 3, to_table, 20, indx);
734:
735: --execute the sql and collect the results
736: ignore := dbms_sql.execute(c1);
737: loop
738: fetch_count := dbms_sql.fetch_rows(c1);
739:
740: dbms_sql.column_value(c1, 1, id_table);
734:
735: --execute the sql and collect the results
736: ignore := dbms_sql.execute(c1);
737: loop
738: fetch_count := dbms_sql.fetch_rows(c1);
739:
740: dbms_sql.column_value(c1, 1, id_table);
741: dbms_sql.column_value(c1, 2, from_table);
742: dbms_sql.column_value(c1, 3, to_table);
736: ignore := dbms_sql.execute(c1);
737: loop
738: fetch_count := dbms_sql.fetch_rows(c1);
739:
740: dbms_sql.column_value(c1, 1, id_table);
741: dbms_sql.column_value(c1, 2, from_table);
742: dbms_sql.column_value(c1, 3, to_table);
743:
744: exit when fetch_count <> 20;
737: loop
738: fetch_count := dbms_sql.fetch_rows(c1);
739:
740: dbms_sql.column_value(c1, 1, id_table);
741: dbms_sql.column_value(c1, 2, from_table);
742: dbms_sql.column_value(c1, 3, to_table);
743:
744: exit when fetch_count <> 20;
745: end loop;
738: fetch_count := dbms_sql.fetch_rows(c1);
739:
740: dbms_sql.column_value(c1, 1, id_table);
741: dbms_sql.column_value(c1, 2, from_table);
742: dbms_sql.column_value(c1, 3, to_table);
743:
744: exit when fetch_count <> 20;
745: end loop;
746: dbms_sql.close_cursor(c1);
742: dbms_sql.column_value(c1, 3, to_table);
743:
744: exit when fetch_count <> 20;
745: end loop;
746: dbms_sql.close_cursor(c1);
747:
748: --make sure we got everything
749: IF id_table.COUNT <> n THEN
750: x_msg_data := 'Invalid fetch count('||id_table.COUNT||'), expecting('||n||').';
764: END LOOP;
765:
766: --now perform the bulk DML update
767: update_string := 'UPDATE QA_PLANS SET effective_from = :1, effective_to = :2 WHERE plan_id = :3';
768: c2 := dbms_sql.open_cursor;
769: dbms_sql.parse(c2, update_string, dbms_sql.native);
770: dbms_sql.bind_array(c2, ':1', from_table);
771: dbms_sql.bind_array(c2, ':2', to_table);
772: dbms_sql.bind_array(c2, ':3', id_table);
765:
766: --now perform the bulk DML update
767: update_string := 'UPDATE QA_PLANS SET effective_from = :1, effective_to = :2 WHERE plan_id = :3';
768: c2 := dbms_sql.open_cursor;
769: dbms_sql.parse(c2, update_string, dbms_sql.native);
770: dbms_sql.bind_array(c2, ':1', from_table);
771: dbms_sql.bind_array(c2, ':2', to_table);
772: dbms_sql.bind_array(c2, ':3', id_table);
773: ignore := dbms_sql.execute(c2);
766: --now perform the bulk DML update
767: update_string := 'UPDATE QA_PLANS SET effective_from = :1, effective_to = :2 WHERE plan_id = :3';
768: c2 := dbms_sql.open_cursor;
769: dbms_sql.parse(c2, update_string, dbms_sql.native);
770: dbms_sql.bind_array(c2, ':1', from_table);
771: dbms_sql.bind_array(c2, ':2', to_table);
772: dbms_sql.bind_array(c2, ':3', id_table);
773: ignore := dbms_sql.execute(c2);
774: dbms_sql.close_cursor(c2);
767: update_string := 'UPDATE QA_PLANS SET effective_from = :1, effective_to = :2 WHERE plan_id = :3';
768: c2 := dbms_sql.open_cursor;
769: dbms_sql.parse(c2, update_string, dbms_sql.native);
770: dbms_sql.bind_array(c2, ':1', from_table);
771: dbms_sql.bind_array(c2, ':2', to_table);
772: dbms_sql.bind_array(c2, ':3', id_table);
773: ignore := dbms_sql.execute(c2);
774: dbms_sql.close_cursor(c2);
775:
768: c2 := dbms_sql.open_cursor;
769: dbms_sql.parse(c2, update_string, dbms_sql.native);
770: dbms_sql.bind_array(c2, ':1', from_table);
771: dbms_sql.bind_array(c2, ':2', to_table);
772: dbms_sql.bind_array(c2, ':3', id_table);
773: ignore := dbms_sql.execute(c2);
774: dbms_sql.close_cursor(c2);
775:
776: --return success
769: dbms_sql.parse(c2, update_string, dbms_sql.native);
770: dbms_sql.bind_array(c2, ':1', from_table);
771: dbms_sql.bind_array(c2, ':2', to_table);
772: dbms_sql.bind_array(c2, ':3', id_table);
773: ignore := dbms_sql.execute(c2);
774: dbms_sql.close_cursor(c2);
775:
776: --return success
777: x_msg_data := '';
770: dbms_sql.bind_array(c2, ':1', from_table);
771: dbms_sql.bind_array(c2, ':2', to_table);
772: dbms_sql.bind_array(c2, ':3', id_table);
773: ignore := dbms_sql.execute(c2);
774: dbms_sql.close_cursor(c2);
775:
776: --return success
777: x_msg_data := '';
778: x_return_status := fnd_api.g_true;
777: x_msg_data := '';
778: x_return_status := fnd_api.g_true;
779:
780: exception when others then
781: if dbms_sql.is_open(c1) then
782: dbms_sql.close_cursor(c1);
783: end if;
784: if dbms_sql.is_open(c2) then
785: dbms_sql.close_cursor(c2);
778: x_return_status := fnd_api.g_true;
779:
780: exception when others then
781: if dbms_sql.is_open(c1) then
782: dbms_sql.close_cursor(c1);
783: end if;
784: if dbms_sql.is_open(c2) then
785: dbms_sql.close_cursor(c2);
786: end if;
780: exception when others then
781: if dbms_sql.is_open(c1) then
782: dbms_sql.close_cursor(c1);
783: end if;
784: if dbms_sql.is_open(c2) then
785: dbms_sql.close_cursor(c2);
786: end if;
787: x_msg_data := 'unexpected error: Code('||SQLCODE||'), Message("'||SQLERRM||'")';
788: x_return_status := fnd_api.g_false;
781: if dbms_sql.is_open(c1) then
782: dbms_sql.close_cursor(c1);
783: end if;
784: if dbms_sql.is_open(c2) then
785: dbms_sql.close_cursor(c2);
786: end if;
787: x_msg_data := 'unexpected error: Code('||SQLCODE||'), Message("'||SQLERRM||'")';
788: x_return_status := fnd_api.g_false;
789: RETURN;