且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从Java运行sqlplus脚本的简单方法

更新时间:2023-11-28 21:55:28

我们遇到了同样的问题...简而言之,目前还没有现成的解决方案:如果打开 Maven 源,您会看到他们使用的是基于正则表达式的简单脚本拆分器,该脚本拆分器适用于简单脚本,但通常在例如存储过程.

We've bumped into the same problem... In brief, there are no ready solutions for that: if you open Ant or Maven sources, you'll see they are using a simple regexp-based script splitter which is fine for simple scripts, but usually fails on e.g. stored procedures.

确实有用于PL/SQL的ANTLR解析器,例如 Alexandre Porcelli的解析器-非常接近,但仍不能用作嵌入式解决方案.

There are indeed ANTLR parsers for PL/SQL, such as Alexandre Porcelli's one—those are very close, but still not ready to be used as a drop-in solution.

我们最终编写了

We ended up writing yet another ad hoc splitter which is aware of some sqlplus commands like / and EXIT— it's still ugly, but works for most of our scripts.