Search code examples
oracle-databaseliquibasesqlcl

Make liquibase output be spooled to the current spool file when running using sqlcl


Assume we have the following set of scripts:

test.sql

create or replace view asdas
as
select 1 val from dual
/

controller.xml

<?xml version="1.0" encoding="UTF-8"?> 
<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                      http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.9.xsd">
    <changeSet author="tim" id="01_tab1_seq" runAlways="true" >
      <sqlFile dbms="oracle"
               endDelimiter=";"
               path="test.sql"
               splitStatements="true"
               stripComments="false"/>
    </changeSet>
</databaseChangeLog> 

main.sql

spool output.log
lb update -changelog controller.xml
spool off
exit

When calling main.sql file I get the following output:

roman@UBUNTU-LT:/mnt/c/Users/%USERNAME%/Desktop/preset$ sql testuser/testuser@dev-db1 @main.sql

SQLcl: Release 21.1 Production on Thu Jul 22 16:36:34 2021

Copyright (c) 1982, 2021, Oracle.  All rights reserved.

Last Successful login time: Thu Jul 22 2021 16:36:37 +03:00

Connected to:
Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.7.0.0.0

SQL> set serveroutput on
SQL> set scan on
SQL> set linesize 4000
SQL> spool output.log
SQL> lb update -changelog controller.xml
ScriptRunner Executing: create or replace view asdas
as
select 1 val from dual
/Liquibase Executed:create or replace view asdas
as
select 1 val from dual
/

######## ERROR SUMMARY ##################
Errors encountered:0

SQL> spool off
SQL> exit
Disconnected from Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.7.0.0.0

And what I see in output.log:

SQL> lb update -changelog controller.xml

######## ERROR SUMMARY ##################
Errors encountered:0

SQL> spool off

Instead I want to see the whole log output that I see on the screen. Can I somehow force sqlcl to write it to the file I spool to?

I tried to add -log option to lb update but sqlcl just creates file with something looking like timestamp at the end of the name but this file is empty.


Solution

  • This would be a bug. Whatever you see in the console should be going into the SPOOL file. I'll log the bug for you - thanks for the test case & report!