protected override void ExecuteStatement(ExecutionContext context) { if (!context.Request.Context.CursorExists(CursorName)) { throw new StatementException(String.Format("The cursor '{0}' was not found in the current context.", CursorName)); } var cursor = context.Request.Context.FindCursor(CursorName); if (cursor == null) { throw new StatementException(String.Format("The cursor '{0}' was not found in the current context.", CursorName)); } if (cursor.Status == CursorStatus.Closed) { throw new StatementException(String.Format("The cursor '{0}' was already closed.", CursorName)); } int offset = -1; if (OffsetExpression != null) { offset = OffsetExpression.EvaluateToConstant(context.Request, null); } var fetchContext = new FetchContext(context.Request, Direction, ReferenceExpression); if (Direction == FetchDirection.Absolute || Direction == FetchDirection.Relative) { fetchContext.Offset = offset; } cursor.FetchInto(fetchContext); }
public void Accept(TSqlFragmentVisitor visitor) { visitor.ExplicitVisit(this); OffsetExpression?.Accept(visitor); FetchExpression?.Accept(visitor); }
public void ToString(StringBuilder buf, int indent, int longestClauseLength) { buf.Append(' ', indent); buf.Append("OFFSET"); buf.Append(' ', longestClauseLength - "OFFSET".Length + 1); OffsetExpression.ToString(buf, indent); buf.Append(" ROWS FETCH NEXT "); FetchExpression.ToString(buf, indent); buf.Append(" ROWS ONLY\r\n"); }
public void Given_offset_is_Zero_When_comparing_same_offset_should_not_take_into_account_the_numeric_sign(NumericSign sign) { // Arrange OffsetExpression zero = OffsetExpression.Zero; OffsetExpression zeroWithNegativeSign = new(sign, (uint)zero.Hours, (uint)zero.Minutes); // Act bool actual = zero == zeroWithNegativeSign; // Assert actual.Should().BeTrue(); }