HomeActive Query Builder - Query analysis and modificationProgrammatic modification of SQL queriesHow to add FETCH FIRST to DB2 query

2.11. 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();

This page was: Helpful | Not Helpful