Re: [SQL] currval of sequence "my_seq" is not yet defined in this session

2008-04-28 Thread Scott Marlowe
On Mon, Apr 28, 2008 at 4:33 PM, Nacef LABIDI <[EMAIL PROTECTED]> wrote: > Hi all, > > I am writing some code to get the current value of a sequence using the > currval function to use this value in a following insert on another table. > But I am having this message "currval of sequence "my_seq" is

[SQL] currval of sequence "my_seq" is not yet defined in this session

2008-04-28 Thread Nacef LABIDI
Hi all, I am writing some code to get the current value of a sequence using the currval function to use this value in a following insert on another table. But I am having this message "currval of sequence "my_seq" is not yet defined in this session". Can someone explain me what is the problem wit

Re: [SQL] currval() within one statement

2008-01-22 Thread Richard Huxton
silly_sad wrote: id default value is always set by the trigger before insert on each table for each row. The particular subproblem is to insert one record into ttt1 and then insert corresponding record into ttt, ___This is the place to use currval. I'd be tempted to turn it the other way ar

Re: [SQL] currval() within one statement

2008-01-22 Thread hubert depesz lubaczewski
On Tue, Jan 22, 2008 at 10:16:30AM +0300, silly_sad wrote: > INSERT INTO ttt (a,b) SELECT currval('ttt_id_seq'), 'const' FROM ttt2; > Where the trigger before insert on ttt is defined and this trigger calls > nextval('ttt_id_seq'). > I was surprised having different values of currval() in ttt.a >

Re: [SQL] currval() within one statement

2008-01-22 Thread silly_sad
Richard Huxton wrote: sad wrote: Richard Huxton wrote: Then this is the question on the execution order of the statement INSERT...SELECT... You'll want "Overview of PostgreSQL internals" then http://www.postgresql.org/docs/8.2/static/overview.html What do you think should happen? I had

Re: [SQL] currval() within one statement

2008-01-22 Thread Richard Huxton
sad wrote: Richard Huxton wrote: Then this is the question on the execution order of the statement INSERT...SELECT... You'll want "Overview of PostgreSQL internals" then http://www.postgresql.org/docs/8.2/static/overview.html What do you think should happen? I had expected all the currva

Re: [SQL] currval() within one statement

2008-01-22 Thread Guillaume Lelarge
sad wrote: Guillaume Lelarge wrote: sad wrote: A. Kretschmer wrote: is it expected that the currval() changes its value between calls within one statement ? Conclusion, don't call nextval() within a TRIGGER, and insert either nextval() for the column or omit this column. I only note that

Re: [SQL] currval() within one statement

2008-01-22 Thread sad
Richard Huxton wrote: sad wrote: A. Kretschmer wrote: is it expected that the currval() changes its value between calls within one statement ? Conclusion, don't call nextval() within a TRIGGER, and insert either nextval() for the column or omit this column. I only note that i still want t

Re: [SQL] currval() within one statement

2008-01-22 Thread Guillaume Lelarge
sad wrote: A. Kretschmer wrote: is it expected that the currval() changes its value between calls within one statement ? Conclusion, don't call nextval() within a TRIGGER, and insert either nextval() for the column or omit this column. I only note that i still want to discuss the titled pr

Re: [SQL] currval() within one statement

2008-01-22 Thread Richard Huxton
sad wrote: A. Kretschmer wrote: is it expected that the currval() changes its value between calls within one statement ? Conclusion, don't call nextval() within a TRIGGER, and insert either nextval() for the column or omit this column. I only note that i still want to discuss the titled pr

Re: [SQL] currval() within one statement

2008-01-21 Thread sad
A. Kretschmer wrote: is it expected that the currval() changes its value between calls within one statement ? Conclusion, don't call nextval() within a TRIGGER, and insert either nextval() for the column or omit this column. I only note that i still want to discuss the titled problem or to

Re: [SQL] currval() within one statement

2008-01-21 Thread A. Kretschmer
am Tue, dem 22.01.2008, um 10:16:30 +0300 mailte silly_sad folgendes: > Helo > > is it expected that the currval() changes its value between calls within > one statement ? > > Look the following call: > > INSERT INTO ttt (a,b) SELECT currval('ttt_id_seq'), 'const' FROM ttt2; This fails if you

[SQL] currval() within one statement

2008-01-21 Thread silly_sad
Helo is it expected that the currval() changes its value between calls within one statement ? Look the following call: INSERT INTO ttt (a,b) SELECT currval('ttt_id_seq'), 'const' FROM ttt2; Where the trigger before insert on ttt is defined and this trigger calls nextval('ttt_id_seq'). I

Re: [SQL] currval() without specifying the sequence name

2004-03-09 Thread ow
--- Tom Lane <[EMAIL PROTECTED]> wrote: > or that the last one that's touched is the one you want? Correct. __ Do you Yahoo!? Yahoo! Search - Find what you’re looking for faster http://search.yahoo.com ---(end of broadcast)---

Re: [SQL] currval() without specifying the sequence name

2004-03-09 Thread Tom Lane
ow <[EMAIL PROTECTED]> writes: > I guess I could but then: > 1) I'd still have to know the sequence name. When integrating pgSql > with 3party frameworks I'd either have to pass it there (could be a > very difficult task) or make some assumptions (also not very good). This scenario is really enti

Re: [SQL] currval() without specifying the sequence name

2004-03-09 Thread Richard Huxton
On Tuesday 09 March 2004 13:50, ow wrote: > Hi, > > Is there a way to retrieve the current value (i.e. the last used value) of > the last used sequence without specifying the sequence name? Something like > the following: > > create table ( id serial, value varchar(10)); > insert into someOthertest

Re: [SQL] currval() without specifying the sequence name

2004-03-09 Thread Achilleus Mantzios
O kyrios ow egrapse stis Mar 9, 2004 : > > --- Achilleus Mantzios <[EMAIL PROTECTED]> wrote: > > > > You could use the same sequence in many tables. > > > > I guess I could but then: > > 1) I'd still have to know the sequence name. When integrating pgSql with 3party > frameworks I'd either ha

Re: [SQL] currval() without specifying the sequence name

2004-03-09 Thread ow
--- Achilleus Mantzios <[EMAIL PROTECTED]> wrote: > > You could use the same sequence in many tables. > I guess I could but then: 1) I'd still have to know the sequence name. When integrating pgSql with 3party frameworks I'd either have to pass it there (could be a very difficult task) or make

Re: [SQL] currval() without specifying the sequence name

2004-03-09 Thread Achilleus Mantzios
O kyrios ow egrapse stis Mar 9, 2004 : > Hi, > > Is there a way to retrieve the current value (i.e. the last used value) of the > last used sequence without specifying the sequence name? Something like the > following: > > create table ( id serial, value varchar(10)); > insert into someOthertest

[SQL] currval() without specifying the sequence name

2004-03-09 Thread ow
Hi, Is there a way to retrieve the current value (i.e. the last used value) of the last used sequence without specifying the sequence name? Something like the following: create table ( id serial, value varchar(10)); insert into someOthertest (value) values ('100'); insert into test (value) values

[SQL] currval

2000-10-01 Thread Craig May
Hi, I'm executing the following statements in series. insert into [tablename] values('a', 'b', 'c'); select currval('serial'); serial being the default index on [tablename] The statement works fine from the command line, however, when executing via jdbc, I'm getting no results back (null po