求大大们帮忙写个ORACLE能用的存储过程,我用LOOP循环逐条查询始终有错,
还望哪位高人不吝赐教。
表一
1 2
abc abc
abc ab
abc abc
ab a表二
1 2
abc ab查询插入表二输出的结果是
1 2
abc abc
abc ab
ab a1和2是列名 在线等 本人小白 还请莫怪
还望哪位高人不吝赐教。
表一
1 2
abc abc
abc ab
abc abc
ab a表二
1 2
abc ab查询插入表二输出的结果是
1 2
abc abc
abc ab
ab a1和2是列名 在线等 本人小白 还请莫怪
解决方案 »
- 在linux下,启动oracle,提示LRM-00109: could not open parameter file.. initorcl.ora文件
- 在oracle 中参数的使用?
- 字段数据丢失
- Oracle菜鸟问:不能对我自己创建的用户下的表进行插入、修改和删除!!!急死了~~!!!~~~!~!~!~!
- 关于自增值
- 在英文操作系统环境下,怎样显示数据库内的中文内容
- 我是新手,有个问题请教一下!!!!!!!!!!!!!!!
- 如何取得快照执行失败的出错信息?
- ORACLE中表中创建一个序列,这个序列能不能自动更新?
- oracle两个表同时更新
- 请教一个关于日期时间的问题,着急在线等!
- 练习2
using (select * from tab1) a
on a.col1=b.col1 and a.col2=b.col2
when not matched then
insert values(b.col1,b.col2)
insert into tb2 select distinct a.* from (select * from tb1 minus select * from tb2) a
merge into tab2 b
using (select distinct * from tab1) a
on (a.col1=b.col1 and a.col2=b.col2)
when not matched then
insert values(a.col1,a.col2)
SQL> ed
已写入 file afiedt.buf 1 merge into b
2 using (select distinct col1,col2 from a) aa
3 on(aa.col1=b.col1 and aa.col2=b.col2)
4 when not matched then
5 insert
6* values (aa.col1,aa.col2)
SQL> /2 行已合并。SQL> select * from b;COL COL
--- ---
abc ab
abc abc
ab a
merge into 就能满足了!
begin
for c1 in (select col1,col2 from tab1) loop
for c2 in (select * from dual where (c1.col1,c1.col2) not in (select col1,col2 from tab2)) loop
insert into tab2 values c1;
end loop;
end loop;
end;
/
SQL code
begin
i := 0;
for c1 in (select col1,col2 from tab1) loop
for c2 in (select * from dual where (c1.col1,c1.col2) not in (select col1,col2 from tab2)) loop
i := i+1 ;
insert into tab2 values c1;
if(mod(i/10)=0)then
commit;
end if ;
end loop;
commit;
end loop;
end;
/