I have a SQL view, which resolves some foreign key dependencies. The View looks like this:
id | title | plantName | customerName | lastUpdated
Where plantName and customerName are 2 resolved values of a foreign key.
There are 3 Tables in total:
Table 1
id | name | surname | idTable2 | idTable3 | lastUpdated
Table 2
id | plantName
Table 3
id | firstName | lastName
What i want to archieve is a trigger which updates the lastUpdated
column in the View everytime a row shows another value.
The Problem here is, that lastUpdated
inside the View should also be updated when a foreign key changes it's value.
Example view Output:
1 | hotel | mock | meier | 2020-02-26 10:03:03.817
2 | hotel | raddison | mueller | 2020-02-26 10:04:03.000
Let's say I'll update Table 2
and update "raddison" to "mercure hotel". The View will look like this afterwards:
1 | hotel | mock | meier | 2020-02-26 10:03:03.817
2 | hotel | mercure hotel | mueller | 2020-02-26 10:04:03.000
I now want that the lastUpdated
Column in the View of row 2 representing the datetime where the foreign key has changed.
Desired output:
1 | hotel | mock | meier | 2020-02-26 10:03:03.817
2 | hotel | mercure hotel | mueller | 2020-02-26 13:44:03.000
Is there any way to archieve this?
Thanks in Advance