How can we insert the data obtained in Table A into another table B?
(1) For tables A and B with the same structure [number of fields, type of corresponding fields, etc.], you can use
Insert into B select * From;
Insert into B (field1, field2, field3) Select a. field1, A. field2, A. field3 from;
(2) If the number of fields in two tables is different but the structure of several fields is the same (similar to parent-child relationship), you must use insert into B (field1, field2) Select. field1,. field2 from;
1. Use a cursor with parameters to implement the insert function:
Create or replace procedure get_data (
-- Parameter list:
N_task_id in number, -- task id
V_task_name in varchar2, -- Task Name
V_name in varchar2 -- name
)
-----------------------------------------------
-- Procedure name: get_data --
-- Comment content: obtain qualified data from the data source table and insert it to the target data table :--
-- Reference: n_tas_id task id ,--
-- V_task_namek Task Name ,--
-- V_bdw_name restrictions on the data source table: Intranet name --
-----------------------------------------------
Is
-- Insert row number control
I _count number (5 );
-- Data cursor: data_cur (in_name)
-- Parameter: Intranet name: in_name
Cursor data_cur (in_name varchar2) is/** note: the Parameter definition does not contain precision **/
Select *
From get_data_src
Where a. Name = in_name;
Begin
-- Counter to control the number of inserted rows
I _count: = 0;
-- Insert data cyclically
For mycur in data_cur (v_name) loop
Insert into ABC (
Row_id,
Task_id,
Task_name,
Get_data_dt,
Cust_id,
Assign_flag,
Deal_date
) Values (
Seq_kd.nextval,
N_task_id,
V_task_name,
Sysdate,
Mycur. cust_id,
'N ',
Null
);