# Clear Staging Tables for User at Login Time

**URL:** https://www.five.org/t/clear-staging-tables-for-user-at-login-time/633
**Category:** How do I?
**Created:** [March 25, 2026, 8:56pm UTC](https://www.five.org/t/clear-staging-tables-for-user-at-login-time/633 "2026-03-25T20:56:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![RMittelman](https://yyz2.discourse-cdn.com/flex030/user_avatar/www.five.org/rmittelman/32/447_2.png) [@RMittelman](https://www.five.org/u/RMittelman)
#### Post date: [March 25, 2026, 8:56pm UTC](https://www.five.org/t/clear-staging-tables-for-user-at-login-time/633/1 "2026-03-25T20:56:59Z")

</div>

My report queries all load the report data into staging tables, and then run the reports against the staging tables. This was necessary so reports can be either generated on client or staged on server for mail-merge.

The staging tables are **StageMemberList** , **StageGroupList** and **StageGroupRoster**. There will be more as more reports are developed. These tables all have a **UserKey** field, which contains the current user key, obtained at login time.

At login time, I need to clear the staging tables of all records for the current UserKey. I tried this code, which usually works in MySQL:

```auto
    let sqlStage = `SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES 
                    WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME LIKE 'Stage%'`;
    const qr = five.executeQuery(sqlStage, 0);

```

This does NOT work, and in fact throws an error. I believe this is because you have locked down MySQL so us users can’t directly work with the database.

This is fine, if you have an alternative method. I need to obtain the names of all tables which begin with “Stage”, then iterate these names and execute SQL to delete the records for the current user.

Can you please explain how to do this?  
If it cannot be done, please advise. The alternative method is to maintain a list of the known staging tables in a variable/setting, which I can do, but it seems ineffiecient.

Thanks…

---

<div class="post-metadata">

### Author: ![eltonsantos](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@eltonsantos](https://www.five.org/u/eltonsantos)
#### Post date: [March 30, 2026, 3:58am UTC](https://www.five.org/t/clear-staging-tables-for-user-at-login-time/633/2 "2026-03-30T03:58:39Z")

</div>

Hi Ron,

We have locked the access to the INFORMATION\_SCHEMA.

Have you tried to create a table to store the names of the Stage tables? I know it seems cumbersome, but since you want to query all tables starting with ‘Stage‘, I would suggest storing this information in your current database, which will allow you to apply more rules in the future.

Regards,  
Elton S

---

<div class="post-metadata">

### Author: ![RMittelman](https://yyz2.discourse-cdn.com/flex030/user_avatar/www.five.org/rmittelman/32/447_2.png) [@RMittelman](https://www.five.org/u/RMittelman)
#### Post date: [March 30, 2026, 6:16pm UTC](https://www.five.org/t/clear-staging-tables-for-user-at-login-time/633/3 "2026-03-30T18:16:42Z")

</div>

Thanks, Elton. This is how I’m doing it right now.
