利用Oracle动态游标实现动态SQL循环遍历
利用Oracle动态游标实现动态SQL循环遍历
- create or replace procedure P_TEST_SQL is
- TYPE ref_cursor_type IS REF CURSOR; --定义一个动态游标
- tablename varchar2(200) default 'ess_client';
- v_sql varchar2(1000);
- mobile varchar2(15);
- usrs ref_cursor_type;
- begin
- --使用连接符拼接成一条完整SQL
- v_sql := 'select usrmsisdn from '||tablename||' where rownum < 11';
- --打开游标
- open usrs for v_sql ;
- loop
- fetch usrs into mobile;
- exit when usrs%notfound;
- insert into tmp(usrmsisdn) values(mobile);
- end loop;
- close usrs;
- commit;
- end P_TEST_SQL;
相关推荐
IT之家 2020-03-11
graseed 2020-10-28
zbkyumlei 2020-10-12
SXIAOYI 2020-09-16
jinhao 2020-09-07
impress 2020-08-26
liuqipao 2020-07-07
淡风wisdon大大 2020-06-06
yoohsummer 2020-06-01
chenjia00 2020-05-29
baike 2020-05-19
扭来不叫牛奶 2020-05-08
hxmilyy 2020-05-11
黎豆子 2020-05-07
xiongweiwei00 2020-04-29
Cypress 2020-04-25
冰蝶 2020-04-20