How to create a dynamic spool file for SQLPLUS

De Notas pessoais

The example below will show you how to create a new log file for each execution of the script:

column vpath old_value new_vpath
column dt    old_value new_dt
column ext   old_value new_ext
select 'F:\DBA_Scripts\logs\' vpath,to_char(sysdate,'yyyymmdd_hh24miss') dt, '_Atualiza.log' ext from dual;
spool &new_vpath&new_dt&new_ext
select sysdate from dual;

For the example above, each time the script runs a new log will be created as follows:


Ferramentas pessoais

contador de visitas