Oracle动态"SQL选择"查询记录类型 [英] Oracle Dynamic 'SQL select' query record type
本文介绍了Oracle动态"SQL选择"查询记录类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
动态请求如下:
request := 'select * from ' || param_table_name || ' where ' || column_name_list;
然后我这样做:
open cur1 for request;
直到运行时才知道通过cur1
提取的记录的确切类型,因为它不应对该过程应用于的表施加任何限制.但是,然后如何遍历查询返回的内容呢?
The exact type of record fetched via cur1
isn't known until runtime, because it should impose no restrictions on whatever table this procedure is applied to. But then, how do I iterate through what the query returns?
推荐答案
PL/SQL游标不能与编译时间未知的列一起使用.
PL/SQL cursors cannot work with columns that aren't known a compile time.
在PL/SQL中使用完全动态查询的唯一方法是使用PL/SQL包DBMS_SQL
.
To only way to work with fully dynamic queries in PL/SQL is by using the PL/SQL package DBMS_SQL
.
更新:
Oracle对 DBMS_SQL 的全面描述a>包含许多示例的软件包.
Oracle has a comprehensive description of the DBMS_SQL package with many examples.
这篇关于Oracle动态"SQL选择"查询记录类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文