Subject Re: [firebird-support] insert into tab1 (...) select (...) from tab1
Author Sándor Tamás (HostWare Kft.)
For tables like this, you definitely should have a primary key, like an auto
increment field. (By the way, when do you need duplicated datas to be in a
table without unique identifier? )

With that, you can read the last value, and do a select where PRIMARY_ID <=
MAX_VALUE.
(in fact, it will be faster than the null compare for temp_field)

SanTa

----- Original Message -----
From: "tomjanczkadao" <tomjancz@...>
To: <firebird-support@yahoogroups.com>
Sent: Tuesday, September 15, 2009 9:48 AM
Subject: [firebird-support] insert into tab1 (...) select (...) from tab1


> Hi
> I sometimes need to duplicate data in a table. I use
> "insert into tab1 (...) select (...) from tab1" syntax.
> The problem is, that it result in infinite loop, so it selects records
> that have been just inserted and inserts it again and so on.
> Is it correct behaviour?
> I expected, that select takes a snapshot of table content and inserts it
> once.
> My temporary solution is to add temp_field, fill existing records with
> some value, and add "where temp_field is null" to select clause.
>
> Regards, Tomek
>
>
>
> ------------------------------------
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> 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
>
>
>