Oracle 动态“SQL 选择”查询记录类型
动态请求如下所示:
request := 'select * from ' || param_table_name || ' where ' || column_name_list;
然后我这样做:
open cur1 for request;
通过 cur1
获取的记录的确切类型直到运行时才知道,因为它不应该对该过程应用到的任何表施加任何限制。但是,如何迭代查询返回的内容呢?
The dynamic request looks like this:
request := 'select * from ' || param_table_name || ' where ' || column_name_list;
Then I do:
open cur1 for request;
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PL/SQL 游标无法处理编译时未知的列。
在 PL/SQL 中使用完全动态查询的唯一方法是使用 PL/SQL 包
DBMS_SQL
。更新:
Oracle 对 DBMS_SQL 包包含许多示例。
PL/SQL cursors cannot work with columns that aren't known a compile time.
To only way to work with fully dynamic queries in PL/SQL is by using the PL/SQL package
DBMS_SQL
.Update:
Oracle has a comprehensive description of the DBMS_SQL package with many examples.