db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mamta Satoor <msat...@gmail.com>
Subject Re: ResultSet updateRow() error
Date Fri, 02 Dec 2005 21:40:25 GMT
Danny,

Looking at the insert sql and the program, looks like only one row will
qualify for
SELECT transactiontest.idnumber, transactiontest.name FROM transactiontest
WHERE transactiontest.idnumber = 1 FOR UPDATE
And that is why I think you get the resultset closed when you do commit and
then try to do a next. If you had another row that qualified for the select
statement, next would have taken you to that row.

Mamta


On 12/2/05, Danny <danny.gallagher@gainergroup.com> wrote:
>
>  It is the ClientDriver that I am using.
>
>
>
> Program is attached, as is it updates, if you uncomment the commit and
> next, you get result set is closed, which is different
>
> than the error I was getting before, nonetheless.
>
>
>
> Also, table create:
>
>
>
> CREATE TABLE transactiontest
>
> (
>
>     idnumber            SMALLINT NOT NULL,
>
>     name                VARCHAR(35),
>
>
>
>     PRIMARY KEY (idnumber)
>
> );
>
>
>
> INSERT INTO TRANSACTIONTEST VALUES(1, 'TEST NAME 1');
>
> INSERT INTO TRANSACTIONTEST VALUES(2, 'TEST NAME 2');
>
> INSERT INTO TRANSACTIONTEST VALUES(3, 'TEST NAME 3');
>
> INSERT INTO TRANSACTIONTEST VALUES(4, 'TEST NAME 4');
>
>
>
> Danny Gallagher
>
> The Gainer Group
>
> 6525 The Corners Parkway
>
> Suite 215
>
> Norcross Ga, 30092
>
>
>
>
>  ------------------------------
>
> *From:* Mamta Satoor [mailto:msatoor@gmail.com]
> *Sent:* Thursday, December 01, 2005 12:21 PM
> *To:* Derby Discussion
> *Subject:* Re: ResultSet updateRow() error
>
>
>
> Hi Danny,
>
>
>
> The behavior you are noticing about cursor not positioned on a row after
> commit is documented in Derby Developer's Guide 10.1 at http://db.apache.org/derby/docs/10.1/devguide/cdevconcepts29416.html
>
>
> Looks at subsection Cursors.
>
> "A cursor declared to be held across commit can execute updates and issue
> multiple commits before closing the cursor, but the cursor must be
> repositioned before any statement following the commit."
>
>
>
> As for you not being able to reposition with a next, I don't know why that
> is happening w/o looking at a self-contained reproducible program.
>
>
>
> Mamta
>
>
>
> On 12/1/05, *Danny* <danny.gallagher@gainergroup.com> wrote:
>
> Sounds similar to my issue.
>
> From JIRA comments:
> I think the current behaviour is correct. After a commit the result set is
>
> open but is not positioned on a row. The result set must be re-positioned
> with a next() or other method before acessing a row or modifying it with a
> positioned update or delete. I think this may be from the SQL standard, or
>
> is it the JDBC standard?
>
> The bug 4515 (Cloudscape bug tracking system) was fixed, I think to return
> the correct error as you are seeing.
>
> So I tried calling next() again after the commit but before the call to
> updateRow() to reposition the cursor, no luck, same error:
> Invalid cursor state - no current row.
>
> Danny Gallagher
> The Gainer Group
> 6525 The Corners Parkway
> Suite 215
> Norcross Ga, 30092
>
>
> -----Original Message-----
> From: Fernanda Pizzorno [mailto:Fernanda.Pizzorno@Sun.COM]
> Sent: Thursday, December 01, 2005 3:59 AM
> To: Derby Discussion
> Subject: Re: ResultSet updateRow() error
>
> It appears to me that the behavior you are seeing is similar to that of
> JIRA 610 (http://issues.apache.org/jira/browse/DERBY-610), except that
> you are using updateRow and not positioned update. Is that the case?
>
> Fernanda
>
> Danny wrote:
>
> > I figured out what the problem was, although, I am not sure why the
> > behavior seems to be implemented the way it is.
> >
> > Between the time that I was calling the update methods on the columns
> > and the call to updateRow() a commit was being executed.
> >
> > It seems that this invalidated the current row somehow, I could still
> > get the values from the columns with the get methods, so the entire
> > ResultSet object wasn't hosed, but the cursor seems to be.
> >
> > Since the ResultSet was created with
> > ResultSet.HOLD_CURSORS_OVER_COMMIT, I don't understand why it behaves
> > this way.
> >
> > Danny Gallagher
> >
> > The Gainer Group
> >
> > 6525 The Corners Parkway
> >
> > Suite 215
> >
> > Norcross Ga, 30092
> >
> > ------------------------------------------------------------------------
>
> >
> > *From:* Mamta Satoor [mailto:msatoor@gmail.com]
> > *Sent:* Tuesday, November 29, 2005 2:00 PM
> > *To:* Derby Discussion
> > *Subject:* Re: ResultSet updateRow() error
> >
> > Hi Danny,
> >
> > The scenario you described should work. Can you provide a simple
> > reproducible program for this(along with the table and index creation?
> >
> > Mamta
> >
> > On 11/29/05, *Danny* < danny.gallagher@gainergroup.com
> > <mailto:danny.gallagher@gainergroup.com>> wrote:
> >
> >
> > Derby version = 10.1.2.1 <http://10.1.2.1>
> >
> > I cannot seem to figure out why this ResultSet update is not working.
> >
> > I create the ResultSet with the following:
> >
> > Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,
> > ResultSet.CONCUR_UPDATABLE, ResultSet.HOLD_CURSORS_OVER_COMMIT);
> >
> > The query that I execute to return the result set contains the primary
> > key,
> > FROM contains only one table, and the query contains no JOINS or UNIONS.
> >
> > So then I call next()
> > Update all the columns that I am interested in updating, up to this
> point
> > everything is fine, I can get the column that I updated out, and the
> > values
> > are the updated ones.
> >
> > When I call updateRow(), I get: Invalid cursor state - no current row
> >
> > But there is a current row, I am updating columns in it and those
> updates
> > are taking place.
> >
> > Any help is appreciated.
> > Thanks
> >
> > Danny Gallagher
> > The Gainer Group
> > 6525 The Corners Parkway
> > Suite 215
> > Norcross Ga, 30092
> >
> >
> >
> >
>
>
>
>
>

Mime
View raw message