Inheritance: SqlStatement, IDeclarationStatement, IPlSqlStatement
        public static void DeclareCursorNoParameters()
        {
            var query = (SqlQueryExpression) SqlExpression.Parse("SELECT a, b FROM test_table GROUP BY a HAVING b > 3");
            var statement = new DeclareCursorStatement("c1", query);

            var sql = statement.ToString();

            var expected = new SqlStringBuilder();
            expected.AppendLine("CURSOR c1 IS");
            expected.Append("  SELECT a, b FROM test_table GROUP BY a HVAING b > 3");

            Assert.AreEqual(expected.ToString(), sql);
        }
        public static void DeclareCursorWithParameters()
        {
            var query = (SqlQueryExpression)SqlExpression.Parse("SELECT a, b FROM test_table WHERE a / 4 = c");
            var statement = new DeclareCursorStatement("c1", new []{new CursorParameter("c", PrimitiveTypes.Integer()), }, query);

            var sql = statement.ToString();

            var expected = new SqlStringBuilder();
            expected.AppendLine("CURSOR c1(c INTEGER) IS");
            expected.Append("  SELECT a, b FROM test_table WHERE a / 4 = c");

            Assert.AreEqual(expected.ToString(), sql);
        }
        public void InsensitiveSimpleCursor()
        {
            const string cursorName = "c";
            var query = (SqlQueryExpression) SqlExpression.Parse("SELECT * FROM APP.test_table");
            var statement = new DeclareCursorStatement(cursorName, query);

            statement.Execute(Query);

            var cursor = Query.FindCursor(cursorName);
            Assert.IsNotNull(cursor);
            Assert.AreEqual(cursorName, cursor.CursorInfo.CursorName);
            Assert.IsEmpty(cursor.CursorInfo.Parameters);
        }
        public static void DeclareCursorWithParameters()
        {
            var query     = (SqlQueryExpression)SqlExpression.Parse("SELECT a, b FROM test_table WHERE a / 4 = c");
            var statement = new DeclareCursorStatement("c1", new [] { new CursorParameter("c", PrimitiveTypes.Integer()), }, query);

            var sql = statement.ToString();

            var expected = new SqlStringBuilder();

            expected.AppendLine("CURSOR c1(c INTEGER) IS");
            expected.Append("  SELECT a, b FROM test_table WHERE a / 4 = c");

            Assert.AreEqual(expected.ToString(), sql);
        }
        public static void DeclareCursorNoParameters()
        {
            var query     = (SqlQueryExpression)SqlExpression.Parse("SELECT a, b FROM test_table GROUP BY a HAVING b > 3");
            var statement = new DeclareCursorStatement("c1", query);

            var sql = statement.ToString();

            var expected = new SqlStringBuilder();

            expected.AppendLine("CURSOR c1 IS");
            expected.Append("  SELECT a, b FROM test_table GROUP BY a HVAING b > 3");

            Assert.AreEqual(expected.ToString(), sql);
        }
        public void InsensitiveSimpleCursor()
        {
            const string cursorName = "c";
            var          query      = (SqlQueryExpression)SqlExpression.Parse("SELECT * FROM APP.test_table");
            var          statement  = new DeclareCursorStatement(cursorName, query);

            statement.Execute(Query);

            var cursor = Query.FindCursor(cursorName);

            Assert.IsNotNull(cursor);
            Assert.AreEqual(cursorName, cursor.CursorInfo.CursorName);
            Assert.IsEmpty(cursor.CursorInfo.Parameters);
        }
        public void InsensitiveWithParams()
        {
            const string cursorName = "c";
            var query = (SqlQueryExpression)SqlExpression.Parse("SELECT * FROM APP.test_table WHERE a = :a");
            var parameters = new[] {new CursorParameter("a", PrimitiveTypes.Integer())};
            var statement = new DeclareCursorStatement(cursorName, parameters, query);

            statement.Execute(Query);

            var cursor = Query.FindCursor(cursorName);
            Assert.IsNotNull(cursor);
            Assert.AreEqual(cursorName, cursor.CursorInfo.CursorName);
            Assert.IsNotEmpty(cursor.CursorInfo.Parameters);
        }
        public void InsensitiveWithParams()
        {
            const string cursorName = "c";
            var          query      = (SqlQueryExpression)SqlExpression.Parse("SELECT * FROM APP.test_table WHERE a = :a");
            var          parameters = new[] { new CursorParameter("a", PrimitiveTypes.Integer()) };
            var          statement  = new DeclareCursorStatement(cursorName, parameters, query);

            statement.Execute(Query);

            var cursor = Query.FindCursor(cursorName);

            Assert.IsNotNull(cursor);
            Assert.AreEqual(cursorName, cursor.CursorInfo.CursorName);
            Assert.IsNotEmpty(cursor.CursorInfo.Parameters);
        }
Example #9
0
 protected virtual SqlStatement VisitDeclareCursor(DeclareCursorStatement statement)
 {
     return new DeclareCursorStatement(statement.CursorName, statement.Parameters, statement.Flags, statement.QueryExpression);
 }
        public void DeclareCursor()
        {
            var query = (SqlQueryExpression) SqlExpression.Parse("SELECT * FROM table1, table2");
            var statement = new DeclareCursorStatement("c1", query);

            SerializeAndAssert(statement, (serialized, deserialized) => {
                Assert.IsNotNull(deserialized);
                Assert.AreEqual("c1", deserialized.CursorName);
                Assert.IsNotNull(deserialized.QueryExpression);
            });
        }
Example #11
0
 protected virtual SqlStatement VisitDeclareCursor(DeclareCursorStatement statement)
 {
     return(new DeclareCursorStatement(statement.CursorName, statement.Parameters, statement.Flags, statement.QueryExpression));
 }