GetColumnName () returns an Oracle alias

I am using ojdbc7.jar to connect to oracle with Java. For a query with an alias, when I do getColumnName() and getColumnLabel() from ResultSetMetaData , both return an alias. I want to have the original column name.

+5
source share
1 answer

This is not possible if you write a query in which the alias of the column (or function) will be added to some other name when the result set is passed to the next level (another query, as in a view, or a JDBC / ODBC call), metadata that the system about that request has only an alias.

The only way to find the original name is to track the SQL used back to its source (for example, if it calls the view, looks for the definition of the view, etc.).

Consider a view that associates a column with something else (essentially, what you do, because the view is just stored SQL, which runs on demand). The definition of the representation of this column will have only an alias (in fact, it is stored in dba_tab_columns), and not the original name. You have no way of knowing the original name, except for the definition of a view.

0
source

Source: https://habr.com/ru/post/1258261/


All Articles