function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
millburnmillburn 

select *

is there select *  from object in SOQL?  "*" is what I am looking for. I dont want to write out every column.

SuperfellSuperfell

No, you have to be explicit.

nnewbold-sfdcnnewbold-sfdc

As Simon said, you have to be explicit.  However, the workaround is to use a bit of dynamic apex to get all the fields you need.  You then pass those into a dynamic query.  Here's a class you can get started with for getting all fields for an object:

 

public class DynamicApexFieldLister 
{
      public static Map<String, Schema.SObjectField> getFieldsForSObject(SObjectType s)
      {
            Map<String, Schema.SObjectField> fieldMap = s.getDescribe().fields.getMap();
            
            return fieldMap;
      }
      
      public static Map<String, Schema.SObjectField> getFieldsForSObject(String s)
      {
            return getFieldsForSObject(Schema.getGlobalDescribe().get(s));
      }
      
      public static Map<String, Schema.SObjectField> getFieldsForSObject(SObject s)
      {
            return getFieldsForSObject(s.getSObjectType());
      } 
      
      public static Map<String, Schema.SObjectField> getUpdateableFieldsForSObject(SObjectType s)
      {
            Map<String, Schema.SObjectField> objectFields = getFieldsForSObject(s);
            
            Map<String, Schema.SObjectField> updateableFields = new Map<String, Schema.SObjectField>();
            
            for (String fieldName : objectFields.keySet())
            {
                  if (objectFields.get(fieldName).getDescribe().isUpdateable())
                        updateableFields.put(fieldName, objectFields.get(fieldName));
            }
            
            return updateableFields;
      }

      public static Map<String, Schema.SObjectField> getUpdateableFieldsForSObject(String s)
      {
            return getUpdateableFieldsForSObject(Schema.getGlobalDescribe().get(s));
      }
      
      public static Map<String, Schema.SObjectField> getUpdateableFieldsForSObject(SObject s)
      {
            return getUpdateableFieldsForSObject(s.getSObjectType());
      }
      
}
nnewbold-sfdcnnewbold-sfdc

Forgot to mention, be cautious when using the describes as there are limits around the number of describes you can make as well as the size of your query.