Subject Re: [firebird-support] Bug in Firebird
Author Stanislav Golubtsov
Offcourse, problem can be avoided if you use integer
primary keys:

create table temp_table (ID integer not null, a
integer, primary key (ID));
create generator temp_gen;
insert into temp_table(gen_id(temp_gen, 1), 1);
insert into temp_table(gen_id(temp_gen, 1), 2);
insert into temp_table(gen_id(temp_gen, 1), 3);

then something similar to:
select max(ID) from temp_table into :max_id;
insert into temp_table select gen_id(temp_gen, 1), a
from temp_table where ID<=:max_id;

Another general solution for FireBird could be:
create table temp_table (a integer);
insert into temp_table values(1);
insert into temp_table values(2);
insert into temp_table values(3);

Then something similar to:
select count(*) from temp_table into :temp_count;
insert into temp_table select first :temp_count a from
temp_table;

With the last statement like:
insert into temp_table select first 1000 a from
temp_table;

you can generate some records...
Cool, ;)

--
Stanislav Golubtsov

--- Alexandre Benson Smith
<iblist@...> wrote:

> sgaflv wrote:
>
> >Hello,
> >I've experimented with Firebird and I wonder, if
> this could be a bug:
> >
> >create table temp_table ( a integer);
> >insert into temp_table values(1);
> >insert into temp_table values(2);
> >insert into temp_table values(3);
> >insert into temp_table select a from temp_table;
> >
> >After the last statement server hangs in endless
> loop and DB grows all
> >the time.
> >
> >I have tested this on FireBird 1.5.2., and I wonder
> if something
> >similar could happen in some complex inserts.
> >
> >
> The new inserted rows will be inserted againg and
> again in a endless loop.
>
> I think you should restrict the last insert
> statement in some form like
>
> insert into temp_table select a from temp_table
> where a <= 3;
>
> see you !
>
> --
>
> Alexandre Benson Smith
> Development
> THOR Software e Comercial Ltda.
> Santo Andre - Sao Paulo - Brazil
> www.thorsoftware.com.br
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.344 / Virus Database: 267.11.5/110 -
> Release Date: 22/09/2005
>
>




__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com