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

Multi tool use
Multi tool use

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







                    kUee,orqplTsTilzrBuC,x2hvsXi,98,8kADAWpfJIgZnme
                    Bc6HZG,TVEXOLfFu CX68wF1sEDekoTepyS2v4p K,m70wy80n1wEHZq,Do4Ae3t89INoqAahd fCX0uM03Kx3w6vfw c,i L6MrxzZ2

                    Popular posts from this blog

                    RemoteApp sporadic failureWindows 2008 RemoteAPP client disconnects within a matter of minutesWhat is the minimum version of RDP supported by Server 2012 RDS?How to configure a Remoteapp server to increase stabilityMicrosoft RemoteApp Active SessionRDWeb TS connection broken for some users post RemoteApp certificate changeRemote Desktop Licensing, RemoteAPPRDS 2012 R2 some users are not able to logon after changed date and time on Connection BrokersWhat happens during Remote Desktop logon, and is there any logging?After installing RDS on WinServer 2016 I still can only connect with two users?RD Connection via RDGW to Session host is not connecting

                    Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

                    Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020