Skip to content

Instantly share code, notes, and snippets.

@xtender xtender/example.sql
Created Jun 15, 2019

Embed
What would you like to do?
Conditional glogin for sqlplus and sqlcl
[oracle@ORA193 admin]$ cat glogin.sql
set ver off feed off;
col conditional_glogin new_val conditional_glogin noprint
col _PWD new_val _PWD noprint;
select '' as "_PWD" from dual where 1=0;
select nvl2('&_PWD','sqlcl','sqlplus') conditional_glogin from dual;
@@&conditional_glogin
set ver on feed on;
[oracle@ORA193 admin]$ cat sqlcl.sql
prompt SQLCL!
[oracle@ORA193 admin]$ cat sqlplus.sql
prompt SQLPLUS!
[oracle@ORA193 admin]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Jun 15 21:44:13 2019
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQLPLUS!
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@ORA193 admin]$ sql / as sysdba
SQLcl: Release 19.1 Production on Sat Jun 15 21:44:20 2019
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQLCL!
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
set ver off feed off;
col conditional_glogin new_val conditional_glogin noprint
col _PWD new_val _PWD noprint;
select '' as "_PWD" from dual where 1=0;
select nvl2('&_PWD','sqlcl','sqlplus') conditional_glogin from dual;
@@&conditional_glogin
set ver on feed on;
prompt SQLCL!
prompt SQLPLUS!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.