You need to sign in to do that
Don't have an account?
Getting an error in a batch class
I have written a below batch class and getting an errror. the error is "Compile Error: line breaks not allowed in string literals " .It refers to assigning the query result to string q . Other code is written but i dont think there is any issue. I am able to spot the error while it is standard way to make a query and store it in a string. Please help.
global class batchClassCloseProbability1 implements Database.batchable<sObject>{
/*#################Variable Declaration#################################*/
global final String q;
Integer prbv = 0;
Integer prbb = 0;
Decimal i7=0;
Decimal i8=0;
Decimal i9=0;
global batchClassCloseProbability1()
{
q = 'Select id, name,StageVFlag__c, StageBFlag__c,StageAFlag__c,StageEFlag__c,StageCFlag__c,StageGFlag__c,ownerid, status__c, type, amount, AM_Opportunity_ID__c,Closed_Probablity_Stage_V__c,Closed_Probablity_Stage_A__c' ;
}
global database.querylocator start(Database.BatchableContext bc) {
return Database.getQueryLocator(query);
}
Thanks
~Alok
Hi alok29nov,
Your query string q in incomplete. so, try executing it with completed query in string .
hey just missed some part of query to post here.. it is like
q = 'Select id, name,StageVFlag__c, StageBFlag__c,StageAFlag__c,StageEFlag__c,StageCFlag__c,StageGFlag__c,ownerid, status__c, type, amount, AM_Opportunity_ID__c,Closed_Probablity_Stage_V__c,Closed_Probablity_Stage_A__c from Opportunity'
try it in system log
Check if the query is proper and ensure its the exact line number of error.
Hi Rahul,
there is no error is query. When i am trying to assign it to 'q' then im getting a error because query has been done in '------' instead of [...]. but this is the standard way when we query in a batch class. the query is workinf fine when i i give it in below start method.
global database.querylocator start(Database.BatchableContext bc) {
return Database.getQueryLocator(query);
}
here [[ Database.getQueryLocator(the whole query)]] if i write the same query instead of passing it in string 'q' i get no error.
Hi Rahul,
Actually, you just have a carriage return character in your line code when you try to assign your query to your string.