public Row Fetch(FetchDirection direction, int offset) { Evaluate(); if (Result == null) { return(null); } if (direction != FetchDirection.Absolute && direction != FetchDirection.Relative && offset > -1) { throw new ArgumentException("Cannot set the offset for a non-relative and non-absolute fetch direction."); } int realOffset; if (direction == FetchDirection.Next) { realOffset = currentOffset + 1; } else if (direction == FetchDirection.Prior) { realOffset = currentOffset - 1; } else if (direction == FetchDirection.First) { realOffset = 0; } else if (direction == FetchDirection.Last) { realOffset = Result.RowCount - 1; } else if (direction == FetchDirection.Absolute) { realOffset = offset; } else if (direction == FetchDirection.Relative) { realOffset = offset + currentOffset; } else { throw new ArgumentException(); } if (realOffset >= Result.RowCount || realOffset < 0) { Status = CursorStatus.Closed; return(null); } var row = Result.GetRow(realOffset); currentOffset = realOffset; Status = CursorStatus.Fetching; return(row); }
public Row Fetch(FetchDirection direction, int offset) { lock (this) { AssertNotClosed(); if (!CursorInfo.IsScroll && direction != FetchDirection.Next) { throw new ScrollCursorFetchException(CursorInfo.CursorName); } var table = State.Result; if (!CursorInfo.IsInsensitive) { if (Context == null) { throw new CursorOutOfContextException(CursorInfo.CursorName); } IList <IDbObject> refs; table = Evaluate(Context, State.OpenArguments, out refs); } return(State.FetchRowFrom(table, direction, offset)); } }
public FetchIntoStatement(string cursorName, FetchDirection direction, SqlExpression offsetExpression, SqlExpression referenceExpression) { if (offsetExpression != null) { if (direction != FetchDirection.Absolute && direction != FetchDirection.Relative) { throw new ArgumentException("Cannot specify an offset for a FETCH that is not RELATIVE or ABSOLUTE"); } } if (String.IsNullOrEmpty(cursorName)) { throw new ArgumentNullException("cursorName"); } if (referenceExpression == null) { throw new ArgumentNullException("referenceExpression"); } CursorName = cursorName; Direction = direction; OffsetExpression = offsetExpression; ReferenceExpression = referenceExpression; }
public FetchStatement(string cursorName, FetchDirection direction, SqlExpression offsetExpression) { if (offsetExpression != null) { if (direction != FetchDirection.Absolute && direction != FetchDirection.Relative) throw new ArgumentException("Cannot specify an offset for a FETCH that is not RELATIVE or ABSOLUTE"); } CursorName = cursorName; Direction = direction; OffsetExpression = offsetExpression; }
private static bool TryParseDirection(string s, out FetchDirection direction) { #if PCL return Enum.TryParse(s, true, out direction); #else try { direction = (FetchDirection) Enum.Parse(typeof (FetchDirection), s, true); return true; } catch (Exception) { direction = new FetchDirection(); return false; } #endif }
private static bool TryParseDirection(string s, out FetchDirection direction) { #if PCL return(Enum.TryParse(s, true, out direction)); #else try { direction = (FetchDirection)Enum.Parse(typeof(FetchDirection), s, true); return(true); } catch (Exception) { direction = new FetchDirection(); return(false); } #endif }
public FetchContext(IRequest request, FetchDirection direction, SqlExpression reference) { if (request == null) throw new ArgumentNullException("request"); if (reference == null) throw new ArgumentNullException("reference"); if (reference.ExpressionType != SqlExpressionType.VariableReference && reference.ExpressionType != SqlExpressionType.Reference) throw new ArgumentException("Invalid reference expression type."); Request = request; Direction = direction; Reference = reference; }
public FetchStatement(string cursorName, FetchDirection direction, SqlExpression offsetExpression) { if (offsetExpression != null) { if (direction != FetchDirection.Absolute && direction != FetchDirection.Relative) { throw new ArgumentException("Cannot specify an offset for a FETCH that is not RELATIVE or ABSOLUTE"); } } CursorName = cursorName; Direction = direction; OffsetExpression = offsetExpression; }
public static Row Fetch(this IRequest request, string cursorName, FetchDirection direction, SqlExpression offset) { var result = request.ExecuteStatement(new FetchStatement(cursorName, direction, offset)); if (result.Type == StatementResultType.Exception) { throw result.Error; } if (result.Type != StatementResultType.Result) { throw new InvalidOperationException(); } return(result.Result.GetRow(0)); }
internal Row FetchRowFrom(ITable table, FetchDirection direction, int offset) { int rowOffset; if (direction == FetchDirection.Next) { rowOffset = CurrentOffset + 1; } else if (direction == FetchDirection.Prior) { rowOffset = CurrentOffset - 1; } else if (direction == FetchDirection.First) { rowOffset = CurrentOffset = 0; } else if (direction == FetchDirection.Last) { rowOffset = table.RowCount - 1; } else if (direction == FetchDirection.Absolute) { rowOffset = offset; } else if (direction == FetchDirection.Relative) { rowOffset = CurrentOffset + offset; } else { // Should never happen throw new InvalidOperationException("Invalid fetch direction"); } if (rowOffset < 0 || rowOffset >= table.RowCount) { Status = CursorStatus.NotFetching; CurrentRow = null; } else { Status = CursorStatus.Fetching; CurrentRow = table.GetRow(rowOffset); } CurrentOffset = rowOffset; return(CurrentRow); }
internal Row FetchRowFrom(ITable table, FetchDirection direction, int offset) { int rowOffset; if (direction == FetchDirection.Next) { rowOffset = CurrentOffset + 1; } else if (direction == FetchDirection.Prior) { rowOffset = CurrentOffset - 1; } else if (direction == FetchDirection.First) { rowOffset = CurrentOffset = 0; } else if (direction == FetchDirection.Last) { rowOffset = table.RowCount; } else if (direction == FetchDirection.Absolute) { rowOffset = offset; } else if (direction == FetchDirection.Relative) { rowOffset = CurrentOffset + offset; } else { // Should never happen throw new InvalidOperationException(); } if (rowOffset < 0 || rowOffset >= table.RowCount) { throw new IndexOutOfRangeException( String.Format("The fetch offset '{0}' is smaller than zero or greater than the result set ({1}).", rowOffset, table.RowCount)); } CurrentOffset = rowOffset; Status = CursorStatus.Fetching; return(table.GetRow(rowOffset)); }
public FetchIntoStatement(string cursorName, FetchDirection direction, SqlExpression offsetExpression, SqlExpression referenceExpression) { if (offsetExpression != null) { if (direction != FetchDirection.Absolute && direction != FetchDirection.Relative) throw new ArgumentException("Cannot specify an offset for a FETCH that is not RELATIVE or ABSOLUTE"); } if (String.IsNullOrEmpty(cursorName)) throw new ArgumentNullException("cursorName"); if (referenceExpression == null) throw new ArgumentNullException("referenceExpression"); CursorName = cursorName; Direction = direction; OffsetExpression = offsetExpression; ReferenceExpression = referenceExpression; }
public FetchContext(IRequest request, FetchDirection direction, SqlExpression reference) { if (request == null) { throw new ArgumentNullException("request"); } if (reference == null) { throw new ArgumentNullException("reference"); } if (reference.ExpressionType != SqlExpressionType.VariableReference && reference.ExpressionType != SqlExpressionType.Reference) { throw new ArgumentException("Invalid reference expression type."); } Request = request; Direction = direction; Reference = reference; }
public void FetchNextStatement(FetchDirection d) { switch (d) { case FetchDirection.UP: if (CurrentIndex > 0) { CurrentIndex--; } break; case FetchDirection.DOWN: if (CurrentIndex < DataToClassify.Count - 1) { CurrentIndex++; } break; default: break; } UpdateStatement(); }
public FetchStatement(string cursorName, FetchDirection direction) { CursorName = cursorName; Direction = direction; }
public override SqlStatement VisitFetchStatement(PlSqlParser.FetchStatementContext context) { string cursorName = Name.Simple(context.cursor_name()); FetchDirection direction = FetchDirection.Next; int offset = -1; var fetchDirection = context.fetchDirection(); if (fetchDirection != null) { if (fetchDirection.ABSOLUTE() != null) { var value = Number.PositiveInteger(fetchDirection.numeric()); if (value == null) { throw new ParseCanceledException("FETCH ABSOLUTE requires a numeric offset."); } direction = FetchDirection.Absolute; offset = value.Value; } else if (fetchDirection.RELATIVE() != null) { var value = Number.PositiveInteger(fetchDirection.numeric()); if (value == null) { throw new ParseCanceledException("FETCH RELATIVE requires a numeric offset."); } direction = FetchDirection.Relative; offset = value.Value; } else if (fetchDirection.NEXT() != null) { direction = FetchDirection.Next; } else if (fetchDirection.PRIOR() != null) { direction = FetchDirection.Prior; } else if (fetchDirection.FIRST() != null) { direction = FetchDirection.First; } else if (fetchDirection.LAST() != null) { direction = FetchDirection.Last; } } var offsetExp = offset == -1 ? null : SqlExpression.Constant(offset); if (context.INTO() != null) { SqlExpression refExpression; var tableName = Name.Object(context.objectName()); var varNames = context.variable_name().Select(Name.Simple).ToArray(); if (tableName != null) { refExpression = SqlExpression.Reference(tableName); } else { refExpression = SqlExpression.Tuple(varNames.Select(SqlExpression.VariableReference).Cast <SqlExpression>().ToArray()); } return(new FetchIntoStatement(cursorName, direction, offsetExp, refExpression)); } return(new FetchStatement(cursorName, direction, offsetExp)); }
public void Read(TProtocol iprot) { iprot.IncrementRecursionDepth(); try { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.I64) { SubscriptionId = iprot.ReadI64(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 2: if (field.Type == TType.String) { SquareChatMid = iprot.ReadString(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 3: if (field.Type == TType.String) { SyncToken = iprot.ReadString(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 4: if (field.Type == TType.I32) { Limit = iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 5: if (field.Type == TType.I32) { Direction = (FetchDirection)iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); } finally { iprot.DecrementRecursionDepth(); } }
internal Row FetchRowFrom(ITable table, FetchDirection direction, int offset) { int rowOffset; if (direction == FetchDirection.Next) { rowOffset = CurrentOffset + 1; } else if (direction == FetchDirection.Prior) { rowOffset = CurrentOffset - 1; } else if (direction == FetchDirection.First) { rowOffset = CurrentOffset = 0; } else if (direction == FetchDirection.Last) { rowOffset = table.RowCount - 1; } else if (direction == FetchDirection.Absolute) { rowOffset = offset; } else if (direction == FetchDirection.Relative) { rowOffset = CurrentOffset + offset; } else { // Should never happen throw new InvalidOperationException("Invalid fetch direction"); } if (rowOffset < 0 || rowOffset >= table.RowCount) { Status = CursorStatus.NotFetching; CurrentRow = null; } else { Status = CursorStatus.Fetching; CurrentRow = table.GetRow(rowOffset); } CurrentOffset = rowOffset; return CurrentRow; }
public Row Fetch(FetchDirection direction) { return(Fetch(direction, -1)); }
internal Row FetchRowFrom(ITable table, FetchDirection direction, int offset) { int rowOffset; if (direction == FetchDirection.Next) { rowOffset = CurrentOffset + 1; } else if (direction == FetchDirection.Prior) { rowOffset = CurrentOffset - 1; } else if (direction == FetchDirection.First) { rowOffset = CurrentOffset = 0; } else if (direction == FetchDirection.Last) { rowOffset = table.RowCount; } else if (direction == FetchDirection.Absolute) { rowOffset = offset; } else if (direction == FetchDirection.Relative) { rowOffset = CurrentOffset + offset; } else { // Should never happen throw new InvalidOperationException(); } if (rowOffset < 0 || rowOffset >= table.RowCount) throw new IndexOutOfRangeException( String.Format("The fetch offset '{0}' is smaller than zero or greater than the result set ({1}).", rowOffset, table.RowCount)); CurrentOffset = rowOffset; Status = CursorStatus.Fetching; return table.GetRow(rowOffset); }
public FetchStatement(string cursorName, FetchDirection direction) { CursorName = cursorName; Direction = direction; }
public static void FetchInto(this IRequest request, string cursorName, FetchDirection direction, SqlExpression reference, SqlExpression offset) { request.ExecuteStatement(new FetchIntoStatement(cursorName, direction, offset, reference)); }
public FetchStatement(string cursorName, FetchDirection direction) : this(cursorName, direction, null) { }
public FetchStatement(string cursorName, FetchDirection direction) : this(cursorName, direction, null) { }
public static Row Fetch(this IRequest request, string cursorName, FetchDirection direction) { return(Fetch(request, cursorName, direction, null)); }
public async Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken) { iprot.IncrementRecursionDepth(); try { TField field; await iprot.ReadStructBeginAsync(cancellationToken); while (true) { field = await iprot.ReadFieldBeginAsync(cancellationToken); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.I64) { SubscriptionId = await iprot.ReadI64Async(cancellationToken); } else { await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken); } break; case 2: if (field.Type == TType.String) { SquareChatMid = await iprot.ReadStringAsync(cancellationToken); } else { await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken); } break; case 3: if (field.Type == TType.String) { SyncToken = await iprot.ReadStringAsync(cancellationToken); } else { await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken); } break; case 4: if (field.Type == TType.I32) { Limit = await iprot.ReadI32Async(cancellationToken); } else { await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken); } break; case 5: if (field.Type == TType.I32) { Direction = (FetchDirection)await iprot.ReadI32Async(cancellationToken); } else { await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken); } break; default: await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken); break; } await iprot.ReadFieldEndAsync(cancellationToken); } await iprot.ReadStructEndAsync(cancellationToken); } finally { iprot.DecrementRecursionDepth(); } }
public static void FetchInto(this IRequest request, string cursorName, FetchDirection direction, SqlExpression reference) { FetchInto(request, cursorName, direction, reference, null); }