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 8965427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:47:59+00:00 2026-06-15T16:47:59+00:00

I have a table called applications and a table called application_history . I want

  • 0

I have a table called applications and a table called application_history. I want to keep a history of applications and had the idea of using a trigger whenever a row gets updated in the applications table to copy that row to application_history before it is actually updated.

At the moment, I’ve written this code out from another SO post:

create or replace 
trigger APPLICATION_UPDATE_TRG
BEFORE UPDATE ON TBL_APPLICATIONS 
FOR EACH ROW
DECLARE
  CURSOR curAppHistory IS
    SELECT record_number, job_id, submitted_date, status_id, id
      FROM tbl_application
      WHERE id = :old.id;
  vRowAppHistory curAppHistory%ROWTYPE;
BEGIN
  OPEN curAppHistory;
  FETCH curAppHistory INTO vRowAppHistory;
  CLOSE curAppHistory;
  INSERT INTO tbl_application_history
  (record_number, job_id, submitted_date, status_id, application_id)
  VALUES (vRowAppHistory.record_number, vRowAppHistory.job_id, vRowAppHistory.submitted_date, 
  vRowAppHistory.status_id, vRowAppHistory.id);
END;

However, it’s not properly compiling. SQL Developer throws out 3 errors about commands not properly ended and statements being ignored.

What’s the proper way to do this?

Edit: The errors:

Error(2,10): PLS-00341: declaration of cursor 'CURAPPHISTORY' is incomplete or malformed
Error(3,5): PL/SQL: SQL Statement ignored
Error(4,12): PL/SQL: ORA-00942: table or view does not exist
Error(6,18): PL/SQL: Item ignored
Error(9,3): PL/SQL: SQL Statement ignored
Error(9,28): PLS-00320: the declaration of the type of this expression is incomplete or malformed
Error(11,3): PL/SQL: SQL Statement ignored
Error(14,29): PLS-00320: the declaration of the type of this expression is incomplete or malformed
Error(14,44): PL/SQL: ORA-00984: column not allowed here
  • 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-15T16:48:01+00:00Added an answer on June 15, 2026 at 4:48 pm

    Error(4,12): PL/SQL: ORA-00942: table or view does not exist

    A typo? You specified two different tables here.

    BEFORE UPDATE ON TBL_APPLICATIONS

    FROM tbl_application

    Anyway, you’ll get ORA-04091 with this trigger. Similar test case:

    SYSTEM@dwal> create table t (key number primary key, value varchar2(10));
    
    Table created.
    
    SYSTEM@dwal> insert into t values (1, 'abcdef');
    
    1 row created.
    
    SYSTEM@dwal> insert into t values (2, 'ghijkl');
    
    1 row created.
    
    SYSTEM@dwal> commit;
    
    Commit complete
    
    SYSTEM@dwal> ed
    Wrote file S:\\tools\buffer.sql
    
      1  create or replace trigger tt
      2  before update on t for each row
      3  declare
      4  cursor c is
      5    select key, value
      6      from t
      7     where key = :old.key;
      8  v c%rowtype;
      9  begin
     10    open c;
     11    fetch c into v;
     12    close c;
     13    dbms_output.put_line(v.value);
     14* end;
    09:58:51 SYSTEM@dwal> /
    
    Trigger created.
    
    
    SYSTEM@dwal> update t set value = '123';
    update t set value = '123'
           *
    ERROR at line 1:
    ORA-04091: table SYSTEM.T is mutating, trigger/function may not see it
    ORA-06512: at "SYSTEM.TT", line 3
    ORA-06512: at "SYSTEM.TT", line 8
    ORA-04088: error during execution of trigger 'SYSTEM.TT'
    

    You should probably do it like this:

    INSERT INTO tbl_application_history 
    (record_number, job_id, submitted_date, status_id, application_id)
    VALUES 
    (:old.record_number, :old.job_id, :old.submitted_date, :old.status_id, :old.id);
    

    The whole trigger would be a single insert statement in this case:

    SYSTEM@dwal> create table t_log (key number, value varchar2(10));
    
    Table created.
    
    SYSTEM@dwal> ed
    Wrote file S:\\tools\buffer.sql
    
      1  create or replace trigger tt
      2  before update on t for each row
      3  begin
      4    insert into t_log values (:old.key, :old.value);
      5* end;
    SYSTEM@dwal> /
    
    Trigger created.
    
    SYSTEM@dwal> update t set value = '123';
    
    2 rows updated.
    
    SYSTEM@dwal> commit;
    
    Commit complete.
    
    SYSTEM@dwal> select * from t_log;
    
           KEY VALUE
    ---------- ----------
             1 abcdef
             2 ghijkl
    
    
    SYSTEM@dwal> select * from t;
    
           KEY VALUE
    ---------- ----------
             1 123
             2 123
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table called AllCustomersHistoryOfRecords which is table with history of all
I'm working on rails application with postgres db.I have a table called merchant_review_votes where
I have table called stats . In am inserting yes or no in the
i have table called as Support, which have a field named Name and contains
I have table called Buttons. Buttons table i have column button_number . Table contain
I have table called posts in my DB. Each post has field called social_network
I have a table called 'MyTable' that looks like: ID | Item | Type
I have a table called States and i am displaying values of states in
I have a table called TPM_TASKS which contain all tasks, as well as a
I have a table called sellerparams with a number of columns, one of them

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.