ITPub博客

首页 > 数据库 > 数据库开发技术 > 有关动态显示不确定表的相关列的实现

有关动态显示不确定表的相关列的实现

原创 数据库开发技术 作者:jsfjp 时间:2007-02-05 00:29:16 0 删除 编辑
create or replace procedure dump_query( p_query in varchar2 )
is

l_columnValue varchar2
(4000);

l_status integer;

l_colCnt number default 0;

l_cnt number default 0;

l_line long;



/* We'll be using this to see how many columns

* we have to fetch so we can define them and

* then retrieve their values.

*/

l_descTbl dbms_sql.desc_tab;





/* Step 1 - open cursor. */

l_theCursor integer default dbms_sql.open_cursor;
begin



/* Step 2 - parse the input query so we can describe it. */

dbms_sql.parse( l_theCursor, p_query, dbms_sql.native );



/* Step 3 - now, describe the outputs of the query. */

dbms_sql.describe_columns( l_theCursor, l_colCnt, l_descTbl );



/* Step 4 - we do not use in this example, no BINDING needed.

* Step 5 - for each column, we need to define it, tell the database

* what we will fetch into. In this case, all data is going

* to be fetched into a single varchar2(4000) variable.

*/

for i in 1 .. l_colCnt

loop

dbms_sql
.define_column( l_theCursor, i, l_columnValue, 4000 );

end loop;



/* Step 6 - execute the statement. */

l_status := dbms_sql.execute(l_theCursor);



/* Step 7 - fetch all rows. */

while ( dbms_sql.fetch_rows(l_theCursor) > 0 )

loop

/* Build up a big output line, this is more efficient than calling

* DBMS_OUTPUT.PUT_LINE inside the loop.

*/

l_cnt := l_cnt+1;

l_line := l_cnt;

/* Step 8 - get and process the column data. */

for i in 1 .. l_colCnt loop

dbms_sql
.column_value( l_theCursor, i, l_columnValue );

l_line := l_line || ',' || l_columnValue;

end loop;



/* Now print out this line. */

dbms_output.put_line( l_line );

end loop;



/* Step 9 - close cursor to free up resources.. */

dbms_sql.close_cursor(l_theCursor);
exception

when others then

dbms_sql
.close_cursor( l_theCursor );

raise;
end dump_query;[@more@]恭喜您成功申请ITPUB BLOG,请牢记您BLOG的域名
http://jsfjp.itpub.net/
您BLOG的控制面板在
http://jsfjp.itpub.net/admin.php
登陆口令就是论坛口令,BLOG的口令和论坛是捆绑的。您可以在控制面板里完成发表文章,修改名称,模版以及观察统计数据等功能
全体ITPUB BLOG的内容首页在
http://weblog.itpub.net/
可以在这里了解整个ITPUB BLOG的状况,包括最新文章,BLOG列表,排名,统计数据等
怎样才可以使自己的BLOG变得知名?
只有宣传才可以使网站的访问增多,您可以把您的BLOG连接写在签名档里,或者在帖子里介绍给别的会员,也可以在别的网站和现实场合进行广泛的宣传。如果您的BLOG能被搜索引擎收录,那也对增加流量有所帮助。这也许需要您到一些常用搜索引擎那里登录一下。百度的登录入口:
http://www.baidu.com/search/url_submit.html
google的登录入口
http://www.google.com/intl/zh-CN/add_url.html
登录可以帮助您的BLOG尽快被收录(否则可能要等待比较长的时间)
法律责任
ITPUB是中华人民共和国境内网站,请大家在发表言论时注意遵守中华人民共和国法律,尊重知识产权,ITPUB只提供寄存平台,任何网友的个人言论都不代表ITPUB的观点,ITPUB也不会为网友的个人行为承担法律义务和责任

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/65557/viewspace-897328/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: 没有了~
请登录后发表评论 登录
全部评论
  • 博文量
    1
  • 访问量
    1299