Skip to Main Content

Trigger that makes concatenation rows into cols and inserts to another tab.

nodexAug 10 2011 — edited Aug 10 2011
Hi,

I have a trigger to do. Let me explain you how everything looks like in my DB.

TABLE A

O_ID | NAME
---------------------------
1 | A_Name1
2 | A_Name2
3 | A_Name3
4 | A_Name4


TABLE B
O_ID | NAME | DATE
---------------------------------------------------------------
1 | ATT_15 |2011-01-01
1 | ATT_16 |2011-01-02
2 | ATT_15 |2011-03-03
4 | ATT_19 |2011-03-05


TABLE C (dictionary)

P_ID | P_NAMEATTRIBUTE
-----------------------
1 | P1
2 | P2
3 | P3
4 | P4

TABLE D

O_ID | P_ID
------------------
1 | 1
1 | 2
1 | 4
2 | 3
2 | 4
4 | 2

Basicly, all I'm trying to do is make a trigger based on:
When you update Table A do an insert into Table B. What should be inserted?
All ID’s from table C that matches trough TABLE D
A.O_ID = D.O_ID and C.P_ID = D.P_ID but concatenated.
I would like to have in this case inserted into table B records like that:

O_ID | P_ID | P_NAMEATTRIBUTE
----------------------------------------------
1 | 1 2 | P1 P2 P4
2 | 3 4 | P3 P4
4 | 2 | P2

Let's hope it's comprehensive. :)

Regards!
Comments
Post Details
Added on Aug 10 2011
4 comments
105 views