+ Start a Discussion
j_panchalj_panchal 

Dummy column select in SOQL

Hello,

 

i have to questions :

 

1. Is there a way to select dummy column in SOQL like in SQL queries, like

     [select Name, Phone , 'testDummyColumn' from Contact]

 

2.  Is there a gender field in Contact sObject in SalesForce, and if not, from where we can select the gender of a contact. i have

     to display a list of contacts on VF page along with their gender.

 

Thanks in Advance. 

Rahul SharmaRahul Sharma

j_panchal, That Dummy column feature is not available in salesforce SOQL.

 

Also there is no such standard field in Contact Object for holding Gender. How ever you can create custom field to store and display Gender in visualforce page.

j_panchalj_panchal

Hi Rahul,

 

Thanks for the response.

i'll  use a custom field for gender.

 

just one more question - can we get column or field names that are used in a soql query, for example :

 

the soql query which i'm using is -

 

List<Account> lst = [select a.Name,a.Website, (SELECT c.FirstName, c.LastName,c.Title,c.Email, c.Phone, c.MailingState FROM a.Contacts c) FROM Account a].

 

then i need to get the labels of the fields which are used in the query, like in this case ('Name', 'Website' , 'FirstName', 'LastName', 'Title') and so on.

is there a way by which we can do this, tried using FieldSet in a Map but not getting the desired result.

 

Thanks.

Rahul SharmaRahul Sharma
 
If you want to use fieldset then you would need to built a Dynamic query in String so as to query fields present in fieldsets.
Other wise you can use inputFIeld tag to display Name as well as value in visualforce page.
Like:
<apex:inputFIeld value="{!objAccount.Name}" />