• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to select only the colums of a table which are the same of another table

Resolved: How to select only the colums of a table which are the same of another table

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

info about polymorphic table functions
I’m using a polymorphic function (skip_col_not_in_model ) to remove the columns of a table which are not in another table.
I can compile the body. But not the spec.

[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 many dbms_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:
You can convert any describe only polymorphic table to a macro.

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!

oracle sql
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: correct policy to get secrets on local go app

22/03/2023

Resolved: Vue 3 watchEffect dependency tracking after asynchronous code

22/03/2023

Resolved: Watching state object in pinia doesn’t fire when object changes

22/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.