pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
MoveToInsertRow on a table without a primary key
4+ messages / 3 participants
[nested] [flat]

* MoveToInsertRow on a table without a primary key
@ 2012-03-14 13:03  patrick.balleux@gmail.com
  0 siblings, 1 reply; 4+ messages in thread

From: patrick.balleux@gmail.com @ 2012-03-14 13:03 UTC (permalink / raw)
  To: pgsql-jdbc

Hello all,

I have a table in a database that does not have a primary key.  In the process of migrating data from Oracle to Postgres, I am using ResultSets to populate the Postgres tables.

Basically, all is working well except for tables that do not have a primary key.  When I reach the "movetoinsertrow" instruction in my code, the jdbc driver raises an exception about the missing primary key.

The workaround would be to add a temporary primary key to such table, but I want to avoid that.  I did the same test with HSQLDB and it works.  To me, it seems like a bug.

I googled around for the solution, but found nothing.

Any tips?



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: MoveToInsertRow on a table without a primary key
@ 2012-03-14 14:05  Dave Cramer <pg@fastcrypt.com>
  parent: patrick.balleux@gmail.com
  0 siblings, 1 reply; 4+ messages in thread

From: Dave Cramer @ 2012-03-14 14:05 UTC (permalink / raw)
  To: patrick.balleux@gmail.com; +Cc: pgsql-jdbc

Pretty sure a primary key is a pre-requisite for an updatable result set.

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca



On Wed, Mar 14, 2012 at 9:03 AM,  <patrick.balleux@gmail.com> wrote:
> Hello all,
>
> I have a table in a database that does not have a primary key.  In the process of migrating data from Oracle to Postgres, I am using ResultSets to populate the Postgres tables.
>
> Basically, all is working well except for tables that do not have a primary key.  When I reach the "movetoinsertrow" instruction in my code, the jdbc driver raises an exception about the missing primary key.
>
> The workaround would be to add a temporary primary key to such table, but I want to avoid that.  I did the same test with HSQLDB and it works.  To me, it seems like a bug.
>
> I googled around for the solution, but found nothing.
>
> Any tips?
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: MoveToInsertRow on a table without a primary key
@ 2012-03-14 14:46  Andrew Hastie <andrew@ahastie.net>
  parent: Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Andrew Hastie @ 2012-03-14 14:46 UTC (permalink / raw)
  To: pgsql-jdbc

Not sure if this helps but:-
   1. Examination of the JBC4 spec makes no mention of a PK being a 
pre-requisite for an updatable ResultSet. It implies "cursors" or 
similar are employed.
   2. MS SQLServer 2008 and IBM DB2 for Linux/Unix/Windows also have a 
similar restriction.

Anyway, a table with no PK is bad design of your database tables anyway ;-)

Andrew

On 14/03/12 14:05, Dave Cramer wrote:
> Pretty sure a primary key is a pre-requisite for an updatable result set.
>
> Dave Cramer
>
> dave.cramer(at)credativ(dot)ca
> http://www.credativ.ca
>
>
>
> On Wed, Mar 14, 2012 at 9:03 AM,<patrick.balleux@gmail.com>  wrote:
>> Hello all,
>>
>> I have a table in a database that does not have a primary key.  In the process of migrating data from Oracle to Postgres, I am using ResultSets to populate the Postgres tables.
>>
>> Basically, all is working well except for tables that do not have a primary key.  When I reach the "movetoinsertrow" instruction in my code, the jdbc driver raises an exception about the missing primary key.
>>
>> The workaround would be to add a temporary primary key to such table, but I want to avoid that.  I did the same test with HSQLDB and it works.  To me, it seems like a bug.
>>
>> I googled around for the solution, but found nothing.
>>
>> Any tips?
>>
>> --
>> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: MoveToInsertRow on a table without a primary key
@ 2012-03-14 14:46  Dave Cramer <pg@fastcrypt.com>
  parent: Andrew Hastie <andrew@ahastie.net>
  0 siblings, 0 replies; 4+ messages in thread

From: Dave Cramer @ 2012-03-14 14:46 UTC (permalink / raw)
  To: Andrew Hastie <andrew@ahastie.net>; +Cc: pgsql-jdbc

Unfortunately the API docs are not particularly great.

This http://docs.oracle.com/javase/1.3/docs/guide/jdbc/getstart/resultset.html
gives a strong suggestion to use a primary key

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca



On Wed, Mar 14, 2012 at 10:46 AM, Andrew Hastie <andrew@ahastie.net> wrote:
> Not sure if this helps but:-
>  1. Examination of the JBC4 spec makes no mention of a PK being a
> pre-requisite for an updatable ResultSet. It implies "cursors" or similar
> are employed.
>  2. MS SQLServer 2008 and IBM DB2 for Linux/Unix/Windows also have a similar
> restriction.
>
> Anyway, a table with no PK is bad design of your database tables anyway ;-)
>
> Andrew
>
>
> On 14/03/12 14:05, Dave Cramer wrote:
>>
>> Pretty sure a primary key is a pre-requisite for an updatable result set.
>>
>> Dave Cramer
>>
>> dave.cramer(at)credativ(dot)ca
>> http://www.credativ.ca
>>
>>
>>
>> On Wed, Mar 14, 2012 at 9:03 AM,<patrick.balleux@gmail.com>  wrote:
>>>
>>> Hello all,
>>>
>>> I have a table in a database that does not have a primary key.  In the
>>> process of migrating data from Oracle to Postgres, I am using ResultSets to
>>> populate the Postgres tables.
>>>
>>> Basically, all is working well except for tables that do not have a
>>> primary key.  When I reach the "movetoinsertrow" instruction in my code, the
>>> jdbc driver raises an exception about the missing primary key.
>>>
>>> The workaround would be to add a temporary primary key to such table, but
>>> I want to avoid that.  I did the same test with HSQLDB and it works.  To me,
>>> it seems like a bug.
>>>
>>> I googled around for the solution, but found nothing.
>>>
>>> Any tips?
>>>
>>> --
>>> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgsql-jdbc
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2012-03-14 14:46 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-03-14 13:03 MoveToInsertRow on a table without a primary key patrick.balleux@gmail.com
2012-03-14 14:05 ` Dave Cramer <pg@fastcrypt.com>
2012-03-14 14:46   ` Andrew Hastie <andrew@ahastie.net>
2012-03-14 14:46     ` Dave Cramer <pg@fastcrypt.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox