+ Start a Discussion
Khemais MenzliKhemais Menzli 

Restrinction using some SQL statement in production env

Hi everyone,
Today I faced a problem using SQL queries in production environment to update
The query is the following :
PDATE Contact SET Converted_Month__c = date(year(CreatedDate),month(CreatedDate),1) WHERE ID = 'XYZ'
I tried to execute query above using the SQL panel in Develop tools. BUT I get this message : The query has to start with 'FIND' or 'SELECT'.
One more question, the statement Select * seems blocked by SFDC, is there any technical restriction behind it? if yes, is there a workaroud or a solution to select all fields in a given table?
Your helps is appreciate 
Amit GhadageAmit Ghadage
Salesforce doesn't support SQL.
It supports SOQL & SOSL .

Select * is not allowed in salesforce you have to select each field you need.

read more about soql and sosl in  Force.com SOQL and SOSL Reference.
Khemais MenzliKhemais Menzli
@Amit Ghadage : thank you for your reply,
Thus after a quick look at the link above, I can say that there is no UPDATE feature for SOQL.
How can I update my Objects on production env? should I do through Apex? 
Amit GhadageAmit Ghadage
Yes, you have to use Apex.
Contact c = [select Converted_Month__c, createddate from Contact where Id = 'XYZ']; 
c.Converted_Month__c = date.newInstance(createddate.year(), CreatedDate.month(),createddate.day()); 
update c;

however it is advised to bulkify your code. if you are using this in trigger.