pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Cramer <pg@fastcrypt.com>
To: Daniel Schaedler <postgres-jdbc@daniel.schaedler.name>
Cc: Guillaume Cottenceau <gc@mnc.ch>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: problem to get nextval of a sequence
Date: Tue, 28 Dec 2004 09:05:36 -0500
Message-ID: <41D16830.7000800@fastcrypt.com> (raw)
In-Reply-To: <41D1608B.10109@daniel.schaedler.name>
References: <41D15580.3050700@daniel.schaedler.name>
	<87zmzyblx3.fsf@meuh.mnc.ch>
	<41D1608B.10109@daniel.schaedler.name>

Daniel,

The spec says that you must call next to position the cursor. What 
happens if nothing comes back? ie an empty result set ?

Dave

Daniel Schaedler wrote:

> Guillaume Cottenceau wrote:
>
>> Daniel Schaedler <postgres-jdbc 'at' daniel.schaedler.name> writes:
>>
>>
>>> Hi List
>>>
>>> I try to get the 'nextval' of a sequence:
>>> ***
>>>   String query = "SELECT nextval('nodes_nodeid_seq')";
>>>   pstmt = conn.prepareStatement(query);
>>>   logger.debug("statement: " + pstmt.toString());
>>>   ResultSet ress = pstmt.executeQuery();
>>>   long newID = ress.getLong("nextval");  // <-- Exception
>>> ***
>>>
>>> I get the following Exception:
>>> ***
>>> org.postgresql.util.PSQLException: ResultSet not positioned properly,
>>> perhaps you need to call next.
>>
>>
>>
>> "perhaps you need to call next".
>>
>> Have you tried calling next?
>
>
> uhhh....
> ....now yes...and it works.
>
> When I expect only one set of data, I never call next. That's why I 
> ignored the statement.
>
> thanks anyway.
> Daniel
>
>
>

-- 
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561




view thread (6+ messages)  latest in thread

Message-ID: <41D16830.7000800@fastcrypt.com>
Permalink:  ../41D16830.7000800@fastcrypt.com/
Also on:    postgresql.org/message-id/41D16830.7000800@fastcrypt.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: pg@fastcrypt.com, postgres-jdbc@daniel.schaedler.name, gc@mnc.ch
  Subject: Re: problem to get nextval of a sequence
  In-Reply-To: <41D16830.7000800@fastcrypt.com>
  References: <41D15580.3050700@daniel.schaedler.name> <87zmzyblx3.fsf@meuh.mnc.ch> <41D1608B.10109@daniel.schaedler.name> <41D16830.7000800@fastcrypt.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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