Question:
info about polymorphic table functionsI’m using a polymorphic function (skip_col_not_in_model ) to remove the columns of a table which are not in another table.
[Error] Compilation (24: 59): PLS-00766: more than one parameter of TABLE type is not allowed
Similary to this query
a1:1
I would like to do that
a1:1, a2: 2 (expected resulted only)
The problem comes from the fact that I can’t give two table.
to avoid this problem, I can give the table_model as a string, get the column (search in table all_tab_columns ). But the code is not so easy to understand anymore und doesn’t work with common table expression. Has somebody ideas of improvement?
code
Answer:
You can do this (from 19.6) using SQL macros. Unlike polymorphic table functions, these allow you to have manydbms_tf.table_t
arguments.SQL macros return the text of a SQL expression which is constructed at parse time. So here you can build the select list similar to the method you’ve used in the PTF.
For example:
to avoid this problem, I can give the table_model as a string
In general this doesn’t work! As the docs say:
While the constant scalar values are passed as-is to the DESCRIBE function, all other values are passed as NULLs.
So if you use a bind variable to pass the table name, it’s value is null.
In this example, notice that when using
:new_col
for the string parameter val
its null
in the describe
:If you have better answer, please add a comment about this, thank you!