You need to sign in to do that
Don't have an account?
kullai king 1
System.QueryException: unexpected token: !=
Error is in expression '{!sear}' in component <apex:commandButton> in page listobjects: Class.listobjects.sear: line 57, column 1
Class.listobjects.sear: line 57, column 1
Please help me
public with sharing class listobjects {
public String lisobj{get;set;}
public String lisfields{get;set;}
public string opira{get;set;}
public String envalu{get;set;}
public list<Sobject> accList{get;set;}
public set<String> lisfiels{get;set;}
public string query{get;set;}
Public list<SelectOption> getobj(){
List<SelectOption> opty=new List<SelectOption>();
opty.add(new SelectOption('None','--none---'));
opty.add(new selectoption('Account','Account'));
opty.add(new selectoption('Lead','Lead'));
opty.add(new selectoption('Contact','Contact'));
opty.add(new selectoption('Opportunity','Opportunity'));
opty.add(new selectoption('Reports','Reports'));
opty.add(new selectoption('testA__c','testA__c'));
return opty;
}
public listobjects(){
lisfiels=new set<string>();
}
public list<SelectOption> getcall(){
list<selectoption> losfils=new list<selectoption>();
try{
losfils.add(new SelectOption('None','--none---'));
map<String,Schema.SObjectType> schemap = Schema.getGlobalDescribe();
Schema.SObjectType ts=schemap.get(lisobj);
Schema.DescribeSobjectResult dsobjresul=ts.getDescribe();
Map<String,Schema.SObjectField> fildres=dsobjresul.Fields.getmap();
for(Schema.SobjectField sts:fildres.values()){
Schema.DescribeFieldResult dfc=sts.getDescribe();
losfils.add(new SelectOption(dfc.getName(),dfc.getLabel()));
}
}catch(Exception e){}
return losfils;
}
public list<Selectoption> getval(){
list<Selectoption> opera=new list<Selectoption>();
opera.add(new Selectoption('--None--','--None--'));
opera.add(new Selectoption('%','Equal'));
opera.add(new Selectoption('!=','NotEqual'));
opera.add(new Selectoption('>:','Greaterthan'));
return opera;
}
public void sear(){
string query;
Schema.SObjectType tt=Schema.getGlobalDescribe().get(lisobj);
query='Select id,Name from ' + tt + 'where' + lisfields + '!=:' +envalu;
list<Sobject> ss=database.query(query);
system.debug('SSSSSSSSSSSSS'+query);
}
}
Error Apex Dynamical Query
System.QueryException: unexpected token: !=
Error is in expression '{!sear}' in component <apex:commandButton> in page listobjects: Class.listobjects.sear: line 57, column 1
Class.listobjects.sear: line 57, column 1
Please help me
public with sharing class listobjects {
public String lisobj{get;set;}
public String lisfields{get;set;}
public string opira{get;set;}
public String envalu{get;set;}
public list<Sobject> accList{get;set;}
public set<String> lisfiels{get;set;}
public string query{get;set;}
Public list<SelectOption> getobj(){
List<SelectOption> opty=new List<SelectOption>();
opty.add(new SelectOption('None','--none---'));
opty.add(new selectoption('Account','Account'));
opty.add(new selectoption('Lead','Lead'));
opty.add(new selectoption('Contact','Contact'));
opty.add(new selectoption('Opportunity','Opportunity'));
opty.add(new selectoption('Reports','Reports'));
opty.add(new selectoption('testA__c','testA__c'));
return opty;
}
public listobjects(){
lisfiels=new set<string>();
}
public list<SelectOption> getcall(){
list<selectoption> losfils=new list<selectoption>();
try{
losfils.add(new SelectOption('None','--none---'));
map<String,Schema.SObjectType> schemap = Schema.getGlobalDescribe();
Schema.SObjectType ts=schemap.get(lisobj);
Schema.DescribeSobjectResult dsobjresul=ts.getDescribe();
Map<String,Schema.SObjectField> fildres=dsobjresul.Fields.getmap();
for(Schema.SobjectField sts:fildres.values()){
Schema.DescribeFieldResult dfc=sts.getDescribe();
losfils.add(new SelectOption(dfc.getName(),dfc.getLabel()));
}
}catch(Exception e){}
return losfils;
}
public list<Selectoption> getval(){
list<Selectoption> opera=new list<Selectoption>();
opera.add(new Selectoption('--None--','--None--'));
opera.add(new Selectoption('%','Equal'));
opera.add(new Selectoption('!=','NotEqual'));
opera.add(new Selectoption('>:','Greaterthan'));
return opera;
}
public void sear(){
string query;
Schema.SObjectType tt=Schema.getGlobalDescribe().get(lisobj);
query='Select id,Name from ' + tt + 'where' + lisfields + '!=:' +envalu;
list<Sobject> ss=database.query(query);
system.debug('SSSSSSSSSSSSS'+query);
}
}
1. You are are not puttin any spaces between words like From , Querying Object, where and where clause.
2. envalu is a variable so it should come like below
lisfields + '!=: envalu' ;
so that what when it gets executed it behace like a variable.
Thanks
Sandeep Singhal
http://www.codespokes.com/
All Answers
1. You are are not puttin any spaces between words like From , Querying Object, where and where clause.
2. envalu is a variable so it should come like below
lisfields + '!=: envalu' ;
so that what when it gets executed it behace like a variable.
Thanks
Sandeep Singhal
http://www.codespokes.com/
Thanks For Giving Response. I got the Isseu.