String table =
'Account'
;
Map<String, Schema.SObjectType> m = Schema.getGlobalDescribe() ;
Schema.SObjectType s = m.get(table) ;
Schema.DescribeSObjectResult r = s.getDescribe() ;
Map<String, Schema.SObjectField> fields = r.fields.getMap() ;
string soql =
''
;
for
(String fieldName : fields.keyset()) {
if
(soql !=
''
) {
soql +=
', '
;
}
soql += fieldName;
}
soql =
'SELECT '
+ soql +
' FROM '
+ table;
System.debug(soql);
List<Account> acs = Database.query(soql);
System.debug(acs.get(0));
0 comments:
Post a Comment