Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 2237A9FC219 for ; Fri, 23 Feb 2007 15:32:49 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 24002-05 for ; Fri, 23 Feb 2007 15:32:45 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id A4B939FC1F2 for ; Fri, 23 Feb 2007 15:32:45 -0400 (AST) Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; Fri, 23 Feb 2007 19:32:44 +0000 Received: from state.g2switchworks.com by mail.g2switchworks.com; 23 Feb 2007 13:32:44 -0600 Subject: Re: how do I to generate a sequence Range or Set of integer constants From: Scott Marlowe To: Stefan Becker Cc: pgsql-sql@postgresql.org In-Reply-To: <200702231925.35411.pgsql@yukonho.de> References: <200702231925.35411.pgsql@yukonho.de> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1172259164.20651.9.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Fri, 23 Feb 2007 13:32:44 -0600 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.019 tagged_above=0 required=5 tests=AWL, BAYES_50, SPF_PASS, UNPARSEABLE_RELAY X-Spam-Level: X-Archive-Number: 200702/240 X-Sequence-Number: 27574 On Fri, 2007-02-23 at 12:25, Stefan Becker wrote: > dear SQL friends, > > What I want to do might be done differantly. Right now I can't > think of another solution other than a select statement > > I would like to create a sequence range of integer constants. Join > this sequence against a ID Range in a database and look for missing > Id's. > > Another application for this would be to simply populate a database with > say 1000..9999 Records.... > > Now: Is there a syntax that allows for the following..... > > create table XX (id int); > insert into XX (select xx from "1 to 1000" of integers) > > or... > > select IntSeq.MissingValues, x.UniqIntId,x.A,x.B,x.C, > from MyDataTable x > left outer join > ( > select MissingValues from "1 to 1000" of integers > ) IntSeq on MissingValues=x.UniqIntId select * from generate_series(1,1000);