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 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

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You'll want to use a UNION SELECT: SELECT p.id, COUNT(p.id),… May 12, 2026 at 12:58 am
  • Editorial Team
    Editorial Team added an answer Make sure to use alpha transparency only on tiles that… May 12, 2026 at 12:58 am
  • Editorial Team
    Editorial Team added an answer Why not a dict, with channel number as the key… May 12, 2026 at 12:58 am

Related Questions

Inside of a trigger I'm trying to loop over all columns on a table
I working on a XAML style for my controls. The code below is for
I have a program that uses a Microsoft Access database for its back-end. I
I have a simple .Net enum. I also have a view model object which
I'm trying to find out whether I should be using business critical logic in

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.