Re: insertRow and updateable resultset

From: Dave Cramer <Dave(at)micro-automation(dot)net>
To: Joel Hock <joel(at)enspire(dot)com>
Cc: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: insertRow and updateable resultset
Date: 2003-01-17 21:51:07
Message-ID: 1042840266.1905.235.camel@inspiron.cramers
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Joel,

Is the primary key a "serial" type, as Barry mentioned send us your
schema for that table.

It should work correctly. You may have to do a setNull on the primary
key column.

Dave
On Fri, 2003-01-17 at 13:09, Joel Hock wrote:
> All of this pertains to PostgreSQL 7.1.3 and the jdbc3 development
> driver that I downloaded today and also the stable driver.
>
>
>
> I am using an updateable ResultSet and insertRow() to insert a row,
> which works fine.
>
> I then do a refreshRow() and try to retrieve the auto-generated
> primary key, which doesn’t work. I just get back a null value. I am
> currently using the oid to re-select the row as a workaround, but want
> a database-independent way of getting the key.
>
>
>
> Sample code:
>
>
>
> ResultSet uprs = stmt.executeQuery("SELECT * FROM login WHERE 1=0");
>
> uprs.moveToInsertRow();
>
> uprs.updateObject(“email”, email);
>
> uprs.insertRow();
>
> uprs.next();
>
> uprs.refreshRow();
>
> String loginId = uprs.getString(); // returns null
>
>
>
> Note that the same thing happens if I leave out the ‘uprs.next()’.
> (As an aside, this is a bug because the refreshRow() should fail if
> next() is not called; the java docs state that refreshRow() should
> fail on the insert row).
>
>
>
>
>
> Can anyone confirm that the code I’m using should return the generated
> primary key from the database? I’ve looked at the driver code
> (AbstractJdbc2ResultSet.java) and couldn’t see why this wasn’t
> working.
>
>
>
> Thanks,
>
> Joel
--
Dave Cramer <Dave(at)micro-automation(dot)net>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Joel Hock 2003-01-17 21:51:12 Re: insertRow and updateable resultset
Previous Message Barry Lind 2003-01-17 20:55:56 Re: insertRow and updateable resultset