Subject Re: [firebird-support] create generator from a select
Author Nick Upson
This will not work as an "order by" in an insert is illegal

A way would be to insert all records into the table
then run an SP which does something like this

for select cola, colb, colc from test into :a, :b, :c order by cola, colb, colc
do
begin
update test set cold = genid(my_gen, 1) where cola = :a and
colb = :b and colc = :c;
end

of you could do the entire job in one go by selecting from your
original table T1
in the correct order and doing the insert into test there using a
similiar select loop


On 10/04/07, Alejandro Garcia <aleplgr@...> wrote:
> Hi! I'm trying to create a generator:
> 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'm trying to do something like this, TEST is my new table that I've already created:
>
> INSERT INTO TEST (
> TEST.CLIENTID,
> TEST.DATE2,
> TEST.DATE1,
> GEN_ID(GENID, 1)
> )
> SELECT T1.CLIENTID,
> T1.DATA2,
> T1.DATA1
> FROM
> T1
> WHERE
> CONDITIONS
> ORDER BY
> T1.CLIENTID,T1.DATA1
>
>
>
>
>
> ---------------------------------
>
> LLama Gratis a cualquier PC del Mundo.
> Llamadas a fijos y móviles desde 1 céntimo por minuto.
> http://es.voice.yahoo.com
>
> [Non-text portions of this message have been removed]
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>