Skip to main content

Using EVENTLIST

When LINK SOURCE EVENT is specified in the CQ that populates the WActionStore, and the type for the linked events is specified in the EVENT TYPES clause of the CREATE WACTIONSTORE statement, you can use EVENTLIST in a subquery and ITERATOR over the subquery to return values from fields in the linked events.

For example, in MultiLogApp, the WActionStore ApiActivity includes linked events of the type ApiUsage:

CREATE TYPE ApiUsage (
  api String key, 
  sobject String, 
  count Integer, 
  logTime DateTime
);
CREATE TYPE ApiContext (
  api String key, 
  count Integer, 
  logTime DateTime
);
CREATE WACTIONSTORE ApiActivity 
CONTEXT OF ApiContext 
EVENT TYPES (ApiUsage) ...

CREATE CQ GetApiSummaryUsage 
INSERT INTO ApiActivity 
SELECT a.api,  
  sum(a.count),
  first(a.logTime)
FROM ApiSummaryWindow a 
GROUP BY a.api
LINK SOURCE EVENT;

The following query will return all fields from all linked events:

SELECT it.api, it.count, it.logTime, it.sobject FROM
  (SELECT EVENTLIST(t) AS list_of_events FROM Samples.ApiActivity t) z,
  ITERATOR(z.list_of_events) it;