运行 使用 sqlcl 时,使 liquibase 输出假脱机到当前假脱机文件
Make liquibase output be spooled to the current spool file when running using sqlcl
假设我们有以下一组脚本:
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
调用 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
只是创建了一个文件,其名称末尾看起来像时间戳,但这个文件是空的。
这将是一个错误。无论您在控制台中看到什么,都应该进入 SPOOL 文件。我会为您记录错误 - 感谢您提供测试用例和报告!
假设我们有以下一组脚本:
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
调用 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
只是创建了一个文件,其名称末尾看起来像时间戳,但这个文件是空的。
这将是一个错误。无论您在控制台中看到什么,都应该进入 SPOOL 文件。我会为您记录错误 - 感谢您提供测试用例和报告!