function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
javierjiesjavierjies 

Issues with a SOQL query

Hello everyone!!!

 

I have done an APEX class. If I use this query;

 

 Contact C=[select Name from Contact where Id not in ('a0U80000001p4TEEAY,a0U80000001p4T9EAI')];

 

 It works! It gives me the Contacts I want!

 

But if I do this;

 

string help='a0U80000001p4TEEAY,a0U80000001p4T9EAI';

Contact C=[select Name from Contact where Id not in (:help)];

 

It doesn't work!

 

How do I pass parameters correctly?!?!?

 

Thanks in advance!!

AlsoDougAlsoDoug

You should be using an array or list since you want to make sure it's not one of the two values.

 

Nader2009Nader2009
try string help='''a0U80000001p4TEEAY,a0U80000001p4T9EAI''';
javierjiesjavierjies
You are right . The select is:

 list<Contact> C=[select Name from Contact where Id not in ('a0U80000001p4TEEAY,a0U80000001p4T9EAI')];

 

thank you!

 

 

but the problem persists...

Message Edited by javierjies on 08-26-2009 10:10 AM
AlsoDougAlsoDoug

Try the following code.

 

 

List<String> idsIWantToAvoid = new List<String>(); idsIWantToAvoid.add('a0U80000001p4TEEAY'); idsIWantToAvoid.add('a0U80000001p4T9EAI'); list<Contact> C=[select Name from Contact where Id not in :idsIWantToAvoid ];

 

 

 

javierjiesjavierjies

Thanks , but I can't save the class because it gives me an error message!

 

Save Error: Invalid bind expression type of LIST: String for column of type String

 

 

 

AlsoDougAlsoDoug
Hrm. Trying using an array instead.
VinodVinod
Instead of storing it as string try to store it as ID and try it out.