You need to sign in to do that
Don't have an account?
Simon Baird
Adding Limit to Database.query
Hi there,
I need to limit the number of records returned from this query. When i use the LIMIT clause before the last semi colon I get an error "mismatched input expecting semi colon". Any thoughts guys?
public List<Event> start(){
String query = 'Select Id,IsRecurrence,Event_Processed__c,Allowance_Type__c,Session_Coverage_Type__c,Session_Type__c,Message_from_Office_to_Podiatrist__c,Additional_Message_From_Office_to_Pod__c,Subject,OwnerId,owner.Name,WhatId,startdatetime,of_Session_Sharing_Day__c,Wing_1__c,Wing_2__c,Wing_3__c,Wing_4__c,Wing_5__c,Wing_6__c,Wing_7__c,Wing_8__c,Wing_9__c,Rooms_1__c,Rooms_2__c,Rooms_3__c,Rooms_4__c FROM Event WHERE Do_Not_Create_Session__c = false AND IsRecurrence = false AND Event_Processed__c = false AND RecordType.Name IN :lstEventRecordTypes AND What.RecordType.Name IN :lstAccountRecordTypes AND Owner.Title IN :lstOwnerTitles AND ActivityDate = NEXT_N_DAYS :'+ lastNumberOfDays ;
return Database.query(query);
I need to limit the number of records returned from this query. When i use the LIMIT clause before the last semi colon I get an error "mismatched input expecting semi colon". Any thoughts guys?
public List<Event> start(){
String query = 'Select Id,IsRecurrence,Event_Processed__c,Allowance_Type__c,Session_Coverage_Type__c,Session_Type__c,Message_from_Office_to_Podiatrist__c,Additional_Message_From_Office_to_Pod__c,Subject,OwnerId,owner.Name,WhatId,startdatetime,of_Session_Sharing_Day__c,Wing_1__c,Wing_2__c,Wing_3__c,Wing_4__c,Wing_5__c,Wing_6__c,Wing_7__c,Wing_8__c,Wing_9__c,Rooms_1__c,Rooms_2__c,Rooms_3__c,Rooms_4__c FROM Event WHERE Do_Not_Create_Session__c = false AND IsRecurrence = false AND Event_Processed__c = false AND RecordType.Name IN :lstEventRecordTypes AND What.RecordType.Name IN :lstAccountRecordTypes AND Owner.Title IN :lstOwnerTitles AND ActivityDate = NEXT_N_DAYS :'+ lastNumberOfDays ;
return Database.query(query);
Please check the below code:
Please do let me know if it helps you.
Regards,
Mahesh
All Answers
Please check the below code:
Please do let me know if it helps you.
Regards,
Mahesh