Creare una mappa del genere:
Map<String, Schema.SObjectField> fldObjMap = schema.SObjectType.Account.fields.getMap();
List<Schema.SObjectField> fldObjMapValues = fldObjMap.values();
Poi si può scorrere fldObjMapValues per creare una query string SOQL:
String theQuery = 'SELECT ';
for(Schema.SObjectField s : fldObjMapValues)
{
String theLabel = s.getDescribe().getLabel(); // Perhaps store this in another map
String theName = s.getDescribe().getName();
String theType = s.getDescribe().getType(); // Perhaps store this in another map
// Continue building your dynamic query string
theQuery += theName + ',';
}
// Trim last comma
theQuery = theQuery.subString(0, theQuery.length() - 1);
// Finalize query string
theQuery += ' FROM Account WHERE ... AND ... LIMIT ...';
// Make your dynamic call
Account[] accounts = Database.query(theQuery);
superfell è corretta, non c'è modo di fare direttamente un SELECT *. Tuttavia, questa piccola ricetta del codice funzionerà (beh, non l'ho ancora testata, ma penso che sia ok). Comprensibilmente Force.com vuole un'architettura multi-tenant in cui le risorse vengano fornite come esplicitamente necessarie, non facilmente facendo SELECT * quando in genere solo un sottoinsieme di campi è effettivamente necessario.
grazie per la tua risposta. Ti dispiacerebbe condividere un esempio, per costruire la query da describeSObject. – Sukhhhh