View Single Post
  #3  
Old 2nd December 2014, 09:19 AM
Thorsten Engler [NDA]
 
Posts: n/a
Default Re: INSERT INTO add each record twice

I'm pretty sure that there is nothing wrong with the server that makes it copy
every record twice, much more likely is that you are doing something on the
client side which results in the query being send to the server for execution
twice.

e.g. you might have the "ActiveRuntime" property on the query set to true,
which results in the query being executed the first time when the containing
form/data module is created, and then you are calling Execute or Open on the
query object again later.

Or other such issues.

kts wrote:

>
> Hi,
>
> I am using INSERT INTO from TnxQuery to copy from one table to another.
> The result always add each record twice. When I execute the exact same
> SQL INSERT INTO queries from Nexus DB Enterprise Manager(on the same
> tables created from code), it works without adding the records twice. Is
> this a bug, or is it my setup of the nexus components that is wrong..?
>
> I avoided the problem for some time by replacing the following query:
>
>
> Code:
> --------------------
> INSERT INTO DestTable SELECT * FROM SrcTable
> --------------------
>
> with:
>
> Code:
> --------------------
> INSERT INTO DestTable SELECT * FROM SrcTable t1 WHERE NOT EXISTS(SELECT
> ID FROM DestTable t2 WHERE t2.ID = t1.aID) --------------------
>
>
> But now I need more advance INSERT INTO queries and cannot do this to
> avoid the problem.
>
> I am using NexusDB: 4,0006 Release (C20) 32bit on RAD Studio XE6 (C++),
> Windows 8.1.