Package com.alibaba.druid.sql.dialect.sqlserver.parser

Examples of com.alibaba.druid.sql.dialect.sqlserver.parser.SQLServerStatementParser.parseStatementList()


public class SQLServerDropIndex_Test_2 extends TestCase {

    public void test_alter_first() throws Exception {
        String sql = "DROP INDEX IX_ProductVendor_VendorID     ON Purchasing.ProductVendor;";
        SQLServerStatementParser parser = new SQLServerStatementParser(sql);
        SQLStatement stmt = parser.parseStatementList().get(0);
        parser.match(Token.EOF);

        SQLServerSchemaStatVisitor visitor = new SQLServerSchemaStatVisitor();
        stmt.accept(visitor);
View Full Code Here


        String sql = "SELECT 1";

        String expect = "SELECT 1";

        SQLServerStatementParser parser = new SQLServerStatementParser(sql);
        SQLStatement stmt = parser.parseStatementList().get(0);

        String text = TestUtils.outputSqlServer(stmt);

        Assert.assertEquals(expect, text);
View Full Code Here

    public void test_0() throws Exception {
        String sql = "CREATE TABLE #Test (C1 nvarchar(10), C2 nvarchar(50), C3 datetime);";

        SQLServerStatementParser parser = new SQLServerStatementParser(sql);
        List<SQLStatement> statementList = parser.parseStatementList();
        SQLCreateTableStatement stmt = (SQLCreateTableStatement) statementList.get(0);

        Assert.assertEquals(1, statementList.size());

        String output = SQLUtils.toSQLString(stmt, JdbcConstants.SQL_SERVER);
View Full Code Here

        String sql = "INSERT Production.ScrapReason OUTPUT INSERTED.ScrapReasonID, INSERTED.Name, INSERTED.ModifiedDate INTO @MyTableVar VALUES (N'Operator error', GETDATE());";

        SQLServerStatementParser parser = new SQLServerStatementParser(sql);
        parser.setParseCompleteValues(false);
        parser.setParseValuesSize(3);
        List<SQLStatement> statementList = parser.parseStatementList();
        SQLStatement stmt = statementList.get(0);

        SQLServerInsertStatement insertStmt = (SQLServerInsertStatement) stmt;

        Assert.assertEquals(1, insertStmt.getValuesList().size());
View Full Code Here

        String sql = "INSERT TOP(5)INTO dbo.EmployeeSales  OUTPUT inserted.EmployeeID, inserted.FirstName, inserted.LastName, inserted.YearlySales SELECT sp.BusinessEntityID, c.LastName, c.FirstName, sp.SalesYTD FROM Sales.SalesPerson AS sp INNER JOIN Person.Person AS c ON sp.BusinessEntityID = c.BusinessEntityID WHERE sp.SalesYTD > 250000.00 ORDER BY sp.SalesYTD DESC;";

        SQLServerStatementParser parser = new SQLServerStatementParser(sql);
        parser.setParseCompleteValues(false);
        parser.setParseValuesSize(3);
        List<SQLStatement> statementList = parser.parseStatementList();
        SQLStatement stmt = statementList.get(0);

        SQLServerInsertStatement insertStmt = (SQLServerInsertStatement) stmt;

        Assert.assertEquals(0, insertStmt.getValuesList().size());
View Full Code Here

                        "\n\tJOIN HumanResources.EmployeeAddress ea ON ea.EmployeeID = e.EmployeeID" + //
                        "\n\tJOIN Person.Address a ON a.AddressID = ea.AddressID" + //
                        "\n\tJOIN Person.StateProvince sp ON sp.StateProvinceID = a.StateProvinceID";

        SQLServerStatementParser parser = new SQLServerStatementParser(sql);
        SQLStatement stmt = parser.parseStatementList().get(0);

        String text = TestUtils.outputSqlServer(stmt);

        Assert.assertEquals(expect, text);
View Full Code Here

        "\n\t\tOR '1' = ?" +
        "\n\t\tOR t.need_control = 0)" +
        "\nORDER BY t.sort_order";

        SQLServerStatementParser parser = new SQLServerStatementParser(sql);
        SQLStatement stmt = parser.parseStatementList().get(0);

        String text = TestUtils.outputSqlServer(stmt);

        Assert.assertEquals(expect, text);
View Full Code Here

        String sql = "SELECT TOP ? * FROM T";

        String expect = "SELECT TOP ? *\nFROM T";

        SQLServerStatementParser parser = new SQLServerStatementParser(sql);
        SQLSelectStatement stmt = (SQLSelectStatement) parser.parseStatementList().get(0);

        String text = TestUtils.outputSqlServer(stmt);

        Assert.assertEquals(expect, text);

View Full Code Here

                        + "\n\tINNER JOIN Person.Address a ON a.AddressID = c.ContactID" //
                        + "\nWHERE TerritoryID IS NOT NULL" //
                        + "\n\tAND SalesYTD <> 0";

        SQLServerStatementParser parser = new SQLServerStatementParser(sql);
        SQLStatement stmt = parser.parseStatementList().get(0);

        String text = TestUtils.outputSqlServer(stmt);

        Assert.assertEquals(expect, text);
View Full Code Here

public class SQLServerAlterTableTest_2 extends TestCase {

    public void test_alter_first() throws Exception {
        String sql = "ALTER TABLE dependencies ADD PRIMARY KEY(id)";
        SQLServerStatementParser parser = new SQLServerStatementParser(sql);
        SQLStatement stmt = parser.parseStatementList().get(0);
        parser.match(Token.EOF);

        SQLServerSchemaStatVisitor visitor = new SQLServerSchemaStatVisitor();
        stmt.accept(visitor);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.