从 ant 执行 sqlplus 找不到 DYLD_LIBRARY_PATH
Execute sqlplus from ant fails to find DYLD_LIBRARY_PATH
我正在尝试使用 sqlplus 的执行标记从 Apache Ant 中 运行 SQL 脚本。
<exec dir="src/sql" executable="sqlplus" failonerror="true" output="src/sql/test.sql.err">
<arg value="${db.login}"/>
<arg value="@test.sql"/>
</exec>
Sqlplus 使用相同的参数从命令行运行。
蚂蚁,然而 returns:
dyld: Library not loaded: /ade/b/2649109290/oracle/sqlplus/lib/libsqlplus.dylib
对于我设置的命令行:
export DYLD_LIBRARY_PATH=/Applications/instantclient_11_2/
我需要采取等效的操作让 Ant 找到这些库吗?
一个选择是尝试使用 SQLcl。
这是来自 sqldev 的 sql 脚本引擎,它是 sqlplus ,还有更多
http://www.oracle.com/technetwork/developer-tools/sqlcl/overview/sqlcl-index-2994757.html
好处是没有库,它是自包含的,并使用 JDBC 瘦驱动程序进行数据库连接。
这是您的 ANT 示例..
<project name="sqlcl" basedir=".">
<property name="db.login" value="klrice/klrice"/>
<target name="sqlcl">
<exec dir="." executable="/Users/klrice/Downloads/sqlcl/bin/sql"
failonerror="true"
output="sql/test.sql.err">
<arg value="${db.login}"/>
<arg value="@sql/dual.sql"/>
</exec>
</target>
</project>
然后运行...
$ ant sqlcl
Buildfile: /Users/klrice/build.xml
sqlcl:
BUILD SUCCESSFUL
Total time: 3 seconds
587211042:~ klrice$ more sql/test.sql.err
SQLcl: Release 17.4.0 Production on Wed Mar 07 21:59:54 2018
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Last Successful login time: Wed Mar 07 2018 22:00:08 -05:00
Connected to:
Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production
login.sql found in the CWD. DB access is restricted for login.sql.
Adjust the SQLPATH to include the path to enable full functionality.
1
----------
1
Disconnected from Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production
使用@kris-rice建议的解决方案,这是我的实现,包括检查错误...
<!-- =================================================================== -->
<!-- load plsql tox -->
<!-- =================================================================== -->
<target name="compile.plsql.tox" description="compile plsql for tox">
<echo message="compile.plsql.tox --------------------"/>
<mkdir dir="tmp/log"/>
<exec dir="src/sql" executable="sql" failonerror="true" output="src/sql/tox.all.sql.err">
<arg value="${db.login.tox}"/>
<arg value="@tox.all.sql"/>
</exec>
<echo message="looking for plsql errors -------------------"/>
<exec dir="src/sql" executable="grep" failonerror="false" resultproperty="found">
<arg value="LINE/COL ERROR"/>
<arg value="tox.all.sql.err"/>
</exec>
<fail message="plsql compile errors">
<condition>
<equals arg1="${found}" arg2="0"/>
</condition>
</fail>
<echo message="looking for line item errors ---------------"/>
<exec dir="src/sql" executable="grep" failonerror="false" resultproperty="found">
<arg value="ERROR at"/>
<arg value="tox.all.sql.err"/>
</exec>
<fail message="sql compile errors">
<condition>
<equals arg1="${found}" arg2="0"/>
</condition>
</fail>
<echo message="compile.plsql.tox --------------------"/>
</target>
<!-- =================================================================== -->
我正在尝试使用 sqlplus 的执行标记从 Apache Ant 中 运行 SQL 脚本。
<exec dir="src/sql" executable="sqlplus" failonerror="true" output="src/sql/test.sql.err">
<arg value="${db.login}"/>
<arg value="@test.sql"/>
</exec>
Sqlplus 使用相同的参数从命令行运行。
蚂蚁,然而 returns:
dyld: Library not loaded: /ade/b/2649109290/oracle/sqlplus/lib/libsqlplus.dylib
对于我设置的命令行:
export DYLD_LIBRARY_PATH=/Applications/instantclient_11_2/
我需要采取等效的操作让 Ant 找到这些库吗?
一个选择是尝试使用 SQLcl。 这是来自 sqldev 的 sql 脚本引擎,它是 sqlplus ,还有更多 http://www.oracle.com/technetwork/developer-tools/sqlcl/overview/sqlcl-index-2994757.html
好处是没有库,它是自包含的,并使用 JDBC 瘦驱动程序进行数据库连接。
这是您的 ANT 示例..
<project name="sqlcl" basedir=".">
<property name="db.login" value="klrice/klrice"/>
<target name="sqlcl">
<exec dir="." executable="/Users/klrice/Downloads/sqlcl/bin/sql"
failonerror="true"
output="sql/test.sql.err">
<arg value="${db.login}"/>
<arg value="@sql/dual.sql"/>
</exec>
</target>
</project>
然后运行...
$ ant sqlcl
Buildfile: /Users/klrice/build.xml
sqlcl:
BUILD SUCCESSFUL
Total time: 3 seconds
587211042:~ klrice$ more sql/test.sql.err
SQLcl: Release 17.4.0 Production on Wed Mar 07 21:59:54 2018
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Last Successful login time: Wed Mar 07 2018 22:00:08 -05:00
Connected to:
Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production
login.sql found in the CWD. DB access is restricted for login.sql.
Adjust the SQLPATH to include the path to enable full functionality.
1
----------
1
Disconnected from Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production
使用@kris-rice建议的解决方案,这是我的实现,包括检查错误...
<!-- =================================================================== -->
<!-- load plsql tox -->
<!-- =================================================================== -->
<target name="compile.plsql.tox" description="compile plsql for tox">
<echo message="compile.plsql.tox --------------------"/>
<mkdir dir="tmp/log"/>
<exec dir="src/sql" executable="sql" failonerror="true" output="src/sql/tox.all.sql.err">
<arg value="${db.login.tox}"/>
<arg value="@tox.all.sql"/>
</exec>
<echo message="looking for plsql errors -------------------"/>
<exec dir="src/sql" executable="grep" failonerror="false" resultproperty="found">
<arg value="LINE/COL ERROR"/>
<arg value="tox.all.sql.err"/>
</exec>
<fail message="plsql compile errors">
<condition>
<equals arg1="${found}" arg2="0"/>
</condition>
</fail>
<echo message="looking for line item errors ---------------"/>
<exec dir="src/sql" executable="grep" failonerror="false" resultproperty="found">
<arg value="ERROR at"/>
<arg value="tox.all.sql.err"/>
</exec>
<fail message="sql compile errors">
<condition>
<equals arg1="${found}" arg2="0"/>
</condition>
</fail>
<echo message="compile.plsql.tox --------------------"/>
</target>
<!-- =================================================================== -->