Skip to main content
Participant
July 24, 2012
Answered

<Cfquery> insert into generates duble entry

  • July 24, 2012
  • 2 replies
  • 1471 views

Does anyone know, why an “ insert into “ could generates a double entry on a SQL table?

I use it in other routines and programs with success, but in this specific program, it’s being defiant, generating two entry with the same content.

Please, let me know if someone has the same problem or what I’m doing wrong?

I appreciate any help.

This topic has been closed for replies.
Correct answer aijr

Dan,

Thanks, for your help, I'm using something similar to work around, but I'd to know why this is happening, it is true that I' m a novice here, but it is the 1st time I'm facing this kind of problem with insert. Do you have any idea what is causing this behavior?

Again thanks,

2 replies

aijrAuthorCorrect answer
Participant
July 31, 2012

Dan,

Thanks, for your help, I'm using something similar to work around, but I'd to know why this is happening, it is true that I' m a novice here, but it is the 1st time I'm facing this kind of problem with insert. Do you have any idea what is causing this behavior?

Again thanks,

Legend
July 31, 2012

The query itself is not causing the issue, you need to step back and figure out what is calling this code twice. In my experience, the most likely cause is someone double clicking on a link or button and the page executing this code is being called twice.

aijrAuthor
Participant
August 9, 2012

As I told you, I find a way to work around, but it is a far cry from a clean solution, I will review my code paying a special attention to these points, thanks for the tips.

Inspiring
July 24, 2012

There are many possible reasons.  I try to prevent it like this:

insert into myTable

(list_of_fields)

select list_of_values

where not exists

(subquery to identify exisitng records)