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

                    Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

                    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