Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How in PostgreSQL trigger to get access to OLD.myLoopVariable / NEW.myLoopVariable?  RSS feed

 
Max Maximov
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I try to get access to loop variable that is a column names of a table, to get old and new data of each column.



And I have a next error: I try to do it without quotes "", but get the same result.

Help me, please: How can I get access to my old and new columns data ? I need to save all changed data, like a history with fields: column_name, old_value and new_value.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does old refer to? The variable doesn't appear declared anywhere?
 
Knute Snortum
Sheriff
Posts: 3550
85
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe they are created automagically:

https://www.postgresql.org/docs/9.1/static/plpgsql-trigger.html
 
Knute Snortum
Sheriff
Posts: 3550
85
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are sure that the table that tipped the trigger contains the column name?  Maybe print out TG_TABLE_NAME to make sure.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!