Re: trigger or something else?

From: tolik(at)aaanet(dot)ru (Anatoly K(dot) Lasareff)
To: "Emils Klotins" <emils(at)dot(dot)lv>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: trigger or something else?
Date: 2000-06-28 10:57:53
Message-ID: 87bt0mkr7y.fsf@tolikus.hq.aaanet.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>>>>> "EK" == Emils Klotins <emils(at)dot(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 them uses differently named fields.

EK> Eg. I have fields passwd and password.
EK> When passwd field changes, password must automatically change
EK> to be the same 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 enables that? --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(at)aaanet(dot)ru

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Guillaume Perréal 2000-06-28 11:35:03 Re: extract last months data
Previous Message Karel Zak 2000-06-28 10:52:40 Re: trigger or something else?