Java 代码,建议 打包成 jar:
package org.demo.sql;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
/**
* 生成 PLSQL批量补丁语句
*/
public class SqlBatch {
public static void main(String[] args) {
if (null != args && args.length > 0) {
String scriptSuffix = null; // 后缀名
String scriptPath = null;
String sqlPath = null;
String logPath = null;
for (String args0 : args) {
if (args0.startsWith("scriptSuffix=")) {
scriptSuffix = args0.split("scriptSuffix=")[1];
}
if (args0.startsWith("scriptPath=")) {
scriptPath = args0.split("scriptPath=")[1];
}
if (args0.startsWith("sqlPath=")) {
sqlPath = args0.split("sqlPath=")[1];
}
if (args0.startsWith("logPath=")) {
logPath = args0.split("logPath=")[1];
}
}
if (null != scriptPath) {
if (null == sqlPath) { // 默认生成到 SQL脚本 的父目录
sqlPath = new File(scriptPath).getParent();
}
if (null == logPath) { // 默认生成到 SQL脚本 的父目录
logPath = new File(scriptPath).getParent();
}
String[] scriptSuffixArray = null;
if (null != scriptSuffix) {
if (scriptSuffix.contains(",")) { // sql,pck,fnc,...
scriptSuffixArray = scriptSuffix.split(",");
} else {
scriptSuffixArray = new String[] { scriptSuffix };
}
}
scriptPath = scriptPath.replaceAll("\\\\", "/");
sqlPath = sqlPath.replaceAll("\\\\", "/");
logPath = logPath.replaceAll("\\\\", "/");
generateSQLPatch(scriptSuffixArray, scriptPath, sqlPath, logPath);
} else {
cmdE