表结构如下:
create table FB_P_PRJTODIV
(
SET_YEAR NUMBER(4) not null,
DIV_CODE VARCHAR2(36) not null,
PRJ_ID VARCHAR2(20) not null,
RG_CODE VARCHAR2(20),
LAST_VER VARCHAR2(40)
)
create table AA_CC
(
CHR_CODE VARCHAR2(42)
)如何往FB_P_PRJTODIV表循环插入FB_P_PRJTODIV表现有的数据,在插入的时候,div_code要替换成AA_CC的div_code,直到AA_CC表在FB_P_PRJTODIV都有div_code对应的信息。
create table FB_P_PRJTODIV
(
SET_YEAR NUMBER(4) not null,
DIV_CODE VARCHAR2(36) not null,
PRJ_ID VARCHAR2(20) not null,
RG_CODE VARCHAR2(20),
LAST_VER VARCHAR2(40)
)
create table AA_CC
(
CHR_CODE VARCHAR2(42)
)如何往FB_P_PRJTODIV表循环插入FB_P_PRJTODIV表现有的数据,在插入的时候,div_code要替换成AA_CC的div_code,直到AA_CC表在FB_P_PRJTODIV都有div_code对应的信息。
values (2010, '143010001', '03840001', '440304', '');insert into fb_p_prjtodiv (SET_YEAR, DIV_CODE, PRJ_ID, RG_CODE, LAST_VER)
values (2010, '143010001', '03850001', '440304', '');insert into fb_p_prjtodiv (SET_YEAR, DIV_CODE, PRJ_ID, RG_CODE, LAST_VER)
values (2010, '143010001', '03860001', '440304', '');insert into fb_p_prjtodiv (SET_YEAR, DIV_CODE, PRJ_ID, RG_CODE, LAST_VER)
values (2010, '143010001', '03870001', '440304', '');
insert into aa_cc (CHR_CODE)
values ('147010098');insert into aa_cc (CHR_CODE)
values ('148010098');insert into aa_cc (CHR_CODE)
values ('149010098');insert into aa_cc (CHR_CODE)
values ('146010098');insert into aa_cc (CHR_CODE)
values ('150010098');insert into aa_cc (CHR_CODE)
values ('148010008');insert into aa_cc (CHR_CODE)
values ('148010009');insert into aa_cc (CHR_CODE)
values ('148010010');insert into aa_cc (CHR_CODE)
values ('149010001');insert into aa_cc (CHR_CODE)
values ('149010002');insert into aa_cc (CHR_CODE)
values ('149010003');insert into aa_cc (CHR_CODE)
values ('149010004');insert into aa_cc (CHR_CODE)
values ('149010005');insert into aa_cc (CHR_CODE)
values ('149010006');insert into aa_cc (CHR_CODE)
values ('149010007');insert into aa_cc (CHR_CODE)
values ('149010008');insert into aa_cc (CHR_CODE)
values ('147010008');insert into aa_cc (CHR_CODE)
values ('147010009');insert into aa_cc (CHR_CODE)
values ('147010010');insert into aa_cc (CHR_CODE)
values ('147010011');insert into aa_cc (CHR_CODE)
values ('147010012');insert into aa_cc (CHR_CODE)
values ('147010013');insert into aa_cc (CHR_CODE)
values ('146010010');insert into aa_cc (CHR_CODE)
values ('146010011');insert into aa_cc (CHR_CODE)
values ('146010012');insert into aa_cc (CHR_CODE)
values ('146010013');insert into aa_cc (CHR_CODE)
values ('146010014');insert into aa_cc (CHR_CODE)
values ('146010015');insert into aa_cc (CHR_CODE)
values ('148010001');insert into aa_cc (CHR_CODE)
values ('148010002');insert into aa_cc (CHR_CODE)
values ('148010003');insert into aa_cc (CHR_CODE)
values ('148010004');insert into aa_cc (CHR_CODE)
values ('148010005');insert into aa_cc (CHR_CODE)
values ('148010006');insert into aa_cc (CHR_CODE)
values ('148010007');insert into aa_cc (CHR_CODE)
values ('146010005');insert into aa_cc (CHR_CODE)
values ('146010006');insert into aa_cc (CHR_CODE)
values ('146010007');insert into aa_cc (CHR_CODE)
values ('146010008');insert into aa_cc (CHR_CODE)
values ('146010009');insert into aa_cc (CHR_CODE)
values ('144010098');insert into aa_cc (CHR_CODE)
values ('145010098');insert into aa_cc (CHR_CODE)
values ('151010098');insert into aa_cc (CHR_CODE)
values ('152010098');insert into aa_cc (CHR_CODE)
values ('145010003');insert into aa_cc (CHR_CODE)
values ('146010016');insert into aa_cc (CHR_CODE)
values ('147010001');insert into aa_cc (CHR_CODE)
values ('150010001');insert into aa_cc (CHR_CODE)
values ('150010002');insert into aa_cc (CHR_CODE)
values ('150010003');insert into aa_cc (CHR_CODE)
values ('150010004');insert into aa_cc (CHR_CODE)
values ('150010005');insert into aa_cc (CHR_CODE)
values ('150010006');insert into aa_cc (CHR_CODE)
values ('150010007');insert into aa_cc (CHR_CODE)
values ('150010008');insert into aa_cc (CHR_CODE)
values ('150010009');insert into aa_cc (CHR_CODE)
values ('150010010');insert into aa_cc (CHR_CODE)
values ('150010011');insert into aa_cc (CHR_CODE)
values ('150010012');insert into aa_cc (CHR_CODE)
values ('145010009');insert into aa_cc (CHR_CODE)
values ('145010010');insert into aa_cc (CHR_CODE)
values ('143010098');insert into aa_cc (CHR_CODE)
values ('147010002');insert into aa_cc (CHR_CODE)
values ('147010003');insert into aa_cc (CHR_CODE)
values ('147010004');insert into aa_cc (CHR_CODE)
values ('147010005');insert into aa_cc (CHR_CODE)
values ('147010006');insert into aa_cc (CHR_CODE)
values ('147010007');insert into aa_cc (CHR_CODE)
values ('143010002');insert into aa_cc (CHR_CODE)
values ('144010002');insert into aa_cc (CHR_CODE)
values ('144010003');insert into aa_cc (CHR_CODE)
values ('144010004');insert into aa_cc (CHR_CODE)
values ('144010005');insert into aa_cc (CHR_CODE)
values ('144010006');insert into aa_cc (CHR_CODE)
values ('144010007');insert into aa_cc (CHR_CODE)
values ('144010008');insert into aa_cc (CHR_CODE)
values ('144010009');insert into aa_cc (CHR_CODE)
values ('144010010');insert into aa_cc (CHR_CODE)
values ('144010011');insert into aa_cc (CHR_CODE)
values ('145010001');insert into aa_cc (CHR_CODE)
values ('145010002');insert into aa_cc (CHR_CODE)
values ('145010008');insert into aa_cc (CHR_CODE)
values ('146010001');insert into aa_cc (CHR_CODE)
values ('146010002');insert into aa_cc (CHR_CODE)
values ('146010003');insert into aa_cc (CHR_CODE)
values ('146010004');insert into aa_cc (CHR_CODE)
values ('145010004');insert into aa_cc (CHR_CODE)
values ('145010005');insert into aa_cc (CHR_CODE)
values ('145010006');insert into aa_cc (CHR_CODE)
values ('145010007');insert into aa_cc (CHR_CODE)
values ('143010003');insert into aa_cc (CHR_CODE)
values ('143010004');insert into aa_cc (CHR_CODE)
values ('143010005');insert into aa_cc (CHR_CODE)
values ('143010006');insert into aa_cc (CHR_CODE)
values ('143010007');insert into aa_cc (CHR_CODE)
values ('143010013');insert into aa_cc (CHR_CODE)
values ('143010014');insert into aa_cc (CHR_CODE)
values ('144010001');insert into aa_cc (CHR_CODE)
values ('151010001');insert into aa_cc (CHR_CODE)
values ('151010002');insert into aa_cc (CHR_CODE)
values ('151010003');insert into aa_cc (CHR_CODE)
values ('151010004');insert into aa_cc (CHR_CODE)
values ('151010005');insert into aa_cc (CHR_CODE)
values ('152010001');insert into aa_cc (CHR_CODE)
values ('152010002');insert into aa_cc (CHR_CODE)
values ('143010008');insert into aa_cc (CHR_CODE)
values ('143010009');insert into aa_cc (CHR_CODE)
values ('143010010');insert into aa_cc (CHR_CODE)
values ('143010011');insert into aa_cc (CHR_CODE)
values ('143010012');insert into aa_cc (CHR_CODE)
values ('152010003');insert into aa_cc (CHR_CODE)
values ('152010004');insert into aa_cc (CHR_CODE)
values ('152010005');
for i in (select CHR_CODE from aa_cc) loop
insert into fb_p_prjtodiv select SET_YEAR, i.CHR_CODE, PRJ_ID, RG_CODE, LAST_VER from temp;
end loop;
end;drop table temp;