Use of query build datasource in job and range

Use of query build datasource in job and range


 static void SelectCustomerJobQuery(Args _args)  
 {  
 Query query;  
 QueryBuildDataSource queryBuildDatasource;  
 QueryBuildRange queryBuildRange;  
 QueryRun queryRun;  
 Counter recordsFound;  
 custTable cust;  
 ;  
 query = new Query();  
 queryBuildDataSource =query.addDataSource(tableNum(custTable));  
 queryBuildDataSource.addSortField(fieldNum(custTable,Name));  
 queryBuildRange =queryBuildDataSource.addRange(fieldNum(custTable,city));  
 queryRun = new QueryRun(query);  
 /*while (queryRun.next())  
 {  
 cust= queryRun.get(tablenum(custTable));  
 print cust.Name;  
 }*/  
 if (queryRun.prompt())  
 {  
 while (queryRun.next())  
 {  
 recordsFound++;  
 cust= queryRun.get(tablenum(custTable));  
 print cust.Name;  
 }  
 }  
 info(strFmt("Customers found: %1", recordsFound));  
 pause;  
 }