Is it possible to select the value of the second column using something like an index or column position if i dont know the name of the column?
Select col(2) FROM (
Select 'a', 'b',' c', 'd' from dual
)
Is it possible? Sure. You could write a PL/SQL block that used dbms_sql to open a cursor using the actual query against dual, describe the results, bind a variable to whatever you find the second column to be, fetch from the cursor, and then loop. That would be a terribly involved and generally rather painful process but it could be done.
The SQL language does not define a way to do this in a static SQL statement and Oracle does not provide an extension that would allow this. I'd be rather concerned about the underlying problem that you're trying to solve, though, if you somehow know that you want the second column but don't know what that column represents. That's not something that makes a lot of sense in a relational database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With