加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ORACLE游标取数据的顺序

发布时间:2020-12-12 15:31:22 所属栏目:百科 来源:网络整理
导读:如: cursor c_columns(t_table_name varchar) is select column_name from user_tab_columns where table_name = t_table_name order by table_name,column_id; v_txt1:=''; for v_col in c_columns(v_tablename) loop --使用for循环 遍历游标内容 (for简单


如:

cursor c_columns(t_table_name varchar) is select column_name from user_tab_columns where table_name = t_table_name order by table_name,column_id;


v_txt1:='';
for v_col in c_columns(v_tablename) loop --使用for循环 遍历游标内容 (for简单)
v_column := v_col.column_name;
if v_column = 'STATDATE' THEN
v_txt1:=v_txt1||' ''20161130'' as '||v_column;
else
v_txt1:=v_txt1||','||v_column;
end if;
end loop;

游标中有ORDER BY,是按排序后的顺序读取

不加order by 就按默认排序,最好加order by,至于ordey by随机看你的字段唯一性了,一般是加个主键来排序的。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读