18 using System.Collections.Generic;
25 namespace Deveel.Data.Sql.Cursors {
28 if (cursorInfo == null)
29 throw new ArgumentNullException(
"cursorInfo");
42 get {
return State.Status; }
61 throw new ObjectDisposedException(
"Cursor");
76 var orderedParams = parameters.OrderBy(x => x.Offset).ToArray();
77 if (args == null || args.Length != orderedParams.Length)
78 throw new ArgumentException();
80 var result =
new Dictionary<string, SqlExpression>();
81 for (
int i = 0; i < orderedParams.Length; i++) {
82 var param = orderedParams[i];
84 result[param.ParameterName] = arg;
92 var prepared = PrepareQuery(args);
94 return queryPlan.Evaluate(context);
107 result = Evaluate(context, args);
109 State.Open(result, args);
122 throw new ArgumentNullException(
"context");
126 throw new ArgumentException(String.Format(
"Cursor '{0}' is not SCROLL: can fetch only NEXT value.",
CursorInfo.
CursorName));
128 var table = State.Result;
130 table = Evaluate(context.
Request, State.OpenArguments);
132 var fetchRow = State.FetchRowFrom(table, context.
Direction, context.
Offset);
136 FetchIntoReference(context.
Request, fetchRow, reference);
139 FetchIntoVatiable(context.
Request, fetchRow, varName);
144 throw new NotImplementedException();
148 if (reference == null)
149 throw new ArgumentNullException(
"reference");
151 var table = request.
Query.GetMutableTable(reference);
155 throw new NotImplementedException();
160 GC.SuppressFinalize(
this);
172 #region CursorArgumentPreparer
175 private readonly Dictionary<string, SqlExpression>
args;
188 if (!args.TryGetValue(varRef, out exp))
189 throw new ArgumentException(String.Format(
"Variable '{0}' was not found in the cursor arguments", varRef));
SqlQueryExpression PrepareQuery(SqlExpression[] args)
bool CanPrepare(SqlExpression expression)
Verifies whether the instance of the interface can prepare the given expression.
Defines the contract to access the data contained into a table of a database.
An expression that references an object within a context.
void Open(IRequest context, params SqlExpression[] args)
void FetchIntoReference(IRequest request, Row row, ObjectName reference)
Dictionary< string, SqlExpression > BuildArgs(IEnumerable< CursorParameter > parameters, SqlExpression[] args)
Cursor(CursorInfo cursorInfo)
Represents a database object, such as a table, a trigger, a type or a column.
ObjectName FullName
Gets the fully qualified name of the object used to resolve it uniquely within the database...
Describes the name of an object within a database.
CursorArgumentPreparer(Dictionary< string, SqlExpression > args)
A single row in a table of a database.
readonly Dictionary< string, SqlExpression > args
SqlQueryExpression QueryExpression
SqlExpression Prepare(SqlExpression expression)
Returns the new translated object to be mutated from the given expression.
void FetchInto(FetchContext context)
An interface used to prepare a SqlExpression object.
virtual SqlExpression Prepare(IExpressionPreparer preparer)
DbObjectType ObjectType
Gets the type of database object that the implementation is for
void FetchIntoVatiable(IRequest request, Row row, string varName)
ITable Evaluate(IRequest context, SqlExpression[] args)
Defines the base class for instances that represent SQL expression tree nodes.
ICollection< CursorParameter > Parameters
DbObjectType
The kind of objects that can be handled by a database system and its managers
void Dispose(bool disposing)
new IQueryContext Context