使用 sqlcl 运行时,将 liquibase 输出假脱机到当前假脱机文件

时间:2021-07-22 13:41:26

标签: oracle liquibase sqlcl

假设我们有以下脚本集:

测试.sql

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

控制器.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

调用 main.sql 文件时,我得到以下输出:

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

我在 output.log 中看到的:

SQL> lb update -changelog controller.xml

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

SQL> spool off

相反,我想查看我在屏幕上看到的整个日志输出。我可以以某种方式强制 sqlcl 将它写入我假脱机的文件吗?

我尝试向 -log 添加 lb update 选项,但 sqlcl 只是创建了名称末尾带有类似时间戳的文件,但该文件为空。

1 个答案:

答案 0 :(得分:1)

这将是一个错误。您在控制台中看到的任何内容都应该进入 SPOOL 文件。我会为您记录错误 - 感谢您的测试用例和报告!