dynamically access columns in trigger

From: Daniel Schuchardt <d(dot)schuchardt(at)prodat-sql(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: dynamically access columns in trigger
Date: 2010-05-05 11:23:59
Message-ID: hrrkfs$1o1j$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hy,

i need to have some idea how to dynamically access columns in a trigger.

Use/Case:

We have a workflowmodule. In different cases different workflows should
be fired. In the Workflowdefinitiontable, we say "tablename, when". so e.g.
~~table 1 -> insert~~
~~table 2 -> update~~.

We have a central trigger that fires on all tables. Inside the trigger i
evaluate with "TG_REL_NAME=wf_tablename" -> start workflow.

Now the problem is that there are different workflows in the update
case. e.g. if the price changes, a "CheckNewPrice" workflow is startet,
if a date changes a "CheckNewDeliveryDate" workflow is started.

My idea is to give my workflowdefinitiontable a additional column the
holds the condition, e.g.
~~table 2 -> update -> ~~~~~ new.pricecolumn<>old.pricecolumn ~~~
so i need a solution how to evaluate that dynamic statement in my global
trigger funktion.

Any ideas?

--

Daniel Schuchardt
/Softwareentwicklung/

/http://www.prodat-sql.de/

Browse pgsql-general by date

  From Date Subject
Next Message Chris Barnes 2010-05-05 12:14:38 Re: alter table alter type CASCADE
Previous Message Cédric Villemain 2010-05-05 11:01:49 Re: (psuedo) random serial for PK or at least UNIQUE NOT NULL?