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

  • Home
  • SEARCH
  • 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 8977781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:27:04+00:00 2026-06-15T19:27:04+00:00

I have one table called event , and created another global temp table tmp_event

  • 0

I have one table called event, and created another global temp table tmp_event with the same columns and definition with event. Is it possible to insert records in event to tmp_event using this ?

DECLARE
   v_record event%rowtype;
BEGIN 
   Insert into tmp_event values v_record;
END;

There are too many columns in event table, I want to try this because I don’t want to list all the columns.

Forget to mention: I will use this in the trigger, can this v_record be the object :new after insert on EVENT table ?

  • 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-06-15T19:27:05+00:00Added an answer on June 15, 2026 at 7:27 pm

    To insert one row-

    DECLARE
       v_record event%rowtype;
    BEGIN 
       SELECT * INTO v_record from event where rownum=1; --or whatever where clause
       Insert into tmp_event values v_record;
    END;
    

    Or a more elaborate version to insert all rows from event–

    DECLARE
      TYPE t_bulk_collect_test_tab IS TABLE OF event%ROWTYPE;
    
      l_tab t_bulk_collect_test_tab;
    
      CURSOR c_data IS
        SELECT *
        FROM event;
    BEGIN
      OPEN c_data;
      LOOP
        FETCH c_data
        BULK COLLECT INTO l_tab LIMIT 10000;
        EXIT WHEN l_tab.count = 0;
    
        -- Process contents of collection here.
        Insert into tmp_event values v_record;
      END LOOP;
      CLOSE c_data;
    END;
    /
    

    In a trigger, yes it is possible but its like the chicken or the egg. You have to initialize every field of the rowtype with the :new column values like-

    v_record.col1 := :new.col1;
    v_record.col2 := :new.col2;
    v_record.col3 := :new.col3;
    ....
    

    Apparently, the PLSQL examples above cannot be used in a trigger since it would throw a mutating trigger error. And there is no other way for you to get the entire row in the trigger other than accessing each column separately as I explain above, so if you do all this why not directly use :new.col in the INSERT into temp_event itself, will save you a lot of work.


    Also since you say it’s a lot of work to mention all the columns, (in Oracle 11gR2) here’s a quick way of doing that by generating the INSERT statement and executing it dynamically (although not tested for performance).

    CREATE OR REPLACE TRIGGER event_air --air stands for "after insert of row"
    AFTER INSERT ON EVENT
    FOR EACH ROW
       L_query varchar2(2000);   --size it appropriately
    BEGIN
    
       SELECT 'INSERT INTO tmp_event VALUES ('|| listagg (':new.'||column_name, ',') 
                                               WITHIN GROUP (ORDER BY column_name) ||')' 
         INTO l_query
         FROM all_tab_columns
        WHERE table_name='EVENT';
    
       EXECUTE IMMEDIATE l_query;
    
    EXCEPTION
        WHEN OTHERS THEN
            --Meaningful exception handling here
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table called sellerparams with a number of columns, one of them
Lets say I have one table called REVIEWS This table has Reviews that customers
I have one table, t1, which has fileds called userid, week and year fields.
I have 2 datatables in a dataset. One table has a list called CostTypes.
I have two tables one called fs_note the other called dumy_fs_note I created after
I have one table which contains events and dates, and another which contains the
My application has one table called 'events' and each event has approx 30 standard
I have several databases that each have a table called, say, products . One
I have an excel file with four text columns: one of them is called
i have two tables one is called addons and holds information about different addons,

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.