Home → Active Query Builder → Programmatic modification of SQL queries → How to add FETCH FIRST to DB2 query
7.10. How to add FETCH FIRST to DB2 query
To get access to the FETCH FIRST clause of a DB2 query, you should use the DB2SubQuerySelectExpressionExtender object that could be obtained in the following way:
SQLSubQuerySelectExpression selexpr = queryBuilder1.ActiveSubQuery.ActiveUnionSubquery.QueryAST;
DB2SubQuerySelectExpressionExtender extender = (DB2SubQuerySelectExpressionExtender) selexpr.Extender;
Use one of the following code samples to add the LIMIT clause programmatically:
extender.FetchFirst = new SQLFetchFirst(queryBuilder1.SQLContext);
extender.FetchFirst.Count = new AstTokenNumber(queryBuilder1.SQLContext, "10");
queryBuilder1.ActiveSubQuery.ActiveUnionSubquery.NotifySQLUpdated();
