Re: How to add data with ResultSet object?

From: Kris Jurka <books(at)ejurka(dot)com>
To: vasylenko(at)uksatse(dot)org(dot)ua
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: How to add data with ResultSet object?
Date: 2007-11-27 19:35:07
Message-ID: 474C716B.3090406@ejurka.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

vasylenko(at)uksatse(dot)org(dot)ua wrote:
> >
> >This is a known driver bug. The parser to determine the base table of an
> >updatable result set is *very* easily confused. Aside from fixing the
> >driver the only way to fix this would be to use a view to hide the ONLY
> >from the driver. CREATE VIEW myonlyview AS SELECT * FROM ONLY forcehol
> >and then writing appropriate insert rules on it so that you can have the
> >driver select from and insert into the view.
> >
>
> Kris, thanks a lot for an advice!
> That what I have done in my DB.
>
>
> I succeed with update,insert and delete calls from pgsql consol.
> But using jdbc driver I'v got another exception attempting to insert,
> update or delete a row : "No primary key found for table "adminhol_view".
>

Oops, sorry for pointing you down the wrong path.

> I think it is more easy to change a bit parseQuery() from
>
>
> -> //I add a couple of code string to aviod this problem
> -> if(tableName.toLowerCase().equals("only"))
> -> tableName = st.nextToken();
>

It needs a little bit more than that. You must use ONLY when issuing
delete or update statements because primary keys do not inherit and you
could end up updating or deleting child table data. I've applied the
attached patch to CVS for 8.0, 8.1, 8.2, and HEAD.

Kris Jurka

Attachment Content-Type Size
only.patch text/x-patch 4.0 KB

Browse pgsql-jdbc by date

  From Date Subject
Next Message Michael Andreasen 2007-11-28 14:50:53 ssl connection and webstart
Previous Message cncinfo@126.com 2007-11-27 15:03:41 cursor "curs" already in use ?