Clear Staging Tables for User at Login Time

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:

    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…