vines
vines

Reputation: 5225

Oracle Dynamic 'SQL select' query record type

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?

Upvotes: 0

Views: 1780

Answers (1)

Codo
Codo

Reputation: 78825

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.

Upvotes: 5

Related Questions