• Ranjan Singh
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

The application requirement is to send a list of things to a subscriber, that the subscriber has not already received. (The subscriber cannot receive the same thing twice.) A list of things sent is stored in a transaction table, and a list of things that can be sent is stored in a thing table. In regular SQL, this is a simple query:

 

 

SELECT thingId FROM available_things WHERE thingId NOT IN (SELECT thingId FROM transactions WHERE subscriberId = 'XXX')

This is not possible in SOQL. Apprently, however, we can do something similar:

// An IN-bind with an Id list. Note that a list of sObjects // can also be used--the Ids of the objects are used for // the bind Contact[] cc = [select id from contact limit 2]; Task[] tt = [select id from task where whoId in :cc];

(Taken from the Apex Language Reference here.)

 

Unfortunately, it appears that lists, maps, and sets are all limited to 1000 items. (Contact[] is shorthand for List<Contact>.)

 

Since any of my subscribers may have tens of thousands of things sent to them, I cannot do this:

 

Transaction__c[] thingsSent = [select thingId from transaction__c where subscriber__c = :subscriberId]; Thing__c[] things = [select thingId from thing__c where thingId not in :thingsSent];

 

 

I can set an arbitrary upper limit on the number of thiings to send at 1000, but I cannot set any such limit on the number of things that have already been sent.

 

Can this be done in SOQL?

 

TIA,

 

John

  • May 01, 2009
  • Like
  • 0