🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #897

Re: create generator from a select

#897
From: Bill Todd
Date: Tue, 10 Apr 2007 16:27
24 lines
1937 bytes
aleplgr wrote:

> 
> Hi! I have a table with 80 columns, I need to select 3 of them:
> CLIENTID, DATE1 and DATE2 and order them by CLIENTID, DATE1   and
> then create another column that is a sequencial number (a generator)
> that reflects that order.  I need this to be a new table because I've
> done a stored procedure assuming that I have this 4 columns table
> which one of them is a generator.  I can only add a generator in an
> INSERT sentence but I can't INSERT in order because IB 7.5 does not
> let me do it so I don't know how to add a generator in the order I
> need...

I assume you are using a temporary table and putting the data into the
table with and INSERT INTO...SELECT...FROM statement. Is this correct?

Does the sequential number have to start with 1?

You could write a stored procedure that inserts the data then use a FOR
SELECT statment to loop through the records and update the sequential
number field using an integer variable as the counter.

-- 
Bill Todd (TeamB)
Technical Details
Message-ID: <461bace2$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <461b53cd$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,de71095c7084a322
X-Google-Attributes: gid114a0e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Bill Todd" <no@no.com>
Subject: Re: create generator from a select
Newsgroups: borland.public.interbase.sql
References:  <461b53cd$1@newsgroups.borland.com>
Organization: The Database Group, Inc.
User-Agent: XanaNews/1.18.1.6
X-Face: ":yn4zt^A_dn>6~{YJmu^B\'4w)e:apPM\VC=Dvf&*tASxX9|BYczkFd$xr.$vNSZ[3Uobr p]c4\+\l){!WQI.$]veP({HLd;CDYH?iN
NNTP-Posting-Host: 216.207.211.19
Message-ID: <461bace2$1@newsgroups.borland.com>
Date: 10 Apr 2007 08:27:30 -0800
X-Trace: newsgroups.borland.com 1176218850 216.207.211.19 (10 Apr 2007 08:27:30 -0800)
Lines: 24
X-Authenticated-User: btodd
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail