Subject | Re: table insert into itself - can this be done? |
---|---|
Author | Aage Johansen |
Post date | 2011-12-14T22:16:34Z |
p51b.mustang wrote:
<<
Hi,
I am seeking advice on whether this is possible:-
insert into table_X (mydatetime, taskcode, sitecode)
Select x.mydatetime, x.taskcode, ss.sitecode
From table_X x
inner join sites ss on (ss.siteparentcode=x.sitecode)
Where (x.mydatetime between '30 nov 2010' and '1 nov 2011');
/* table_X has no keys */
In other words a table inserting into itself. Essentially for a
particular sitecode the records are duplicated for each sitecode relationship.
On the left side of my brain, I say firebird would collect all
records from the select first and then perform inserts with no problems.
On the right side, I say as records are inserted these very same
records my be gathered into the select and also be duplicated with
horrifying results.
Any thoughts would be appreciated.
with thanks in advance
David
in Luxembourg - "New features of SQL in Firebird") that this will be
(mostly?) fixed in Fb/3.0.
If you find his presentation you will see this in slides 44 onwards.
--
Aage J.
<<
Hi,
I am seeking advice on whether this is possible:-
insert into table_X (mydatetime, taskcode, sitecode)
Select x.mydatetime, x.taskcode, ss.sitecode
From table_X x
inner join sites ss on (ss.siteparentcode=x.sitecode)
Where (x.mydatetime between '30 nov 2010' and '1 nov 2011');
/* table_X has no keys */
In other words a table inserting into itself. Essentially for a
particular sitecode the records are duplicated for each sitecode relationship.
On the left side of my brain, I say firebird would collect all
records from the select first and then perform inserts with no problems.
On the right side, I say as records are inserted these very same
records my be gathered into the select and also be duplicated with
horrifying results.
Any thoughts would be appreciated.
with thanks in advance
David
>>I think Vlad Khorsun announced (in his presentation at the conference
in Luxembourg - "New features of SQL in Firebird") that this will be
(mostly?) fixed in Fb/3.0.
If you find his presentation you will see this in slides 44 onwards.
--
Aage J.