8 namespace Deveel.Data.Sql.Compile {
13 const string sql =
"DECLARE CURSOR test_cursor (a INT, b VARCHAR) IS SELECT * FROM test_table WHERE test_table.a = a";
14 var result = Compile(sql);
16 Assert.IsNotNull(result);
17 Assert.IsFalse(result.HasErrors);
19 Assert.IsNotEmpty(result.Statements);
20 Assert.AreEqual(1, result.Statements.Count);
22 var statement = result.Statements.FirstOrDefault();
24 Assert.IsNotNull(statement);
29 Assert.AreEqual(
"test_cursor", cursorStatement.CursorName);
30 Assert.IsNotEmpty(cursorStatement.Parameters);
31 Assert.IsNotNull(cursorStatement.QueryExpression);
36 const string sql =
"CURSOR test_cursor (a INT, b VARCHAR) IS SELECT * FROM test_table WHERE test_table.a = a";
38 var result = Compile(sql);
40 Assert.IsNotNull(result);
41 Assert.IsFalse(result.HasErrors);
43 Assert.IsNotEmpty(result.Statements);
44 Assert.AreEqual(1, result.Statements.Count);
46 var statement = result.Statements.FirstOrDefault();
48 Assert.IsNotNull(statement);
53 Assert.AreEqual(
"test_cursor", cursorStatement.CursorName);
54 Assert.IsNotEmpty(cursorStatement.Parameters);
55 Assert.IsNotNull(cursorStatement.QueryExpression);
60 const string sql =
"DECLARE CURSOR test_cursor IS SELECT * FROM test_table WHERE test_table.a > 0";
62 var result = Compile(sql);
64 Assert.IsNotNull(result);
65 Assert.IsFalse(result.HasErrors);
67 Assert.IsNotEmpty(result.Statements);
68 Assert.AreEqual(1, result.Statements.Count);
70 var statement = result.Statements.FirstOrDefault();
72 Assert.IsNotNull(statement);
77 Assert.AreEqual(
"test_cursor", cursorStatement.CursorName);
78 Assert.IsEmpty(cursorStatement.Parameters);
79 Assert.IsNotNull(cursorStatement.QueryExpression);
84 const string sql =
"OPEN test_cursor (22, b)";
86 var result = Compile(sql);
88 Assert.IsNotNull(result);
89 Assert.IsFalse(result.HasErrors);
91 Assert.IsNotEmpty(result.Statements);
92 Assert.AreEqual(1, result.Statements.Count);
94 var statement = result.Statements.FirstOrDefault();
96 Assert.IsNotNull(statement);
100 Assert.AreEqual(
"test_cursor", cursorStatement.CursorName);
101 Assert.IsNotEmpty(cursorStatement.Arguments);
106 const string sql =
"OPEN test_cursor";
108 var result = Compile(sql);
110 Assert.IsNotNull(result);
111 Assert.IsFalse(result.HasErrors);
113 Assert.IsNotEmpty(result.Statements);
114 Assert.AreEqual(1, result.Statements.Count);
116 var statement = result.Statements.FirstOrDefault();
118 Assert.IsNotNull(statement);
122 Assert.AreEqual(
"test_cursor", cursorStatement.CursorName);
123 Assert.IsEmpty(cursorStatement.Arguments);
128 const string sql =
"CLOSE test_cursor";
130 var result = Compile(sql);
132 Assert.IsNotNull(result);
133 Assert.IsFalse(result.HasErrors);
135 Assert.IsNotEmpty(result.Statements);
136 Assert.AreEqual(1, result.Statements.Count);
138 var statement = result.Statements.FirstOrDefault();
140 Assert.IsNotNull(statement);
144 Assert.AreEqual(
"test_cursor", cursorStatement.CursorName);
149 const string sql =
"FETCH NEXT FROM test_cursor INTO test_table";
151 var result = Compile(sql);
153 Assert.IsNotNull(result);
154 Assert.IsFalse(result.HasErrors);
156 Assert.IsNotEmpty(result.Statements);
157 Assert.AreEqual(1, result.Statements.Count);
159 var statement = result.Statements.FirstOrDefault();
161 Assert.IsNotNull(statement);
165 Assert.AreEqual(
"test_cursor", cursorStatement.CursorName);
170 const string sql =
"FETCH NEXT";
172 var result = Compile(sql);
174 Assert.IsNotNull(result);
175 Assert.IsFalse(result.HasErrors);
177 Assert.IsNotEmpty(result.Statements);
178 Assert.AreEqual(1, result.Statements.Count);
180 var statement = result.Statements.FirstOrDefault();
182 Assert.IsNotNull(statement);
186 Assert.IsNullOrEmpty(cursorStatement.CursorName);
void DeclareCursorWithArguments()
void ImplicitDeclareCursor()
void DeclareCursorWithoutArguments()
void FetchNextFromCursorInto()
void OpenCursorWithArguments()
void FetchNextImplicitCursor()