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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:07:46+00:00 2026-05-28T08:07:46+00:00

Preface: I have a MS Access 2010 front end running against a MySQL back

  • 0

Preface:

I have a MS Access 2010 front end running against a MySQL back end.

I have companies that have sites and employees that are linked to those company sites and want to allow the users to delete the sites if required BUT this would only be possible if there where no employees linked to those sites which is fine as the MySQL foreign keys enforce this anyway so if I try to do a delete on a site and there are still employees associated with that site it errors.

BUT the only way I have to test to see if the delete is valid (will work) is to try and delete it BUT then it will do the delete IF it is OK. But I want to be able to test if the delete is possible before doing the delete so I can work out if all the other code that also occurs just before a delete should run.

I thought about using “Start Transaction; ….. Rollback;” but that can’t be done from access to MySQL in any way I can come up with. I have tried:

1) Passthrough Query (but apparently you can only pass one query per operation so I can pass the delete but not the “Start Transaction;” or Rollback;”) 🙁

2) Stored Procedure – Passing the delete into a stored procedure that executes it between the “Start Transaction;” and “RollBack;” like:

DELIMITER $$

CREATE DEFINER=`root`@`%` PROCEDURE `SP_TestStatementExecution`(
        IN SQLString TEXT
     )
BEGIN
    START TRANSACTION;
        SET @query := SQLString;
        PREPARE stmt FROM @query;
        EXECUTE stmt;
        DEALLOCATE PREPARE stmt;
    ROLLBACK;
END

BUT that doesn’t seem to error when it’s invalid 🙁

I would like to be able to pass in several statements in one go really so was thinking of something like this:

------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$

CREATE DEFINER=`root`@`%` PROCEDURE `SP_TestStatementsExecution`(
        IN SQLString TEXT
     )
BEGIN
    SET @Delim = ";";
    SET @Pos2 = INSTR(SUBSTRING(SQLString,@Pos1), @Delim);

    START TRANSACTION;
        WHILE @Pos2 > 0 DO
            SET @query = SUBSTRING(
                                SQLString,
                                1,
                                @Pos2
                            );

            PREPARE stmt FROM @query;
            EXECUTE stmt;
            DEALLOCATE PREPARE stmt;

            SET SQLString = SUBSTRING(SQLString,@Pos2 + 1);
            SET @Pos2 = INSTR(SUBSTRING(SQLString,1), @Delim);
        END WHILE;
    ROLLBACK;
END

BUT until I get an error to STOP the execution and return an error to access that is no good…

Question:

How can I test if a series of SQL statements will execute in MySQL without committing to the DB?

I am currently working on using Access’ Rollback with workbooks directly but would prefer to be able to do it in MySQL directly if possible

  • 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-28T08:07:47+00:00Added an answer on May 28, 2026 at 8:07 am

    The solution I went with was to use Accesses own Workspace to roll back the transaction. It wasn’t really ideal but has done the job I needed.

    The method was:

    Sub Test()
        'Create a Workspace
        Dim wrk As DAO.Workspace
        Set wrk = DBEngine(0)
    
        'Begin the transaction
        wrk.BeginTrans
            'Setup error trapping
            On Error GoTo WrkTrap
            'DO INSERTS & UPDATES HERE
            '....
            '....
        'Commit the transaction
        wrk.CommitTrans
        'Return normal error trapping
        On Error GoTo Trap
        'Do more stuff here if needed
        '...
        '...
    
    TidyUp:
        'Do tidy up here
        '...
    
        'Exit before Error Code runs
        Exit Sub
    WrkTrap:
        'Rollback the transaction
        wrk.Rollback
    Trap:
        Debug.Print "ErrorNum = '" & Err.Number & "', Desc = '" _
        & Err.Description & "'"
    
        'Do any error loggin here...
    
        'Jump to methods cleanup code
        Resume TidyUp
    End Sub
    

    Hope this helps someone else. 🙂

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

Sidebar

Related Questions

Preface I have a Access 2010 front-end with a MySQL back-end. I want to
I have to preface this with the fact that I love jQuery as a
Preface I have three tables Customers, Individuals & Companies and a customer can be
Preface: I have a rolling upgrade to SharePoint 2010 in progress for one of
I'll preface this question with the note that I have looked at this similar
To preface we have a strange requirement that all dialogs must be modeless for
Preface: I have two entities defined as a one-to-many relationship: A <<-------> B. B's
Preface: I am sure this is incredibly simple, but I have searched this site
A quick preface, I'm very comfortable in .Net, but have limited experience in c++,
Preface: I have a demo of the problem on my personal site (I hope

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.