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 7768713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:59:05+00:00 2026-06-01T15:59:05+00:00

I’m using MySQL and InnoDB and I’ve run into some problem recently. This is

  • 0

I’m using MySQL and InnoDB and I’ve run into some problem recently.

This is the statement I’m trying to run (I’ve removed some personal details):

START TRANSACTION;

SET FOREIGN_KEY_CHECKS = 0;
INSERT INTO zdb_user (U_DateStart, U_Main_Adres_ID)
VALUES ('2012-04-08', 0);
SET FOREIGN_KEY_CHECKS = 1;

SET @newUID = LAST_INSERT_ID();

INSERT INTO zdb_adres (A_User_ID, A_Zipcode, A_Number)
VALUES (@newUID, '1234AB', 12);

UPDATE zdb_user SET U_Main_Adres_ID = LAST_INSERT_ID() WHERE User_ID = @newUID;

COMMIT;

The problem is that I’m using a ‘circle’ foreign key reference. I bypassed that now by disabling the key checks.

zdb_adres.A_User_ID requires a valid User_ID. And zdb_user.U_Main_Adres_ID requires a valid Adres_ID, but I don’t have either one. Now this all works ‘okay’ as long as the record in zdb_user can actually be created. But there are several constraints on it that could cause it to not be created.

I thought that on an error the transaction would halt, but after running a simple test I discovered this isn’t true at all. Therefore I went googling and I found several solutions like:

DECLARE EXIT HANDLER FOR SQLEXCEPTION, SQLWARNING, NOT FOUND BEGIN ROLLBACK; CALL ERROR_ROLLBACK_OCCURRED; END;

Too bad it doesn’t work, I’m receiving a syntax error when I add it after the START TRANSACTION;:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE EXIT HANDLER FOR SQLEXCEPTION, SQLWARNING, NOT FOUND BEGIN ROLLBACK' at line 1

Does anybody know what the problem is?

  • 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-06-01T15:59:06+00:00Added an answer on June 1, 2026 at 3:59 pm

    The only way to get rid of disabling of foreign key checks is by making U_Main_Adres nullable.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I'm trying to create an if statement in PHP that prevents a single post
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.