Skip to content
Advertisement

How to select columns on the basis of column names in Oracle

I tried the following, but that doesn’t work.

Advertisement

Answer

In this example, I’m composing a select statement based on list of columns from a table (passed to function as a parameter) whose name satisfies certain condition. As it is Scott’s emp table and its columns don’t have any suffix, I’m choosing columns whose name contains letter E.

Based on that list of columns (aggregated with listagg), l_str variable contains a full select statement which is – in turn – a source for refcursor.

Testing:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement