#1  
Old 2nd December 2014, 06:27 AM
kts kts is offline
Junior Member
 
Join Date: May 2013
Posts: 12
Default INSERT INTO add each record twice

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.
  #2  
Old 2nd December 2014, 07:54 AM
Rodrigo Gomez [NDX]
 
Posts: n/a
Default Re: INSERT INTO add each record twice

Without seeing the actual code that does the work, it's impossible to know if there is
something wrong with it.

As you said, running the query within EM works fine, so one could assume the SQL script is
working fine, but that's the only thing that you posted

--
Rodrigo Gómez [NDX]
México, GMT-6
  #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.


  #4  
Old 2nd December 2014, 09:41 AM
kts kts is offline
Junior Member
 
Join Date: May 2013
Posts: 12
Default Problem found with my code

I was running both ExecSQL and Open on the TnxQuery. Sorry for this mistake, I should have seen this.

Thanks for both of your answers, and sorry for the inconvenience.
  #5  
Old 2nd December 2014, 10:51 AM
Thorsten Engler [NDA]
 
Posts: n/a
Default Re: INSERT INTO add each record twice

No worries, glad you found it.

kts wrote:

>
> I was running both ExecSQL and Open on the TnxQuery. Sorry for this
> mistake, I should have seen this.
>
> Thanks for both of your answers, and sorry for the inconvenience.




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lock timeout on insert record oliver nexusdb.public.support 2 23rd April 2008 03:20 PM
Again: Insert, Add Record Fails via VB6 Gary Naughton nexusdb.public.support.odbc 3 2nd October 2007 10:18 PM
Re:Again: Insert, Add Record Fails via VB6 Gary Naughton nexusdb.public.support.odbc 0 26th September 2007 07:11 PM
V1.07 Insert & Add Record Failure Gary Naughton nexusdb.public.support.odbc 0 15th September 2007 09:32 PM
Insert Record without Dataset Overhead Paul Fraser nexusdb.public.support 18 20th April 2004 06:55 AM


All times are GMT +11. The time now is 11:38 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.