Skip site navigation (1) Skip section navigation (2)

Re: jdbc how to get SERIAL

From: Joseph Shraibman <jks(at)selectacast(dot)net>
To: Wim Ceulemans <Wim(dot)Ceulemans(at)nice(dot)be>
Cc: John Thorhauer <jthorhauer(at)phoenixcolor(dot)com>, pgsql-interfaces(at)postgresql(dot)org
Subject: Re: jdbc how to get SERIAL
Date: 2000-07-18 21:15:48
Message-ID: 3974C904.E939E842@selectacast.net (view raw or flat)
Thread:
Lists: pgsql-interfaces
Wim Ceulemans wrote:
> 
> Joseph Shraibman wrote:
> >
> > Explictly get the value.
> >
> > For example:
> > ResultSet rs = st.executeQuery("select nextval('my_col_name_seq'));
> >         st.next(); int id = st.getInt(1);
> >         st.executeUpdate("insert into mytable values(id = "+id+" , myvalu =
> > 'blah');");
> >
> > John Thorhauer wrote:
> > >
> > > How do I get the id column of a row via jdbc if the column is a SERIAL
> > > column.  I want to get the id of the row after I insert new data via
> > > jdbc execute command.
> > >
> > > Thanks,
> > > John Thorhauer
> > >
> 
> Doesn't it have to be currval in stead of nextval?
> 
No, you want to do an insert, to you need to get the nextval.

In response to

pgsql-interfaces by date

Next:From: radifan karamiDate: 2000-07-19 04:04:53
Subject: RE: Clob or Blob in JDBC -> ImageViewer
Previous:From: Matt FairDate: 2000-07-18 21:15:24
Subject: Searching Blobs

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group