All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jn.sqlhelper.dialect.scriptfile.VerticaStatementBuilder Maven / Gradle / Ivy

Go to download

Database dialects ( supports pagination, UrlParser, SqlStatementParser, WallFilter, BatchExecutor for Test) based Java, you can use it in any ORM framework.

There is a newer version: 5.0.7
Show newest version
package com.jn.sqlhelper.dialect.scriptfile;

import com.jn.langx.util.Strings;
import com.jn.sqlhelper.common.sql.sqlscript.PlainSqlDelimiter;

/**
 * supporting Vertica specific syntax.
 */
public class VerticaStatementBuilder extends PostgreSQLSqlStatementBuilder {

    /**
     * Are we currently inside a BEGIN END; block?
     */
    private boolean insideBeginEndBlock;

    /**
     * Holds the beginning of the statement.
     */
    private String statementStart = "";

    @Override
    protected PlainSqlDelimiter changeDelimiterIfNecessary(String line, PlainSqlDelimiter delimiter) {
        if (Strings.countOccurrencesOf(statementStart, " ") < 4) {
            statementStart += line;
            statementStart += " ";
        }

        if (statementStart.startsWith("CREATE FUNCTION")) {
            if (line.startsWith("BEGIN") || line.endsWith("BEGIN")) {
                insideBeginEndBlock = true;
            }

            if (line.endsWith("END;")) {
                insideBeginEndBlock = false;
            }
        }

        if (insideBeginEndBlock) {
            return null;
        }
        return getDefaultDelimiter();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy