Crear un mapa de la siguiente manera:
Map<String, Schema.SObjectField> fldObjMap = schema.SObjectType.Account.fields.getMap();
List<Schema.SObjectField> fldObjMapValues = fldObjMap.values();
A continuación, puede iterar a través de fldObjMapValues para crear una cadena de consulta 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 es correcta, no hay manera de hacerlo directamente un SELECT *. Sin embargo, esta pequeña receta de código funcionará (bueno, no la he probado, pero creo que se ve bien). Es comprensible que Force.com quiera una arquitectura de múltiples inquilinos donde los recursos solo se aprovisionen según lo que se necesite explícitamente, no fácilmente al hacer SELECCIONAR * cuando generalmente solo se necesita un subconjunto de campos.
gracias por su respuesta. ¿Le importaría compartir un ejemplo para construir la consulta desde describeSObject? – Sukhhhh