Have a look at dbms_db_version: https://docs.oracle.com/en/database/oracle/oracle-database/19/arpls/DBMS_DB_VERSION.html#GUID-A1439959-DDE4-49A5-8DEC-3F…
With the information in there you could encapsulate your queries in some plsql with conditional compilation. For a quick start, see Oracle-Base (who else): https://oracle-base.com/articles/10g/conditional-compilation-10gr2
Thank you for reply.
It seems the question was not as obvious and primitive as I though
Question is about sqlcl script. (The link provided refers to Oracle database documentation)
After debugging a bit I found the answer myself.
Here is an example implementation of login.sql for sqlcl.
var dbVersion = conn.getVersionNumber();
if (dbVersion >= 18000)
stmt = "select INSTANCE_NAME, HOST_NAME, VERSION_FULL from v$instance;";
stmt = "select INSTANCE_NAME, HOST_NAME, VERSION from v$instance;";
Ah, I see. Sorry, I misunderstood.
Happy to see you found a solution, though.