Modifying WHERE input conditions for a VIEW

Поиск
Список
Период
Сортировка
От Tony Holmes
Тема Modifying WHERE input conditions for a VIEW
Дата
Msg-id 20030330141507.A83545@crosswinds.net
обсуждение исходный текст
Ответы Re: Modifying WHERE input conditions for a VIEW  (Tom Lane <tgl@sss.pgh.pa.us>)
Export content of a DB  (Ben Clewett <B.Clewett@roadrunner.uk.com>)
Список pgsql-novice
Hi,

I'm stuck with some libraries that severely limit how queries are formed
and sent to postgresql and decided to use views and rules to solve my
problem. However, I've bumped my head on an issue.

I have 2 tables that need to be selected from, depending on the input
WHERE condition.

Here is their very simplified schema:

table foo_users (
  uid serial,
  username character varying(16),    -- No @domainname.com
  password character varying(16),
  active boolean default 't'
);

table domain_users (
  uid serial,
  username character varying(255),    -- Includes @domainname.com
  password character varying(16),
  active boolean default 't'
)

Now, I'm dealing with pgsql commands (from an imap system FYI) that always
appends @domain.com to the username for the where clause:

  SELECT username, password FROM xxxx WHERE username='user@domain.com';


What I want to accomplish is, if the WHERE clause matches @foo.com
I want to select from foo_users, removing @foo.com, otherwise, return
the data from domain_users.

I have experimented with views, rules and looking all over the place
and am stuck!

How can I accomplish this?

Thanks in advance for you assistance!

--
Tony Holmes

Founder and Senior Systems Architect
Crosswinds Internet Communications Inc.


В списке pgsql-novice по дате отправления:

Предыдущее
От: Don Patou
Дата:
Сообщение: database2uml software
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Index behavior question