Re: jdbc how to get SERIAL - Mailing list pgsql-interfaces

From Joseph Shraibman
Subject Re: jdbc how to get SERIAL
Date
Msg-id 3974C904.E939E842@selectacast.net
Whole thread Raw
In response to jdbc how to get SERIAL  (John Thorhauer <jthorhauer@phoenixcolor.com>)
List 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.


pgsql-interfaces by date:

Previous
From: Matt Fair
Date:
Subject: Searching Blobs
Next
From: radifan karami
Date:
Subject: RE: Clob or Blob in JDBC -> ImageViewer