X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0DE155E46DD for ; Sun, 15 Aug 2004 11:42:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01630-06 for ; Sun, 15 Aug 2004 14:42:18 +0000 (GMT) Received: from web54108.mail.yahoo.com (web54108.mail.yahoo.com [206.190.37.243]) by svr1.postgresql.org (Postfix) with SMTP id 204375E37CB for ; Sun, 15 Aug 2004 11:42:15 -0300 (ADT) Message-ID: <20040815144220.58382.qmail@web54108.mail.yahoo.com> Received: from [81.218.84.228] by web54108.mail.yahoo.com via HTTP; Sun, 15 Aug 2004 07:42:20 PDT Date: Sun, 15 Aug 2004 07:42:20 -0700 (PDT) From: Elie Nacache Subject: Re: [GENERAL] Resultset problem or BUG ! To: Oliver Jowett Cc: pgsql-jdbc@postgresql.org In-Reply-To: <411B02FE.6060600@opencloud.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-120682908-1092580940=:54861" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200408/98 X-Sequence-Number: 10820 --0-120682908-1092580940=:54861 Content-Type: text/plain; charset=us-ascii Hi Oliver, > What is the exception you see? The exception returned is "Cannot move to index of 0". > The current development driver (see jdbc.postgresql.org) will treat > absolute(0) as if you'd called beforeFirst(). Older drivers might do > something different. This is exactly the solution. What is the due date of the current development driver ? Elie Oliver Jowett wrote: Elie Nacache wrote: > this.sqlDatas.moveToInsertRow(); > this.updateColumns(); > this.sqlDatas.insertRow(); The JDBC javadoc implies that calling insertRow() leaves the resultset on the insert row. This is what the driver implements. > this.sqlLineNumber = this.sqlDatas.getRow(); // INFO >> return 0 As the javadoc says, getRow() returns 0 if there is no current row. You're on the insert row so there is no current row. > INFO >> At this step there is no commit > INFO >> Second step update the row after collecting updated info > > this.sqlDatas.absolute(this.sqlLineNumber); // INFO >> throw the > exception What is the exception you see? The current development driver (see jdbc.postgresql.org) will treat absolute(0) as if you'd called beforeFirst(). Older drivers might do something different. > this.updateColumns(); > this.sqlDatas.updateRow(); > INFO >> If I fix the sqlLineNumber to 1 and force the absolute(1) > then no Execption is thrown but the modification is not seen in the > table. Looking at the driver source, it looks like the newly inserted row is appended to the resultset, so you should find it at the end of the resultset not the start. (I don't think making this assumption is portable, though). -O __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --0-120682908-1092580940=:54861 Content-Type: text/html; charset=us-ascii
Hi Oliver,
 
> What is the exception you see?
The exception returned is "Cannot move to index of 0".
 
> The current development driver (see jdbc.postgresql.org) will treat
> absolute(0) as if you'd called beforeFirst(). Older drivers might do
> something different.
 
This is exactly the solution. What is the due date of the current development driver ?
 
Elie

Oliver Jowett <oliver@opencloud.com> wrote:
Elie Nacache wrote:

> this.sqlDatas.moveToInsertRow();
> this.updateColumns();
> this.sqlDatas.insertRow();

The JDBC javadoc implies that calling insertRow() leaves the resultset
on the insert row. This is what the driver implements.

> this.sqlLineNumber = this.sqlDatas.getRow(); // INFO >> return 0

As the javadoc says, getRow() returns 0 if there is no current row.
You're on the insert row so there is no current row.

> INFO >> At this step there is no commit
> INFO >> Second step update the row after collecting updated info
>
> this.sqlDatas.absolute(this.sqlLineNumber); // INFO >> throw the
> exception

What is the exception you see?

The current development driver (see jdbc.postgresql.org) will treat
absolute(0) as if you'd called beforeFirst(). O lder drivers might do
something different.

> this.updateColumns();
> this.sqlDatas.updateRow();
> INFO >> If I fix the sqlLineNumber to 1 and force the absolute(1)
> then no Execption is thrown but the modification is not seen in the
> table.

Looking at the driver source, it looks like the newly inserted row is
appended to the resultset, so you should find it at the end of the
resultset not the start. (I don't think making this assumption is
portable, though).

-O

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com --0-120682908-1092580940=:54861--