From: Joseph Shraibman <jks@selectacast.net>
To: Wim Ceulemans <Wim.Ceulemans@nice.be>
Cc: John Thorhauer <jthorhauer@phoenixcolor.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: jdbc how to get SERIAL
Date: Tue, 18 Jul 2000 17:15:48 -0400
Message-ID: <3974C904.E939E842@selectacast.net> (raw)
References: <3974A3B0.E4D01DED@phoenixcolor.com>
<3974A953.92FF9DD2@selectacast.net>
<3974B666.9FF13F1C@nice.be>
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.
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 using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: jks@selectacast.net, Wim.Ceulemans@nice.be, jthorhauer@phoenixcolor.com
Subject: Re: jdbc how to get SERIAL
In-Reply-To: <3974C904.E939E842@selectacast.net>
* 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