Creating a table which can auto update if some column in other table got changed

I have created two tables in postgresql say a and b. So what i want if i change data in table 'a' data in table 'b' automatically got updated at the same time. Or if data in table be such that b.salary= 2000+x where x is variable and it will be passed to table. If any one of the problem get solved i can carry out my work further. Thanks in Advance

Answers


Example:

CREATE TABLE test.x (
   value integer
);

CREATE FUNCTION test.value_calc(_arg integer) RETURNS integer AS
$$
DECLARE
   C_MODIFIER CONSTANT integer = 1000;  -- ;)
BEGIN
   RETURN _arg + C_MODIFIER;  -- there you can put any logic
END;
$$
LANGUAGE plpgsql IMMUTABLE;

CREATE VIEW test.y AS SELECT x.value, test.value_calc(x.value) AS modified FROM test.x AS x;

INSERT INTO test.x VALUES (543);

SELECT * FROM test.y;

value| modified -----+---------- 543| 1543


Need Your Help

While connecting to BLE113 from android 4.3 is logging "Client registered, waiting for callback"

android bluetooth bluetooth-lowenergy samsung-mobile gatt

I'm trying to connect to a BlueGiga BLE113 device and my Samsung Galaxy S4(Android 4.3). I can successfully discover the device but unable to connect and discover services.

Kendo UI ListView Template in MVC4

kendo-ui kendo-grid kendo-asp.net-mvc kendo-treeview kendo-dataviz

I am trying to get image files from the database and bind it to a KendoUI ListView. The problem is that it is not showing images at all.