Oracle PLSQL 中批量执行脚本的代码生成工具

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值