From: | "Michael Shulman" <shulman(at)mathcamp(dot)org> |
---|---|
To: | "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: inserting to a multi-table view |
Date: | 2008-06-17 03:40:05 |
Message-ID: | c3f821000806162040ia5123asae397950270ad2ba@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Jun 16, 2008 at 10:03 PM, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Broersma | 2008-06-17 05:24:50 | Re: inserting to a multi-table view |
Previous Message | Michael Shulman | 2008-06-17 03:32:46 | Re: inserting to a multi-table view |