猿问
回到首页
个人中心
反馈问题
注册登录
下载APP
首页
课程
实战
体系课
手记
专栏
慕课教程
oracle Execute Immediate(sql语句)
Execute Immediate(sql语句),执行后返回多条数据,怎么遍历其数据
杨__羊羊
浏览 1349
回答 1
1回答
慕尼黑的夜晚无繁华
Example 1:Output:ABCDECLARE TYPE var_typ IS TABLE OF VARCHAR2(4000); cVars var_typ; cVar VARCHAR2(4000);BEGIN EXECUTE IMMEDIATE ' SELECT ''A'' cc FROM dual UNION SELECT ''B'' cc FROM dual UNION SELECT ''C'' cc FROM dual' BULK COLLECT INTO cVars; FOR i IN 1 .. cVars.COUNT LOOP cVar := cVars(i); dbms_output.put_line (cVar); END LOOP;END;/ Example 2:Output:A CB DC EDECLARETYPE rec IS RECORD ( col1 VARCHAR2(30), col2 VARCHAR2(30) ); TYPE rec_table IS TABLE OF rec; results rec_table; tRow rec;BEGIN EXECUTE IMMEDIATE ' SELECT ''A'',''C'' FROM dual UNION SELECT ''B'',''D'' FROM dual UNION SELECT ''C'',''E'' FROM dual' BULK COLLECT INTO results; FOR i IN 1 .. results.COUNT LOOP tRow := results(i); dbms_output.put_line(tRow.col1 || ' ' || tRow.col2); END LOOP;END;/
0
0
0
打开App,查看更多内容
随时随地看视频
慕课网APP
相关分类
Oracle
继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续