Clean database

I want to use automation to clean a database as soon as a new record is being created.

I have an automation task that creates a record with a session ID, a timestamp (NOW()) and two attributes from another table. This works.

As soon as a new record is being created I want the robot to:

1) Check if one or more records with the same session ID's is available

2) Delete all but the newest

To retrieve the session ID I used context(device), works fine for now.

Can someone help me how to set up this robot.

I created a bot, triggered by event "add or update" on the session table

But I can't manage to create an action that checks for duplicates (say column userID: [userID]=Context(device)) and the remove all rows with same userID except the latest

So something like select row where userID=context(device) and delete everything but the row with the most recent timestamp.

Solved Solved
1 2 143
1 ACCEPTED SOLUTION

I made a grouped action which filters based on the same device ID, then delete everything, after that create a new session record

View solution in original post

2 REPLIES 2

I made a grouped action which filters based on the same device ID, then delete everything, after that create a new session record

Steve
Platinum 4
Platinum 4
FILTER(
  "table",
  AND(
    ([userID] = CONTEXT("Device")),
    ([timestamp] < [_THISROW].[timestamp])
  )
)
Top Labels in this Space