-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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.