sql - How to control spooling and echo in oracle -
i need write deployment script execute each sql script , log buffer per spooling path defined.
deployment.sql set echo on; spool c:\temp\log\scriptlog\masterscript.log /* start executing script srcipt 1*/ @c:\scr\script1.sql; /* end executing script srcipt 1*/ spool c:\temp\log\scriptlog\masterscript.log append; /* start executing script srcipt 2*/ @c:\scr\script2.sql /* end executing script srcipt 2*/ set echo off spool off
above deployment script execute script1 , script2. want spooling of script1 , script2 should not append on spooling of deployment script . , spooling of deployment script should contains below mentioned (means logged in deployment script)
/* start executing script srcipt 2*/ @c:\scr\script2.sql /* end executing script srcipt 2*/
i tried possible solution used append of spooling , did googling lot did not appropriate solution. kindly suggest
script1.sql ---------------------------------------------------------------------------------------------- -- test_script.sql -- test script 1 ---------------------------------------------------------------------------------------------- set echo on spool c:\temp\log\scriptlog\script1.log begin /* inside spool of script 1 */ dbms_output.put_line('first script'); end; / spool off; set echo off; script2.sql ---------------------------------------------------------------------------------------------- -- test_script.sql -- test script 2 ---------------------------------------------------------------------------------------------- set echo on spool c:\temp\log\scriptlog\script2.log begin /* inside spool of script 2 */ dbms_output.put_line('second script'); end; / spool off; set echo off;
my requirement no single line of script1 , script2 spooling should append in deployment script , , mentioned spooling of script1 , script2 logged seperately provided
it isn't entirely clear want see in each log file, think close.
deployment.sql:
spool c:\temp\log\scriptlog\masterscript.log /* start executing script 1 */ @c:\scr\script1.sql spool c:\temp\log\scriptlog\masterscript.log append /* end executing script 1 */ /* start executing script 2 */ @c:\scr\script2.sql spool c:\temp\log\scriptlog\masterscript.log append /* end executing script 2 */ spool off
script1.sql:
spool off set echo off ---------------------------------------------------------------------------------------------- -- test_script.sql -- test script 1 ---------------------------------------------------------------------------------------------- set echo on spool c:\temp\log\scriptlog\script1.log begin /* inside spool of script 1 */ dbms_output.put_line('first script'); end; / spool off set echo off
and script2.sql same structure:
spool off set echo off ---------------------------------------------------------------------------------------------- -- test_script.sql -- test script 2 ---------------------------------------------------------------------------------------------- set echo on spool c:\temp\log\scriptlog\script2.log begin /* inside spool of script 2 */ dbms_output.put_line('second script'); end; / spool off set echo off
when run sql*plus produces masterscript.log:
sql> /* start executing script 1 */ sql> @c:\scr\script1.sql sql> /* end executing script 1 */ sql> sql> /* start executing script 2 */ sql> @c:\scr\script2.sql sql> /* end executing script 2 */ sql> sql> spool off
script1.log:
sql> sql> begin 2 /* inside spool of script 1 */ 3 4 dbms_output.put_line('first script'); 5 end; 6 / pl/sql procedure completed. sql> sql> spool off
and script2.log
sql> sql> begin 2 /* inside spool of script 2 */ 3 4 dbms_output.put_line('second script'); 5 end; 6 / pl/sql procedure completed. sql> sql> spool off
Comments
Post a Comment