View and primary key

Started by Adrian Klaverover 23 years ago3 messagesgeneral
Jump to latest
#1Adrian Klaver
aklaver@attbi.com

I have set up a view with rules for insert,update and delete. I would like to
be able to use this view from OpenOffice, however it will not allow editing
of a table without a primary key. I cannot create a primary key because
Postgresql says the column does not have a NOT NULL constraint. This column
in the underlying table is NOT NULL. Is there a way to create a primary key
on a view?

Thank you
Adrian Klaver

#2Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Adrian Klaver (#1)
Re: View and primary key

On Fri, 22 Nov 2002, Adrian Klaver wrote:

I have set up a view with rules for insert,update and delete. I would like to
be able to use this view from OpenOffice, however it will not allow editing
of a table without a primary key. I cannot create a primary key because
Postgresql says the column does not have a NOT NULL constraint. This column
in the underlying table is NOT NULL. Is there a way to create a primary key
on a view?

I don't think so at this time. Even if you got past that, I think the
index creation would fail saying that the view wasn't a table.

#3Scott Lamb
slamb@slamb.org
In reply to: Adrian Klaver (#1)
Re: View and primary key

Adrian Klaver wrote:

I have set up a view with rules for insert,update and delete. I would like to
be able to use this view from OpenOffice, however it will not allow editing
of a table without a primary key. I cannot create a primary key because
Postgresql says the column does not have a NOT NULL constraint. This column
in the underlying table is NOT NULL. Is there a way to create a primary key
on a view?

Nope, you can't have constraints on views. Typically what I've done with
similar things is to (1) make sure the column is a primary key in the
underlying table and (2) manually tell the tool the column in the view
is a primary key. I'd assume OpenOffice has some way to do that.