/* * * Author : Vishal Gupta * Purpose : Script is run once at connection creation time * * Revision History: * =================== * Date Author Description * --------- ------------ --------------------------------------------------- * 05-Aug-04 Vishal Gupta Created * 12-Jul-12 Vishal Gupta Enable auto-logging by spooling output to a file * * */ set term off COLUMN user NEW_VALUE vg_USER noprint COLUMN instance_name NEW_VALUE vg_instance_name noprint COLUMN timestamp NEW_VALUE vg_timestamp noprint set feed off set head off select lower(user) "user" , to_char(sysdate,'YYYYMMDD_HH24MISS') timestamp from dual; select upper(instance_name) instance_name from v$instance; set feed on set head on set serveroutput on set lines 200 --SET SQLPROMPT "&&vg_USER@&&vg_instance_name:SQL> " COLUMN user CLEAR COLUMN instance_name CLEAR COLUMN timestamp CLEAR SET SQLPROMPT "&_CONNECT_IDENTIFIER:SQL> " -- -- Set following positional parameters, so that input values in all script -- can be defaulted to some value without getting prompted to enter the value -- when specific positional input is not passed to script. -- DEFINE 1="" DEFINE 2="" DEFINE 3="" DEFINE 4="" DEFINE 5="" DEFINE 6="" DEFINE 7="" DEFINE 8="" DEFINE 9="" DEFINE 10="" DEFINE 11="" DEFINE 12="" -- Set spool file to log all the action and output in the session. -- Create separate spool file for each session. -- Use instance name and timestamp to create unique and identifiable logfiles. -- Windows DEFINE VG_SPOOLDIR="C:\temp\sqlscripts_logs" DEFINE VG_SPOOLFILE="&&VG_SPOOLDIR\&&vg_instance_name._&&vg_timestamp..log" -- Unix --DEFINE VG_SPOOLDIR="$TMP" --DEFINE VG_SPOOLFILE="&&VG_SPOOLDIR/&&vg_instance_name._&&vg_timestamp..log" set term on --spool &&VG_SPOOLFILE append -- Display current session's information. @whoami