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
HarvinHarvin 

Dynamic Query Building in Apex

Please anybody can help regarding dynamic query building in Apex. For example I have a variable

String sSql = 'Select Id, Name from User';

User[] userObjs;
userObjs = [sSql];

Here in the above step it throwing synax error.  Please help me regarding this, how I can form dynamic query.


jf317820jf317820
apex doesn't currently support dynamic query building...you can only pass in comparison variables

String foo = 'Smith';

[select id from contact where lastname = :foo];



Message Edited by jf317820 on 04-04-2008 07:40 PM
GerhardNewman2GerhardNewman2
Unbelievable.  Really.  This is almost a must have.  Sigh.