本文中介紹的幾種寫法分別是從代碼的簡易性
三種不同的寫法:
type TYPE_EMPLOYEES is table of EMPLOYEES%rowtype;
V_EMPLOYEES TYPE_EMPLOYEES;
v_table varchar
v_sql varchar
v_rows number:=
begin
execute immediate
v_table :=
v_sql :=
FIRST_NAME
LAST_NAME
EMAIL
PHONE_NUMBER
HIRE_DATE
JOB_ID
SALARY
COMMISSION_PCT
MANAGER_ID
DEPARTMENT_ID
BIRTHDAY)
values (:
select * bulk collect into V_EMPLOYEES from employees;
for i in
execute immediate v_sql
using V_EMPLOYEES(i)
if mod(i
commit;
end if;
end loop;
commit;
end;
create or replace procedure cp_data
type t_cur is REF cursor;
c_table t_cur;
type t_employee is table of employees%rowtype;
v_employees t_employee;
rows number :=
v_sql varchar
v_table varchar(
begin
v_table :=
open c_table for
select * from employees;
v_sql :=
FIRST_NAME
LAST_NAME
EMAIL
PHONE_NUMBER
HIRE_DATE
JOB_ID
SALARY
COMMISSION_PCT
MANAGER_ID
DEPARTMENT_ID
BIRTHDAY) values (:
loop
fetch c_table bulk collect
into v_employees limit rows;
dbms_output
for i in
execute immediate v_sql
using V_EMPLOYEES(i)
end loop;
commit;
exit when c_table%notfound;
end loop;
close c_table;
end;
create or replace procedure cp_data as
type type_EMPLOYEE_ID is table of EMPLOYEES
type type_FIRST_NAME is table of EMPLOYEES
type type_LAST_NAME is table of EMPLOYEES
type type_EMAIL is table of EMPLOYEES
type type_PHONE_NUMBER is table of EMPLOYEES
type type_HIRE_DATE is table of EMPLOYEES
type type_JOB_ID is table of EMPLOYEES
type type_SALARY is table of EMPLOYEES
type type_COMMISSION_PCT is table of EMPLOYEES
type type_MANAGER_ID is table of EMPLOYEES
type type_DEPARTMENT_ID is table of EMPLOYEES
type type_BIRTHDAY is table of EMPLOYEES
V_EMPLOYEE_ID TYPE_EMPLOYEE_ID;
V_FIRST_NAME TYPE_FIRST_NAME;
V_LAST_NAME TYPE_LAST_NAME;
V_EMAIL TYPE_EMAIL;
V_PHONE_NUMBER TYPE_PHONE_NUMBER;
V_HIRE_DATE TYPE_HIRE_DATE;
V_JOB_ID TYPE_JOB_ID;
V_SALARY TYPE_SALARY;
V_COMMISSION_PCT TYPE_COMMISSION_PCT;
V_MANAGER_ID TYPE_MANAGER_ID;
V_DEPARTMENT_ID TYPE_DEPARTMENT_ID;
V_BIRTHDAY TYPE_BIRTHDAY;
type t_cur is ref cursor;
c_table t_cur;
v_table varchar
v_sql varchar
v_rows number :=
begin
v_table :=
open c_table for
select * from employees;
v_sql :=
FIRST_NAME
LAST_NAME
EMAIL
PHONE_NUMBER
HIRE_DATE
JOB_ID
SALARY
COMMISSION_PCT
MANAGER_ID
DEPARTMENT_ID
BIRTHDAY)
values (:
loop
fetch c_table
bulk collect
into V_EMPLOYEE_ID
forall i in
V_EMPLOYEE_ID(i)
V_EMAIL(i)
V_JOB_ID(i)
V_MANAGER_ID(i)
;
commit;
exit when c_table%notfound;
end loop;
end;
select
column_name ||
from dba_tab_columns
where table_name =
and owner =
select
from dba_tab_columns
where table_name =
and owner =
select
from dba_tab_columns
where table_name =
and owner =
select
from dba_tab_columns
where table_name =
and owner =
From:http://tw.wingwit.com/Article/program/Oracle/201311/17422.html