Short answer:
- You can use the
host command directive to create pathnames. - The file will be created with the
append option, even if it does not already exist.
So that the answer to both questions would look convincing, I sketched a short script:
set trimspool on define off head off host cmd /c dir /b logs spool logs/test1.log host cmd /c if not exist logs md logs spool logs/test1.log append set termout off select '1 test output' output from dual; spool logs/test2.log select '2 test output' output from dual; spool logs/test1.log append select '3 test output' output from dual; spool off host cmd /c dir /b logs\*.log & type logs\*.log exit
And I added its output with comments:
--папка ещё не существует File Not Found -- и лог файл не создался SP2-0606: Cannot create SPOOL file "logs/test1.log" -- оба лог файлика поочерёдно создались, причём первый с append test1.log test2.log logs\test1.log 1 test output 3 test output logs\test2.log 2 test output
To the note: In response to a question that is not directly related to the current one, I gave an example of the dynamic definition of the sql script to run. Similarly, all parameters for spool , host , etc., can be dynamically determined.
host MD <dir>. Question 2 - the file is created withappend, as I recall. - 0xdbspool D:\folder\scripts.log appenddid so. - Viktorov