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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:39:25+00:00 2026-05-11T15:39:25+00:00

Inside of a trigger I’m trying to loop over all columns on a table

  • 0

Inside of a trigger I’m trying to loop over all columns on a table and compare the new values to the old values. Here is what I have so far:

CREATE OR REPLACE TRIGGER 'JOSH'.TEST#UPD BEFORE  UPDATE ON 'JOSH'.'TEST_TRIGGER_TABLE' REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW declare        oldval varchar(2000);       newval varchar(2000);    begin        for row in (SELECT column_name from user_tab_columns where table_name='TEST_TRIGGER_TABLE') loop        execute immediate 'select :old.'||row.column_name||' from dual'   into oldval;        execute immediate 'select :new.'||row.column_name||' from dual'   into newval;        --Do something here with the old and new values    end loop;   end; 

The trigger compiles, but when the trigger fires, I’m getting:

ORA-01008: not all variables bound

on the first execute immediate because it’s expecting a value for :old. :old and :new are already defined as part of the trigger, but it appears that execute immediate can’t see those variables.

Is there a way to dynamically iterate over the column values in a trigger?

  • 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. 2026-05-11T15:39:25+00:00Added an answer on May 11, 2026 at 3:39 pm

    No, you cannot reference :old and :new values dynamically. As Shane suggests, you can write code to generate the static trigger code, if that makes life easier. Also, you can make ‘do something here’ into a package procedure so that your trigger becomes:

    CREATE OR REPLACE TRIGGER JOSH.TEST#UPD BEFORE  UPDATE ON JOSH.TEST_TRIGGER_TABLE begin        my_package.do_something_with (:old.col1, :new.col1);    my_package.do_something_with (:old.col2, :new.col2);    my_package.do_something_with (:old.col3, :new.col3);    -- etc. end; 

    (You can ditch the pointless REFERENCING clause by the way).

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

Sidebar

Related Questions

Good Day All we are trying to do is inside a trigger make sure
I have a foreach loop inside a table to display the content from DB
i have made an tag trigger function inside an anonymous function , here it
I am basically trying to trigger a function if the footer is inside the
I have a trigger AFTER INSERT inside which I must update the value of
Inside a fragment, I have a button which I want to trigger the filling
I'm trying to invoke some C++ code in case a trigger is called inside
I am trying to trigger a custom delegate method inside the delegate method -
I have the following trigger on a blackhole table, that intercepts inserts and passes
I want to have a select statement inside the mysql trigger that has the

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.