You need to sign in to do that
Don't have an account?
Admin User 10161
replace NULL value in SOQL query with empty string
Hi there,
In the following Apex code. I have created a string "query" in which I selected all the fields of a custom object.
Best regards,
In the following Apex code. I have created a string "query" in which I selected all the fields of a custom object.
for(String fieldName : fieldMap.keyset() ) { if(strFields == null || strFields == '') { strFields = fieldName; }else{ strFields = strFields + ' , ' + fieldName; } } query = 'SELECT ' + strFields + ' FROM ' + SobjectApiName + ' WHERE Id IN: buyIds'; for(APTIVN__NBuyer__c buy: Database.query(query)) { SelectedBuyerIDs.add(buy); }The problem is that for some fields for one particular row the value of this field is null. Is it possible to replace NULL value in an empty string on a SOQL query?
Best regards,
All Answers
You can use the below code that will work in all the scenarios:
Let me know if you have any further questions.
Thanks,
Abhishek Bansal.
Thank you for the answer.
The query still returns NULL value.
Let's consider for example the custom object 'Aptiv Buyer' with the following custom fields: id, name, email
Why do you want to do this? Is there any specific requirement?