You need to sign in to do that
Don't have an account?
asadim
SOQL: Select everything?
Hi,
Is there a way to select everything in SOQL like "SELECT *" in SQL? I have looked at the SOQL manual about SELECT statements but it didn't tell if I can do this or not.
Thanks.
No, you can't do this in SOQL, but you can generate dynamically your SOQL query with the list of all fields (Id, Name, etc...).
To identify all fields, you can use the API call describeSObjects()
All Answers
No, you can't do this in SOQL, but you can generate dynamically your SOQL query with the list of all fields (Id, Name, etc...).
To identify all fields, you can use the API call describeSObjects()
Hi,
I did a write up on how this is accomplished for people who happen to stumble upon this topic. It can be found here,
http://johncasimiro.posterous.com/mimic-a-sql-select-statement-in-soql-using-ap
SELECT * FROM table_name
becomes
String table = 'table_name';
String query_string = 'SELECT ';
List<String> table_list = new List<String>();
table_list.add(table);
Set<String> table_rows = schema.describeSObjects(table_list)[0].fields.getMap().keyset();
for(String row : table_rows){
query_string += row + ',';
}
query_string = query_string.removeEnd(','); //remove trailing comma
query_string += ' FROM ' + table;
Database.query(query_string);
This works
SELECT FIELDS(ALL) FROM Account LIMIT 200
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_fields.htm