Skip site navigation (1) Skip section navigation (2)

updateable resultset only working for tables?

From: Guido Fiala <guido(dot)fiala(at)dka-gmbh(dot)de>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: updateable resultset only working for tables?
Date: 2004-03-11 12:36:55
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
First i tried to update/insert records using an updateable resultset using a 
table as datasource, that works just fine.

My application requires to do updates also to views which are created about as 

create view sometable_update as Select * from sometable;
create rule sometable_update_rule as on update to sometable_update do instead 
update sometable set ...;

Updating to sometable_update does work if i type an update statement myself.

However, using code like this:

Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, 
ResultSet urs=stmt.executeQuery("SELECT * FROM sometable_update");

results in an SQLException "no primary keys".

Basically i assume, that this happens because the driver is not able to detect 
the primary keys of a view, which is mainly because postgres stores views in 
a completly different way as tables.

Is there a way to tell the driver the primary keys manually (as i know them at 
this point in my code) for a certain ResultSet/Statement or another solution 
to this problem?

If possible i would like to avoid creating my own insert/update-Strings and 
let it do the driver.



pgsql-jdbc by date

Next:From: Kris JurkaDate: 2004-03-11 13:00:23
Subject: Re: updateable resultset only working for tables?
Previous:From: Markus SchaberDate: 2004-03-11 12:27:22
Subject: Re: Register arbitrary types Framework

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group