-3

is this correct query or not. this is batch class query but i did't get the values any one can tell me

Query:

'SELECT Id,RRD_No__c,Exist_in_Abacus__c,Status__c FROM Demand__c WHERE Status__c=:Open'

here status__c is picklist field.

2 Answers 2

3

I think you mean the following:

List<Demand__c> results = [SELECT Id, RRD_No__c, Exist_in_Abacus__c, Status__c FROM Demand__c where Status__c = 'Open'];

Or, if the status value is dynamic:

String statusValue = 'Open';
List<Demand__c> results = [SELECT Id, RRD_No__c, Exist_in_Abacus__c, Status__c FROM Demand__c where Status__c = :statusValue];

Or, if you want to use dynamic soql:

String statusValue = escapeSingleQuotes('Open');
String query = String.format('SELECT Id, RRD_No__c, Exist_in_Abacus__c, Status__c FROM Demand__c where Status__c = {0}', new List<String>{statusValue});
List<SObject> results = Database.query(query);
2

Below links will helps you...

Query :

String status = string.escapeSingleQuotes('Open');
Query = 'Select Id,RRD_No__c,Exist_in_Abacus_c,Status_c FROM Demand_c where Status_c=:status';

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm http://blog.shivanathd.com/2013/01/how-to-write-batch-class-in.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .