Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7049639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:02:39+00:00 2026-05-28T03:02:39+00:00

We have an application that creates a table with a randomly generated name. I

  • 0

We have an application that creates a table with a randomly generated name. I would like to create a trigger on this table.Since I do not know the name of the tabe I would like to get it from the all_table view. How can I go about achieveing something like this?

    create or replace trigger t1      
after insert or update on (select table_name from all_tables where owner = 'CustomAPP' and table_name like 'STAGE_%')  
     -- for each row
    declare
      -- local variables here
    begin

    end t1;

The SQL above obviously gives an error because of the select clause after the create trigger instead of a table name. Please advise

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:02:40+00:00Added an answer on May 28, 2026 at 3:02 am

    You would need to make the entire CREATE TRIGGER dynamic in order to do this. Something like this should work. You probably want to make the trigger name depend on the name of the table assuming there could be multiple tables that your query against ALL_TABLES might return multiple rows. And you certainly want the trigger to do something rather than having an empty body.

    SQL> create table stg_12345( col1 number );
    
    Table created.
    
    SQL> begin
      2    for x in (select *
      3                from user_tables
      4               where table_name like 'STG%')
      5    loop
      6      execute immediate
      7        'create or replace trigger trg_foo ' ||
      8        ' before insert on ' || x.table_name ||
      9        ' for each row ' ||
     10        'begin ' ||
     11        '  null; ' ||
     12        'end;';
     13    end loop;
     14  end;
     15  /
    
    PL/SQL procedure successfully completed.
    
    SQL> select count(*) from user_triggers where trigger_name = 'TRG_FOO';
    
      COUNT(*)
    ----------
             1
    

    Of course, the idea of an application that creates tables on the fly is one that frightens me to the core. If you have any control over that, I would strongly suggest reconsidering the architecture.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that creates records in a table (rocket science, I know).
Suppose I have a table (MySQL) like this: CREATE TABLE sessions ( session_id INT
I have created a table in my Ruby on Rails application that I am
I have an application that creates, and destroys thousands of objects. Is it worth
I want to run javascript/Python/Ruby inside my application. I have an application that creates
I have application that brings response via Ajax and creates 5-20 new jQuery click
I have an information retrieval application that creates bit arrays on the order of
I have a .Net application that dynamically creates a small HTML page and pops
I have an application that gets installed with a Wise installer (EDIT: Wise creates
We have an internal .NET case management application that automatically creates a new case

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.