Sep 22, 2010

sql escape character setup

in sqlplus setting the "&" as a literal, you need to do the following.
set escape \
select * from bla where blabla = 'xxx \&';
note: you should really set the escape sqlplus parameter in a glogin.sql or login.sql

Sep 21, 2010

sample login.sql using sql variabes

Use the following to set up variables that are based on values from sql output.
Use the new_value option in the sqlplus column command.
See the example below which grabs the instance name of the database that is being used.

SQL> set termout off timing off feedback off
SQL> column instance new_value instance_name
SQL> select instance_name instance from v$instance ;
SQL> set termout on timing on feedback on
SQL> prompt &instance_name


note: The first set statement hides the output from running the v$instance sql query.