Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7083955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:14:31+00:00 2026-05-28T07:14:31+00:00

Ok, I have an update function with a weird twist. Due to the nature

  • 0

Ok, I have an update function with a weird twist. Due to the nature of the structure, I run a delete query then insert query, rather than an actual “Update” query. They are specifically run in that order so that the new items inserted are not deleted. Essentially, items are deleted by an attribute id that matches in the insert query. Since the attribute is not a primary index, “ON DUPLICATE KEY UPDATE” is not working.

So here’s the dilemma. During development and testing, The delete query will run without fail, but if I’m screwing around with the input for the INSERT query and it fails, then the DATA has been deleted without being reinserted, which means regenerating new test data, and even worse, if it fails in production, then the user will lose everything they were working on.

So, I know MySQL validates a query before it is actually run, so is it possible to make sure the INSERT query validates before running the DELETE query?

<cfquery name="delete" datasource="DSOURCE">
  DELETE FROM table
  WHERE colorid = 12
</cfquery>

<!--- check this query first before running delete --->
<cfquery name="insert" datasource="DSOURCE">
  INSERT INTO table (Name, ColorID)
  VALUES ("tom", 12)
</cfquery>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:14:32+00:00Added an answer on May 28, 2026 at 7:14 am

    You have 2 problems.

    Since the attribute is not a primary index, “ON DUPLICATE KEY UPDATE”
    is not working.

    Attribute doesn’t have to be PRIMARY KEY. It’s sufficient if it’s defined as UNIQUE KEY, which you can do without penalties.

    And number two: if you want to execute a series of queries in sequence, with ALL of them being successful and none failing – the term is transaction. Either all succeed or nothing happens. Google about MySQL transactions to get better overview of how to use them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question regarding an update function I created... CREATE OR REPLACE FUNCTION
I have a base class Foo that has an Update() function, which I want
I have the following javascript code, which loads without error, however the update function
I have a function that's called hundreds of thousands of times per update, and
Update 2 : So I never have used the debug function in firebug, but
I have a PL/SQL function (running on Oracle 10g) in which I update some
How can I update a variable outside of a function? For example I have
I have an if statement that needs to look like this: UPDATE $(input#textbox).keypress(function(e){ key==e.which;
I'm getting an weird error using queues/multiprocessing. I basically have a function that takes
I have this function in my Javascript Code that updates html fields with their

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.