Re: inserting to a multi-table view - Mailing list pgsql-general

From Michael Shulman
Subject Re: inserting to a multi-table view
Date
Msg-id c3f821000806162040ia5123asae397950270ad2ba@mail.gmail.com
Whole thread Raw
In response to Re: inserting to a multi-table view  ("Scott Marlowe" <scott.marlowe@gmail.com>)
Responses Re: inserting to a multi-table view
List pgsql-general
On Mon, Jun 16, 2008 at 10:03 PM, Scott Marlowe <scott.marlowe@gmail.com> wrote:
>> I can write a trigger
>> function that does the right thing, with 'INSERT ... RETURNING
>> person_id INTO ...', but Postgres will not let me add an INSERT
>> trigger to a view; it says 'ERROR: "studentinfo" is not a table'.
>
> Got a short example of what you've tried so far?

create function ins_st() returns trigger as $$
declare
  id integer;
begin
  insert into person (...) values (NEW....) returning person_id into id;
  insert into student (person_id, ...) values (id, NEW....);
end;
$$ language plpgsql;

create trigger ins_student before insert on studentinfo
  for each row execute procedure ins_st();

ERROR:  "studentinfo" is not a table

Mike

pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: inserting to a multi-table view
Next
From: "Richard Broersma"
Date:
Subject: Re: inserting to a multi-table view