Re: trigger or something else? - Mailing list pgsql-sql

From tolik@aaanet.ru (Anatoly K. Lasareff)
Subject Re: trigger or something else?
Date
Msg-id 87bt0mkr7y.fsf@tolikus.hq.aaanet.ru
Whole thread Raw
In response to trigger or something else?  ("Emils Klotins" <emils@dot.lv>)
List pgsql-sql
>>>>> "EK" == Emils Klotins <emils@dot.lv> writes:
EK> Hello,EK> I have a table that has to have several fields with different names, EK> but equal content. Sounds
stupid,but it is because I have 2 EK> different programs querying the same table for user information and EK> each of
themuses differently named fields.
 
EK> Eg. I have fields passwd and password.EK> When passwd field changes, password must automatically change EK> to be
thesame as passwd.
 
EK> I was wondering whether I need a trigger for that, or could I EK> somehow manage to specify that in the "create
table"stmt.
 
EK> If I need to do it via trigger, then I apparently need the plpgsql, right?EK> Could you tell which configure option
enablesthat? --enable-EK> plpgsql? 
 
EK> Thanks in advamce for any comments.
EK> Emils

I suppose you can use view for your need. For example:

create table a ( l varchar(30), p varchar(30)
);

create view b as select l as login, p as password from a;

insert into a values ('qq', 'ww');
select * from b;
tolik=# select * from b;login | password 
-------+----------qq    | ww
(1 rows)


Unfortunately this way suits for select only, not for 'insert into b'
and 'update b' statement.

-- 
Anatoly K. Lasareff              Email:       tolik@aaanet.ru 


pgsql-sql by date:

Previous
From: Skeets and Kim Norquist
Date:
Subject: plpgsql function gets wierd with Null parameters
Next
From: "David Craig"
Date:
Subject: extracting a table description