From roopabenzer@yahoo.com Sun Jul 29 12:00:24 2007 Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id A6A8A9FB1C4 for ; Sun, 29 Jul 2007 09:00:24 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 69619-05 for ; Sun, 29 Jul 2007 09:00:11 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from web50803.mail.re2.yahoo.com (web50803.mail.re2.yahoo.com [206.190.38.112]) by postgresql.org (Postfix) with SMTP id 5ACEA9FA4E4 for ; Sun, 29 Jul 2007 09:00:11 -0300 (ADT) Received: (qmail 95261 invoked by uid 60001); 29 Jul 2007 12:00:09 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=NuLssEJaCB7oU40rs7klvGxCehVUVI5i66OvptInPVb19h8jdgwaVU9te6/CDOfUa2k95M8bU80BgvNGl9dOYT3+xVvwEzfv0vsQzzNJp6K5PKbnpHwrSrvrj0Fr2K50KfXHFT1fRWud0elaK2MbLS3M6iVtR64e+lR77ozTFC8=; X-YMail-OSG: ppdZz6cVM1kfeQ5mOwBZstWeWMz3hJcZssYFIZf26CKArNTJErmzT5ln.gLCQppyR7kCAjJ3BkmYYbun.qo80lSi_ZESkxXKlASsX7hwFFSPm2jlVumIuUzZTEDZ8g-- Received: from [116.240.130.24] by web50803.mail.re2.yahoo.com via HTTP; Sun, 29 Jul 2007 05:00:09 PDT Date: Sun, 29 Jul 2007 05:00:09 -0700 (PDT) From: roopa perumalraja Subject: increment the primary key value without using sequences To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-334839604-1185710409=:94674" Content-Transfer-Encoding: 8bit Message-ID: <945413.94674.qm@web50803.mail.re2.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/177 X-Sequence-Number: 28912 --0-334839604-1185710409=:94674 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi all, I would like to know if its possible to increment the primary key field value of stocks table without using sequences by getting the next value of the pk field from the sequnce table ? insert into stocks (prim_id, date,time, code, price, volume) (select ..... from temp_stocks) sequence sequence_code | next_value prim_id 101 stocks table (prim_id, date, time, code, price, volume) temp_stocks table (date, time, code, price, volume) If it can be done, can you please explain me with an example. Thanks a lot in advance. --------------------------------- Sick sense of humor? Visit Yahoo! TV's Comedy with an Edge to see what's on, when. --0-334839604-1185710409=:94674 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit
Hi all,
 
I would like to know if its possible to increment the primary key field value of stocks table without using sequences by getting the next value of the pk field from the sequnce table ?
 
insert into stocks (prim_id, date,time, code, price, volume) (select ..... from temp_stocks)
 
sequence
sequence_code | next_value
prim_id               101
 
stocks table (prim_id, date, time, code, price, volume)
 
temp_stocks table (date, time, code, price, volume)
 
If it can be done, can you please explain me with an example.
 
Thanks a lot in advance.


Sick sense of humor? Visit Yahoo! TV's Comedy with an Edge to see what's on, when. --0-334839604-1185710409=:94674-- From grzm@seespotcode.net Sun Jul 29 13:37:52 2007 Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 547BA9FA56E for ; Sun, 29 Jul 2007 10:37:52 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 60336-10 for ; Sun, 29 Jul 2007 10:37:41 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mtai04.charter.net (mtai04.charter.net [209.225.8.184]) by postgresql.org (Postfix) with ESMTP id 64D8E9FA4DD for ; Sun, 29 Jul 2007 10:37:49 -0300 (ADT) Received: from aa03.charter.net ([10.20.200.155]) by mtai04.charter.net (InterMail vM.7.08.02.00 201-2186-121-20061213) with ESMTP id <20070729133743.HHSY1443.mtai04.charter.net@aa03.charter.net>; Sun, 29 Jul 2007 09:37:43 -0400 Received: from [10.0.1.3] (really [66.188.165.91]) by aa03.charter.net with ESMTP id <20070729133743.QKOL7864.aa03.charter.net@[10.0.1.3]>; Sun, 29 Jul 2007 09:37:43 -0400 In-Reply-To: <945413.94674.qm@web50803.mail.re2.yahoo.com> References: <945413.94674.qm@web50803.mail.re2.yahoo.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <889B7471-25C6-4D05-9AA3-91BE11F9CFE0@seespotcode.net> Cc: pgsql-sql@postgresql.org Content-Transfer-Encoding: 7bit From: Michael Glaesemann Subject: Re: increment the primary key value without using sequences Date: Sun, 29 Jul 2007 08:37:41 -0500 To: roopa perumalraja X-Mailer: Apple Mail (2.752.2) X-Chzlrs: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/179 X-Sequence-Number: 28914 On Jul 29, 2007, at 7:00 , roopa perumalraja wrote: > I would like to know if its possible to increment the primary key > field value of stocks table without using sequences by getting the > next value of the pk field from the sequnce table ? Why? Any other solution will cause performance issues. Michael Glaesemann grzm seespotcode net