Being the Force-Developer

Sunday, July 21, 2019

System.QueryException: Only variable references are allowed in dynamic SOQL/SOSL


You need to check if you have put a colon ':' in between the query string.

Code-snippet for a dynamic SOQL - 

String squery = 'SELECT Id, Name, recordTypeId FROM Account';
squery += ' where recordTypeId =\''+ devRecordTypeId+'\'';

Database.query(squery);
Posted by Hoda, Danish at 9:39 PM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

About Me

My photo
Hoda, Danish
View my complete profile

Blog Archive

  • ►  2024 (1)
    • ►  December (1)
  • ►  2021 (2)
    • ►  June (1)
    • ►  February (1)
  • ►  2020 (7)
    • ►  November (2)
    • ►  October (1)
    • ►  September (1)
    • ►  April (1)
    • ►  March (1)
    • ►  February (1)
  • ▼  2019 (17)
    • ►  December (1)
    • ►  November (2)
    • ►  October (1)
    • ►  September (2)
    • ►  August (3)
    • ▼  July (8)
      • PubSub event in Lightning Web Component  Desc...
      • Call Custom Labels in Apex: String getLabel = La...
      • Parent-Child Communication in LWC Sometimes...
      • Remove first and last characters of a String in A...
      • Embed a Lightning Web Compoent (LWC) inside anoth...
      • System.QueryException: Only variable references ...
      • System.runAs() Usages in test classes -  System....
      • MIXED_DML_OPERATION, DML operation on setup objec...
Picture Window theme. Powered by Blogger.