System.QueryException: unexpected token: ''Dynamic soql : Unexpected token '{'Dynamic soql : unexpected token: <Dynamic SOQL :System.QueryException: unexpected token: <Dynamic Field Query error from non sys admin users: unexpected token: 'from': ()Unexpected token '(' error batch apexunexpected token: IN in dynamic soqlunexpected token found -null in dynamic query when i ran my test classDynamic SOQL Query Exception: : unexpected token: '&lt;EOF&gt;'Unexpected Token WhereSystem.QueryException unexpected token

LightGBM results differently depending on the order of the data

Was there ever a Kickstart that took advantage of 68020+ instructions that would work on an A2000?

What does a yield inside a yield do?

I may be a fraud

Is induction neccessary for proving that every injective mapping of a finite set into itself is a mapping onto itself?

How to explain the behaviour of TreeForm?

In Avengers 1, why does Thanos need Loki?

Why is Arya visibly scared in the library in S8E3?

Did we get closer to another plane than we were supposed to, or was the pilot just protecting our delicate sensibilities?

Enumerate Derangements

How do I tell my manager that his code review comment is wrong?

Is one octave above tonic also considered as tonic?

For a benzene shown in a skeletal structure, what does a substituent to the center of the ring mean?

Would "lab meat" be able to feed a much larger global population

What is a "listed natural gas appliance"?

Why do money exchangers give different rates to different bills?

If Earth is tilted, why is Polaris always above the same spot?

Selecting a secure PIN for building access

Moving the subject of the sentence into a dangling participle

Is it cheaper to drop cargo than to land it?

Do I have to make someone coauthor if he/she solves a problem in StackExchange, asked by myself, which is later used in my paper?

My ID is expired, can I fly to the Bahamas with my passport?

How can I close a gap between my fence and my neighbor's that's on his side of the property line?

What is it called when you multiply something eight times?



System.QueryException: unexpected token: ''


Dynamic soql : Unexpected token '{'Dynamic soql : unexpected token: <Dynamic SOQL :System.QueryException: unexpected token: <Dynamic Field Query error from non sys admin users: unexpected token: 'from': ()Unexpected token '(' error batch apexunexpected token: IN in dynamic soqlunexpected token found -null in dynamic query when i ran my test classDynamic SOQL Query Exception: : unexpected token: '&lt;EOF&gt;'Unexpected Token WhereSystem.QueryException unexpected token






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have built dynamic query.but receiving below exception



 01:16:56.0 (15683245)|USER_DEBUG|[335]|DEBUG|SetOfParentId--->
01:16:56.0 (15756602)|USER_DEBUG|[336]|DEBUG|Set1--->
01:16:56.0 (15788512)|USER_DEBUG|[337]|DEBUG|SetOfGSSDuplicateCase--->
01:16:56.0 (15816995)|USER_DEBUG|[338]|DEBUG|Set11--->
01:16:56.0 (15864603)|USER_DEBUG|[404]|DEBUG|soqlString---->select id,Vmstar_Id__c,GSS_Duplicate_Case__c,Duplicate_Of_Case__c,GSS_Build_Number__c,
GSS_Product_Version__c from Case Where
01:16:56.0 (16227040)|EXCEPTION_THROWN|[405]|System.QueryException:
unexpected token: '<EOF>'
01:16:56.0 (16357113)|FATAL_ERROR|System.QueryException:
unexpected token: '<EOF>'


**Dynamic query:**


string soqlString = 'select id,Vmstar_Id__c,GSS_Duplicate_Case__c,Duplicate_Of_Case__c,GSS_Build_Number__c,GSS_Product_Version__c from Case';
soqlString += ' Where ';
boolean whereClauseAdded = false;
if(SetOfParentId.size()>0)
whereClauseAdded = true;
soqlString += ' Vmstar_Id__c IN : SetOfParentId';

if(SetOfGSSDuplicateCase.size()>0)
if(whereClauseAdded)
soqlString += ' OR Vmstar_Id__c IN : SetOfGSSDuplicateCase';
else
soqlString += ' Vmstar_Id__c IN : SetOfGSSDuplicateCase';

whereClauseAdded = true;

if(Set1.size()>0 )

if(whereClauseAdded)
soqlString += ' OR GSS_Build_Number__c IN : Set1';
else
soqlString += ' GSS_Build_Number__c IN : Set1';

