function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sunny SSunny S 

Unexpected Token 'global' Error

Hi friends, 
I am pretty new to Apex and coming across the following error 'Error: Compile Error: Unexpected token 'global'. at line 7 column 13' whlie trying to save a code to Delete records from a Custom Object called Bookings

I had tried my best but still failing to get over the error.
Can someone please help me in resolving it? I had copied this code from one of Salesforce KB's. 

Use Case: We are looking to call this Class from a scheduled Flow on specific days in order to delete records, as we are short of storage in one of the Sandboxes.

Additionally - how can i add more than ONE object within the same code? so that the deletion operation can work on both objects?

Thanks in advance and any help will be greatly appreciated.

Regards,
Sunny


************ Code Starts Here ********************

global class BookingBatchDeletion implements Database.Batchable<sObject>, Schedulable 
{   
    global BookingBatchDeletion()
    {
            global final String Query;    
    
            global BookingBatchDeletion (String q) {
            Query = q;
            
           //constuctor  
    }
                
    global Database.QueryLocator start(Database.BatchableContext bc)
    {
        // query to delete Booking records
       
        return Database.getQueryLocator(delete[SELECT id FROM Booking__c LIMIT 10000];);
    } 
    
    global void execute(SchedulableContext sc)  
    {   
        //execute the batch
        BookingBatchDeletion deleteCS = new
BookingBatchDeletion();
        ID batchprocessid = Database.executeBatch(deleteCS);
    }
    
    global void execute(Database.BatchableContext BC, list<Booking__c> scope)
    {     
      System.debug('## deleting '+scope.size()+' booking records');   
 
        //delete list of Booking records
            delete scope;   
            Database.emptyRecycleBin(scope);  
    }
        
    global void finish(Database.BatchableContext BC) 
    {                 
        //no post processing
       
     }
}

********* Code Ends Here ***************