Writing a generic delete rule for a view

Поиск
Список
Период
Сортировка
От Scott Cain
Тема Writing a generic delete rule for a view
Дата
Msg-id 536f21b00903051020n5c7340c2ve96e0977365839f7@mail.gmail.com
обсуждение исходный текст
Список pgsql-sql
Hello,

I have a relatively straight forward set up with two schemas, the main
public schema and a private schema (called "testschema" here).  The
tables in both schemas are nearly identical: for each table "foo" in
the public schema, there is a table "testschema._foo" and a view
"testschema.foo" in the private schema, where testschema.foo is a
simple union of the public and private tables, to make it appear when
querying in the private schema that the tables are exactly the same as
the public schema, and that the tables have a union of what is in the
private and public schemas.

Now, I would like to allow insert, update and delete rules on the
private views to do the same actions in private tables (that is, an
insert into testschema.foo should really do an insert into
testschema._foo).  Writing rules to do the update and inserts was
fairly straight forward.  What I don't understand how to do is a
general rule for doing deletes on testschema._foo.  What I would like
would be a way to "grab" the where clause and append it onto the DO
INSTEAD for the rule.  I'm thinking something like this:
 CREATE OR REPLACE RULE testschema_delete_foo    AS ON DELETE TO testschema.foo    DO INSTEAD (DELETE FROM
testschema._fooWHERE $where);
 

So, what I want to know is, is there a "magic" way to get that $where?

Thanks,
Scott


-- 
------------------------------------------------------------------------
Scott Cain, Ph. D.                                   scott at scottcain dot net
GMOD Coordinator (http://gmod.org/)                     216-392-3087
Ontario Institute for Cancer Research


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

Предыдущее
От: Jhonny Velasquez c.
Дата:
Сообщение:
Следующее
От: "Oliveiros Cristina"
Дата:
Сообщение: Re: uso de dblink en php