whereClauseAdded = true;



if(Set11.size()>0)

if(whereClauseAdded)
soqlString += ' OR GSS_Product_Version__c IN : Set11';
else
soqlString += ' GSS_Product_Version__c IN : Set11';

whereClauseAdded = true;


system.debug('soqlString---->'+soqlString);
List<Case> requiredCases = Database.query(soqlString);


if(requiredCases.size()>0)

for(Case et : requiredCases)

if(et.id!=null)
MapOfParentId.put(et.Vmstar_Id__c,et.id);
if(et.GSS_Duplicate_Case__c!=null)
MapOfGSSDuplicateCase.put(et.VMstar_Id__c,et.GSS_Duplicate_Case__c);
if(et.Duplicate_Of_Case__c!=null)
MapOfDuplicateOfCase.put(et.VMstar_Id__c,et.Duplicate_Of_Case__c);
if(et.GSS_Build_Number__c!=null)
Set3.add(et.GSS_Build_Number__c);
if(et.GSS_Product_Version__c!=null)
Set33.add(et.GSS_Build_Number__c);













share|improve this question






























    0















    I have built dynamic query.but receiving below exception



     01:16:56.0 (15683245)|USER_DEBUG|[335]|DEBUG|SetOfParentId--->
    01:16:56.0 (15756602)|USER_DEBUG|[336]|DEBUG|Set1--->
    01:16:56.0 (15788512)|USER_DEBUG|[337]|DEBUG|SetOfGSSDuplicateCase--->
    01:16:56.0 (15816995)|USER_DEBUG|[338]|DEBUG|Set11--->
    01:16:56.0 (15864603)|USER_DEBUG|[404]|DEBUG|soqlString---->select id,Vmstar_Id__c,GSS_Duplicate_Case__c,Duplicate_Of_Case__c,GSS_Build_Number__c,
    GSS_Product_Version__c from Case Where
    01:16:56.0 (16227040)|EXCEPTION_THROWN|[405]|System.QueryException:
    unexpected token: '<EOF>'
    01:16:56.0 (16357113)|FATAL_ERROR|System.QueryException:
    unexpected token: '<EOF>'


    **Dynamic query:**


    string soqlString = 'select id,Vmstar_Id__c,GSS_Duplicate_Case__c,Duplicate_Of_Case__c,GSS_Build_Number__c,GSS_Product_Version__c from Case';
    soqlString += ' Where ';
    boolean whereClauseAdded = false;
    if(SetOfParentId.size()>0)
    whereClauseAdded = true;
    soqlString += ' Vmstar_Id__c IN : SetOfParentId';

    if(SetOfGSSDuplicateCase.size()>0)
    if(whereClauseAdded)
    soqlString += ' OR Vmstar_Id__c IN : SetOfGSSDuplicateCase';
    else
    soqlString += ' Vmstar_Id__c IN : SetOfGSSDuplicateCase';

    whereClauseAdded = true;

    if(Set1.size()>0 )

    if(whereClauseAdded)
    soqlString += ' OR GSS_Build_Number__c IN : Set1';
    else
    soqlString += ' GSS_Build_Number__c IN : Set1';

    whereClauseAdded = true;



    if(Set11.size()>0)

    if(whereClauseAdded)
    soqlString += ' OR GSS_Product_Version__c IN : Set11';
    else
    soqlString += ' GSS_Product_Version__c IN : Set11';

    whereClauseAdded = true;


    system.debug('soqlString---->'+soqlString);
    List<Case> requiredCases = Database.query(soqlString);


    if(requiredCases.size()>0)

    for(Case et : requiredCases)

    if(et.id!=null)
    MapOfParentId.put(et.Vmstar_Id__c,et.id);
    if(et.GSS_Duplicate_Case__c!=null)
    MapOfGSSDuplicateCase.put(et.VMstar_Id__c,et.GSS_Duplicate_Case__c);
    if(et.Duplicate_Of_Case__c!=null)
    MapOfDuplicateOfCase.put(et.VMstar_Id__c,et.Duplicate_Of_Case__c);
    if(et.GSS_Build_Number__c!=null)
    Set3.add(et.GSS_Build_Number__c);
    if(et.GSS_Product_Version__c!=null)
    Set33.add(et.GSS_Build_Number__c);













    share|improve this question


























      0












      0








      0








      I have built dynamic query.but receiving below exception



       01:16:56.0 (15683245)|USER_DEBUG|[335]|DEBUG|SetOfParentId--->
      01:16:56.0 (15756602)|USER_DEBUG|[336]|DEBUG|Set1--->
      01:16:56.0 (15788512)|USER_DEBUG|[337]|DEBUG|SetOfGSSDuplicateCase--->
      01:16:56.0 (15816995)|USER_DEBUG|[338]|DEBUG|Set11--->
      01:16:56.0 (15864603)|USER_DEBUG|[404]|DEBUG|soqlString---->select id,Vmstar_Id__c,GSS_Duplicate_Case__c,Duplicate_Of_Case__c,GSS_Build_Number__c,
      GSS_Product_Version__c from Case Where
      01:16:56.0 (16227040)|EXCEPTION_THROWN|[405]|System.QueryException:
      unexpected token: '<EOF>'
      01:16:56.0 (16357113)|FATAL_ERROR|System.QueryException:
      unexpected token: '<EOF>'


      **Dynamic query:**


      string soqlString = 'select id,Vmstar_Id__c,GSS_Duplicate_Case__c,Duplicate_Of_Case__c,GSS_Build_Number__c,GSS_Product_Version__c from Case';
      soqlString += ' Where ';
      boolean whereClauseAdded = false;
      if(SetOfParentId.size()>0)
      whereClauseAdded = true;
      soqlString += ' Vmstar_Id__c IN : SetOfParentId';

      if(SetOfGSSDuplicateCase.size()>0)
      if(whereClauseAdded)
      soqlString += ' OR Vmstar_Id__c IN : SetOfGSSDuplicateCase';
      else
      soqlString += ' Vmstar_Id__c IN : SetOfGSSDuplicateCase';

      whereClauseAdded = true;

      if(Set1.size()>0 )

      if(whereClauseAdded)
      soqlString += ' OR GSS_Build_Number__c IN : Set1';
      else
      soqlString += ' GSS_Build_Number__c IN : Set1';

      whereClauseAdded = true;



      if(Set11.size()>0)

      if(whereClauseAdded)
      soqlString += ' OR GSS_Product_Version__c IN : Set11';
      else
      soqlString += ' GSS_Product_Version__c IN : Set11';

      whereClauseAdded = true;


      system.debug('soqlString---->'+soqlString);
      List<Case> requiredCases = Database.query(soqlString);


      if(requiredCases.size()>0)

      for(Case et : requiredCases)

      if(et.id!=null)
      MapOfParentId.put(et.Vmstar_Id__c,et.id);
      if(et.GSS_Duplicate_Case__c!=null)
      MapOfGSSDuplicateCase.put(et.VMstar_Id__c,et.GSS_Duplicate_Case__c);
      if(et.Duplicate_Of_Case__c!=null)
      MapOfDuplicateOfCase.put(et.VMstar_Id__c,et.Duplicate_Of_Case__c);
      if(et.GSS_Build_Number__c!=null)
      Set3.add(et.GSS_Build_Number__c);
      if(et.GSS_Product_Version__c!=null)
      Set33.add(et.GSS_Build_Number__c);













      share|improve this question
















      I have built dynamic query.but receiving below exception



       01:16:56.0 (15683245)|USER_DEBUG|[335]|DEBUG|SetOfParentId--->
      01:16:56.0 (15756602)|USER_DEBUG|[336]|DEBUG|Set1--->
      01:16:56.0 (15788512)|USER_DEBUG|[337]|DEBUG|SetOfGSSDuplicateCase--->
      01:16:56.0 (15816995)|USER_DEBUG|[338]|DEBUG|Set11--->
      01:16:56.0 (15864603)|USER_DEBUG|[404]|DEBUG|soqlString---->select id,Vmstar_Id__c,GSS_Duplicate_Case__c,Duplicate_Of_Case__c,GSS_Build_Number__c,
      GSS_Product_Version__c from Case Where
      01:16:56.0 (16227040)|EXCEPTION_THROWN|[405]|System.QueryException:
      unexpected token: '<EOF>'
      01:16:56.0 (16357113)|FATAL_ERROR|System.QueryException:
      unexpected token: '<EOF>'


      **Dynamic query:**


      string soqlString = 'select id,Vmstar_Id__c,GSS_Duplicate_Case__c,Duplicate_Of_Case__c,GSS_Build_Number__c,GSS_Product_Version__c from Case';
      soqlString += ' Where ';
      boolean whereClauseAdded = false;
      if(SetOfParentId.size()>0)
      whereClauseAdded = true;
      soqlString += ' Vmstar_Id__c IN : SetOfParentId';

      if(SetOfGSSDuplicateCase.size()>0)
      if(whereClauseAdded)
      soqlString += ' OR Vmstar_Id__c IN : SetOfGSSDuplicateCase';
      else
      soqlString += ' Vmstar_Id__c IN : SetOfGSSDuplicateCase';

      whereClauseAdded = true;

      if(Set1.size()>0 )

      if(whereClauseAdded)
      soqlString += ' OR GSS_Build_Number__c IN : Set1';
      else
      soqlString += ' GSS_Build_Number__c IN : Set1';

      whereClauseAdded = true;



      if(Set11.size()>0)

      if(whereClauseAdded)
      soqlString += ' OR GSS_Product_Version__c IN : Set11';
      else
      soqlString += ' GSS_Product_Version__c IN : Set11';

      whereClauseAdded = true;


      system.debug('soqlString---->'+soqlString);
      List<Case> requiredCases = Database.query(soqlString);


      if(requiredCases.size()>0)

      for(Case et : requiredCases)

      if(et.id!=null)
      MapOfParentId.put(et.Vmstar_Id__c,et.id);
      if(et.GSS_Duplicate_Case__c!=null)
      MapOfGSSDuplicateCase.put(et.VMstar_Id__c,et.GSS_Duplicate_Case__c);
      if(et.Duplicate_Of_Case__c!=null)
      MapOfDuplicateOfCase.put(et.VMstar_Id__c,et.Duplicate_Of_Case__c);
      if(et.GSS_Build_Number__c!=null)
      Set3.add(et.GSS_Build_Number__c);
      if(et.GSS_Product_Version__c!=null)
      Set33.add(et.GSS_Build_Number__c);










      dynamic-soql






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 23 at 8:28









      Manjot Singh

      2,370724




      2,370724










      asked Apr 23 at 8:20









      SFDC FANSFDC FAN

      1,5401134




      1,5401134




















          2 Answers
          2






          active

          oldest

          votes


















          3














          You need add 'WHERE' to your conditions.
          Because query is ending with




          ... where




          and nothing after it, the result is error.



          soqlString += ' Where ';


          is always added, even if nothing is after it.






          share|improve this answer


















          • 2





            +1 In addition, the space in : Set11 should also cause errors.

            – sfdcfox
            Apr 23 at 8:29


















          0














          You are getting this issue because you are adding the WHERE clause with all of your sets size equal to 0. Hence your SOQL query is left with WHERE clause without any conditions which leaves your SOQL query incomplete and hence you are getting System.QueryException.



          You will have to add the WHERE clause only when one of your set has any value in it. So, your code should be something like below



          Also, make sure you don't have space between colon and the set variable name



          string soqlString = 'select id,Vmstar_Id__c,GSS_Duplicate_Case__c,Duplicate_Of_Case__c,GSS_Build_Number__c,GSS_Product_Version__c from Case';
          if(SetOfParentId.size()>0 || SetOfGSSDuplicateCase.size()>0 || Set1.size()>0 || Set11.size()>0)
          soqlString += ' Where '

          boolean whereClauseAdded = false;
          if(SetOfParentId.size()>0)
          whereClauseAdded = true;
          soqlString += ' Vmstar_Id__c IN :SetOfParentId';

          if(SetOfGSSDuplicateCase.size()>0)
          if(whereClauseAdded)
          soqlString += ' OR Vmstar_Id__c IN :SetOfGSSDuplicateCase';
          else
          soqlString += ' Vmstar_Id__c IN :SetOfGSSDuplicateCase';

          whereClauseAdded = true;


          if(Set1.size()>0)
          if(whereClauseAdded)
          soqlString += ' OR Vmstar_Id__c IN :Set1';
          else
          soqlString += ' Vmstar_Id__c IN :Set1';

          whereClauseAdded = true;


          if(Set11.size()>0)
          if(whereClauseAdded)
          soqlString += ' OR Vmstar_Id__c IN :Set11';
          else
          soqlString += ' Vmstar_Id__c IN :Set11';

          whereClauseAdded = true;


          //query the records using Database.query method
          List<Case> requiredCases = Database.query(soqlString);

          for(Case et : requiredCases)
          if(et.id!=null)
          MapOfParentId.put(et.Vmstar_Id__c,et.id);

          if(et.GSS_Duplicate_Case__c!=null)
          MapOfGSSDuplicateCase.put(et.VMstar_Id__c,et.GSS_Duplicate_Case__c);

          if(et.Duplicate_Of_Case__c!=null)
          MapOfDuplicateOfCase.put(et.VMstar_Id__c,et.Duplicate_Of_Case__c);

          if(et.GSS_Build_Number__c!=null)
          Set3.add(et.GSS_Build_Number__c);

          if(et.GSS_Product_Version__c!=null)
          Set33.add(et.GSS_Build_Number__c);







          share|improve this answer

























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "459"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f258748%2fsystem-queryexception-unexpected-token-eof%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            You need add 'WHERE' to your conditions.
            Because query is ending with




            ... where




            and nothing after it, the result is error.



            soqlString += ' Where ';


            is always added, even if nothing is after it.






            share|improve this answer


















            • 2





              +1 In addition, the space in : Set11 should also cause errors.

              – sfdcfox
              Apr 23 at 8:29















            3














            You need add 'WHERE' to your conditions.
            Because query is ending with




            ... where




            and nothing after it, the result is error.



            soqlString += ' Where ';


            is always added, even if nothing is after it.






            share|improve this answer


















            • 2





              +1 In addition, the space in : Set11 should also cause errors.

              – sfdcfox
              Apr 23 at 8:29













            3












            3








            3







            You need add 'WHERE' to your conditions.
            Because query is ending with




            ... where




            and nothing after it, the result is error.



            soqlString += ' Where ';


            is always added, even if nothing is after it.






            share|improve this answer













            You need add 'WHERE' to your conditions.
            Because query is ending with




            ... where




            and nothing after it, the result is error.



            soqlString += ' Where ';


            is always added, even if nothing is after it.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Apr 23 at 8:26









            user1974566user1974566

            1,213417




            1,213417







            • 2





              +1 In addition, the space in : Set11 should also cause errors.

              – sfdcfox
              Apr 23 at 8:29












            • 2





              +1 In addition, the space in : Set11 should also cause errors.

              – sfdcfox
              Apr 23 at 8:29







            2




            2





            +1 In addition, the space in : Set11 should also cause errors.

            – sfdcfox
            Apr 23 at 8:29





            +1 In addition, the space in : Set11 should also cause errors.

            – sfdcfox
            Apr 23 at 8:29













            0














            You are getting this issue because you are adding the WHERE clause with all of your sets size equal to 0. Hence your SOQL query is left with WHERE clause without any conditions which leaves your SOQL query incomplete and hence you are getting System.QueryException.



            You will have to add the WHERE clause only when one of your set has any value in it. So, your code should be something like below



            Also, make sure you don't have space between colon and the set variable name



            string soqlString = 'select id,Vmstar_Id__c,GSS_Duplicate_Case__c,Duplicate_Of_Case__c,GSS_Build_Number__c,GSS_Product_Version__c from Case';
            if(SetOfParentId.size()>0 || SetOfGSSDuplicateCase.size()>0 || Set1.size()>0 || Set11.size()>0)
            soqlString += ' Where '

            boolean whereClauseAdded = false;
            if(SetOfParentId.size()>0)
            whereClauseAdded = true;
            soqlString += ' Vmstar_Id__c IN :SetOfParentId';

            if(SetOfGSSDuplicateCase.size()>0)
            if(whereClauseAdded)
            soqlString += ' OR Vmstar_Id__c IN :SetOfGSSDuplicateCase';
            else
            soqlString += ' Vmstar_Id__c IN :SetOfGSSDuplicateCase';

            whereClauseAdded = true;


            if(Set1.size()>0)
            if(whereClauseAdded)
            soqlString += ' OR Vmstar_Id__c IN :Set1';
            else
            soqlString += ' Vmstar_Id__c IN :Set1';

            whereClauseAdded = true;


            if(Set11.size()>0)
            if(whereClauseAdded)
            soqlString += ' OR Vmstar_Id__c IN :Set11';
            else
            soqlString += ' Vmstar_Id__c IN :Set11';

            whereClauseAdded = true;


            //query the records using Database.query method
            List<Case> requiredCases = Database.query(soqlString);

            for(Case et : requiredCases)
            if(et.id!=null)
            MapOfParentId.put(et.Vmstar_Id__c,et.id);

            if(et.GSS_Duplicate_Case__c!=null)
            MapOfGSSDuplicateCase.put(et.VMstar_Id__c,et.GSS_Duplicate_Case__c);

            if(et.Duplicate_Of_Case__c!=null)
            MapOfDuplicateOfCase.put(et.VMstar_Id__c,et.Duplicate_Of_Case__c);

            if(et.GSS_Build_Number__c!=null)
            Set3.add(et.GSS_Build_Number__c);

            if(et.GSS_Product_Version__c!=null)
            Set33.add(et.GSS_Build_Number__c);







            share|improve this answer





























              0














              You are getting this issue because you are adding the WHERE clause with all of your sets size equal to 0. Hence your SOQL query is left with WHERE clause without any conditions which leaves your SOQL query incomplete and hence you are getting System.QueryException.



              You will have to add the WHERE clause only when one of your set has any value in it. So, your code should be something like below



              Also, make sure you don't have space between colon and the set variable name



              string soqlString = 'select id,Vmstar_Id__c,GSS_Duplicate_Case__c,Duplicate_Of_Case__c,GSS_Build_Number__c,GSS_Product_Version__c from Case';
              if(SetOfParentId.size()>0 || SetOfGSSDuplicateCase.size()>0 || Set1.size()>0 || Set11.size()>0)
              soqlString += ' Where '

              boolean whereClauseAdded = false;
              if(SetOfParentId.size()>0)
              whereClauseAdded = true;
              soqlString += ' Vmstar_Id__c IN :SetOfParentId';

              if(SetOfGSSDuplicateCase.size()>0)
              if(whereClauseAdded)
              soqlString += ' OR Vmstar_Id__c IN :SetOfGSSDuplicateCase';
              else
              soqlString += ' Vmstar_Id__c IN :SetOfGSSDuplicateCase';

              whereClauseAdded = true;


              if(Set1.size()>0)
              if(whereClauseAdded)
              soqlString += ' OR Vmstar_Id__c IN :Set1';
              else
              soqlString += ' Vmstar_Id__c IN :Set1';

              whereClauseAdded = true;


              if(Set11.size()>0)
              if(whereClauseAdded)
              soqlString += ' OR Vmstar_Id__c IN :Set11';
              else
              soqlString += ' Vmstar_Id__c IN :Set11';

              whereClauseAdded = true;


              //query the records using Database.query method
              List<Case> requiredCases = Database.query(soqlString);

              for(Case et : requiredCases)
              if(et.id!=null)
              MapOfParentId.put(et.Vmstar_Id__c,et.id);

              if(et.GSS_Duplicate_Case__c!=null)
              MapOfGSSDuplicateCase.put(et.VMstar_Id__c,et.GSS_Duplicate_Case__c);

              if(et.Duplicate_Of_Case__c!=null)
              MapOfDuplicateOfCase.put(et.VMstar_Id__c,et.Duplicate_Of_Case__c);

              if(et.GSS_Build_Number__c!=null)
              Set3.add(et.GSS_Build_Number__c);

              if(et.GSS_Product_Version__c!=null)
              Set33.add(et.GSS_Build_Number__c);







              share|improve this answer



























                0












                0








                0







                You are getting this issue because you are adding the WHERE clause with all of your sets size equal to 0. Hence your SOQL query is left with WHERE clause without any conditions which leaves your SOQL query incomplete and hence you are getting System.QueryException.



                You will have to add the WHERE clause only when one of your set has any value in it. So, your code should be something like below



                Also, make sure you don't have space between colon and the set variable name



                string soqlString = 'select id,Vmstar_Id__c,GSS_Duplicate_Case__c,Duplicate_Of_Case__c,GSS_Build_Number__c,GSS_Product_Version__c from Case';
                if(SetOfParentId.size()>0 || SetOfGSSDuplicateCase.size()>0 || Set1.size()>0 || Set11.size()>0)
                soqlString += ' Where '

                boolean whereClauseAdded = false;
                if(SetOfParentId.size()>0)
                whereClauseAdded = true;
                soqlString += ' Vmstar_Id__c IN :SetOfParentId';

                if(SetOfGSSDuplicateCase.size()>0)
                if(whereClauseAdded)
                soqlString += ' OR Vmstar_Id__c IN :SetOfGSSDuplicateCase';
                else
                soqlString += ' Vmstar_Id__c IN :SetOfGSSDuplicateCase';

                whereClauseAdded = true;


                if(Set1.size()>0)
                if(whereClauseAdded)
                soqlString += ' OR Vmstar_Id__c IN :Set1';
                else
                soqlString += ' Vmstar_Id__c IN :Set1';

                whereClauseAdded = true;


                if(Set11.size()>0)
                if(whereClauseAdded)
                soqlString += ' OR Vmstar_Id__c IN :Set11';
                else
                soqlString += ' Vmstar_Id__c IN :Set11';

                whereClauseAdded = true;


                //query the records using Database.query method
                List<Case> requiredCases = Database.query(soqlString);

                for(Case et : requiredCases)
                if(et.id!=null)
                MapOfParentId.put(et.Vmstar_Id__c,et.id);

                if(et.GSS_Duplicate_Case__c!=null)
                MapOfGSSDuplicateCase.put(et.VMstar_Id__c,et.GSS_Duplicate_Case__c);

                if(et.Duplicate_Of_Case__c!=null)
                MapOfDuplicateOfCase.put(et.VMstar_Id__c,et.Duplicate_Of_Case__c);

                if(et.GSS_Build_Number__c!=null)
                Set3.add(et.GSS_Build_Number__c);

                if(et.GSS_Product_Version__c!=null)
                Set33.add(et.GSS_Build_Number__c);







                share|improve this answer















                You are getting this issue because you are adding the WHERE clause with all of your sets size equal to 0. Hence your SOQL query is left with WHERE clause without any conditions which leaves your SOQL query incomplete and hence you are getting System.QueryException.



                You will have to add the WHERE clause only when one of your set has any value in it. So, your code should be something like below



                Also, make sure you don't have space between colon and the set variable name



                string soqlString = 'select id,Vmstar_Id__c,GSS_Duplicate_Case__c,Duplicate_Of_Case__c,GSS_Build_Number__c,GSS_Product_Version__c from Case';
                if(SetOfParentId.size()>0 || SetOfGSSDuplicateCase.size()>0 || Set1.size()>0 || Set11.size()>0)
                soqlString += ' Where '

                boolean whereClauseAdded = false;
                if(SetOfParentId.size()>0)
                whereClauseAdded = true;
                soqlString += ' Vmstar_Id__c IN :SetOfParentId';

                if(SetOfGSSDuplicateCase.size()>0)
                if(whereClauseAdded)
                soqlString += ' OR Vmstar_Id__c IN :SetOfGSSDuplicateCase';
                else
                soqlString += ' Vmstar_Id__c IN :SetOfGSSDuplicateCase';

                whereClauseAdded = true;


                if(Set1.size()>0)
                if(whereClauseAdded)
                soqlString += ' OR Vmstar_Id__c IN :Set1';
                else
                soqlString += ' Vmstar_Id__c IN :Set1';

                whereClauseAdded = true;


                if(Set11.size()>0)
                if(whereClauseAdded)
                soqlString += ' OR Vmstar_Id__c IN :Set11';
                else
                soqlString += ' Vmstar_Id__c IN :Set11';

                whereClauseAdded = true;


                //query the records using Database.query method
                List<Case> requiredCases = Database.query(soqlString);

                for(Case et : requiredCases)
                if(et.id!=null)
                MapOfParentId.put(et.Vmstar_Id__c,et.id);

                if(et.GSS_Duplicate_Case__c!=null)
                MapOfGSSDuplicateCase.put(et.VMstar_Id__c,et.GSS_Duplicate_Case__c);

                if(et.Duplicate_Of_Case__c!=null)
                MapOfDuplicateOfCase.put(et.VMstar_Id__c,et.Duplicate_Of_Case__c);

                if(et.GSS_Build_Number__c!=null)
                Set3.add(et.GSS_Build_Number__c);

                if(et.GSS_Product_Version__c!=null)
                Set33.add(et.GSS_Build_Number__c);








                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 23 at 9:43

























                answered Apr 23 at 9:05









                Vijay GanjiVijay Ganji

                2,2202314




                2,2202314



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Salesforce Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f258748%2fsystem-queryexception-unexpected-token-eof%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

                    Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

                    What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company