Oracle Dynamic 'SQL select' query record type

假如想象 提交于 2019-12-12 01:47:12

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/6478419/oracle-dynamic-sql-select-query-record-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!