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: '<EOF>'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: '<EOF>'Unexpected Token WhereSystem.QueryException unexpected token
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom: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);
dynamic-soql
add a comment |
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
add a comment |
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
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
dynamic-soql
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
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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.
2
+1 In addition, the space in: Set11
should also cause errors.
– sfdcfox
Apr 23 at 8:29
add a comment |
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);
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
2
+1 In addition, the space in: Set11
should also cause errors.
– sfdcfox
Apr 23 at 8:29
add a comment |
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.
2
+1 In addition, the space in: Set11
should also cause errors.
– sfdcfox
Apr 23 at 8:29
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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);
add a comment |
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);
add a comment |
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);
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);
edited Apr 23 at 9:43
answered Apr 23 at 9:05
Vijay GanjiVijay Ganji
2,2202314
2,2202314
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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