public void parse ( final SelectStatement selectStatement ) { if ( ! lexerEngine . skipIfEqual ( SQLServerKeyword . OFFSET ) ) { return ; } int offsetValue = - 1 ; int offsetIndex = - 1 ; if ( lexerEngine . equalAny ( Literals . INT ) ) { offsetValue = Integer . parseInt ( lexerEngine . getCurrentToken ( ) . getLiterals ( ) ) ; } else if ( lexerEngine . equalAny ( Symbol . QUESTION ) ) { offsetIndex = selectStatement . getParametersIndex ( ) ; selectStatement . setParametersIndex ( selectStatement . getParametersIndex ( ) + 1 ) ; } else { throw new SQLParsingException ( lexerEngine ) ; } lexerEngine . nextToken ( ) ; Limit limit = new Limit ( ) ; if ( lexerEngine . skipIfEqual ( DefaultKeyword . FETCH ) ) { lexerEngine . nextToken ( ) ; int rowCountValue = - 1 ; int rowCountIndex = - 1 ; lexerEngine . nextToken ( ) ; if ( lexerEngine . equalAny ( Literals . INT ) ) { rowCountValue = Integer . parseInt ( lexerEngine . getCurrentToken ( ) . getLiterals ( ) ) ; } else if ( lexerEngine . equalAny ( Symbol . QUESTION ) ) { rowCountIndex = selectStatement . getParametersIndex ( ) ; selectStatement . setParametersIndex ( selectStatement . getParametersIndex ( ) + 1 ) ; } else { throw new SQLParsingException ( lexerEngine ) ; } lexerEngine . nextToken ( ) ; lexerEngine . nextToken ( ) ; limit . setRowCount ( new LimitValue ( rowCountValue , rowCountIndex , false ) ) ; limit . setOffset ( new LimitValue ( offsetValue , offsetIndex , true ) ) ; } else { limit . setOffset ( new LimitValue ( offsetValue , offsetIndex , true ) ) ; } selectStatement . setLimit ( limit ) ; }
Parse offset .