[ADMIN] Updatable view and default sequence values

2006-05-17 Thread Kouber Saparev
Hi All, I am currently using PostgreSQL 8.1.3 and am trying to create an updatable view with two (or more) joined tables and I also would like to have the ability to indicate implicitly the value of the serial primary key fields. I have the following two tables: CREATE TABLE purchase ( pu

Re: [ADMIN] Updatable view and default sequence values

2006-05-22 Thread Jim C. Nasby
On Tue, May 16, 2006 at 04:16:55PM +0300, Kouber Saparev wrote: > The tricky part comes when I try to make my view insertable. Normally > I'd insert without specifying the sequence values, but in some cases I'd > want also to have full control of what's going into the underlying > tables. The th

Re: [ADMIN] Updatable view and default sequence values

2006-05-22 Thread Kouber Saparev
Jim C. Nasby wrote: On Tue, May 16, 2006 at 04:16:55PM +0300, Kouber Saparev wrote: The tricky part comes when I try to make my view insertable. Normally I'd insert without specifying the sequence values, but in some cases I'd want also to have full control of what's going into the underlying

Re: [ADMIN] Updatable view and default sequence values

2006-05-22 Thread Jim C. Nasby
On Mon, May 22, 2006 at 10:30:47PM +0300, Kouber Saparev wrote: > Jim C. Nasby wrote: > >On Tue, May 16, 2006 at 04:16:55PM +0300, Kouber Saparev wrote: > >>The tricky part comes when I try to make my view insertable. Normally > >>I'd insert without specifying the sequence values, but in some case

Re: [ADMIN] Updatable view and default sequence values

2006-05-23 Thread Kouber Saparev
Jim C. Nasby wrote: I think you could get away with doing a CASE or COALESCE statement, ie: INSERT INTO subscription_purchase ... SELECT COALESCE(currval('purchase_purchase_sid_seq'), NEW.purchase_sid) BTW, it would be interesting to share whatever you finally come up with; it's an interesting