Re: get a pkey/id back from/after an insert - Mailing list pgsql-novice

From Corey
Subject Re: get a pkey/id back from/after an insert
Date
Msg-id 200606191527.53479.corey@bitworthy.net
Whole thread Raw
In response to Re: get a pkey/id back from/after an insert  (Richard Broersma Jr <rabroersma@yahoo.com>)
Responses Re: get a pkey/id back from/after an insert  (Richard Broersma Jr <rabroersma@yahoo.com>)
List pgsql-novice
On Monday 19 June 2006 15:00, Richard Broersma Jr wrote:
> I am not sure what the best practice is for adding records to both a "parent" and "child" table.
> However, examples in the postgresql documentation demonstrate the use a view that joins the parent
> and child tables.
>
> Rules are used to propagate insert/update/delete statements on the view to the actual parent/child
> tables.  In addition to this, inserts to the view can also be redirected using triggers.
>
> Once this is setup, I would expect that it would simplify your procedural code.
>
> See:
> http://www.postgresql.org/docs/8.1/interactive/rules.html
>
>
> I would be interested in seeing if there is a way to preform operations like this (without views)
> with just one Sql statement.

Excellent - yes, this is ultimately the same thing I was hoping to achieve:
a single operation, rather than two or more disparate actions.

Thankyou for the extra info and the link, I will definitely check that out very
soon ( right now I'm in crunch mode and just to get something working,
even if it's less elegant ).  I'll post to the list if I successfully manage to
get the single-statement, non-view solution working.


Thanks!

Corey

pgsql-novice by date:

Previous
From: Richard Broersma Jr
Date:
Subject: Re: get a pkey/id back from/after an insert
Next
From: Richard Broersma Jr
Date:
Subject: Re: get a pkey/id back from/after an insert