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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:33:06+00:00 2026-06-05T03:33:06+00:00

DROP FUNCTION IF EXISTS my_func; DELIMITER || CREATE FUNCTION my_func(arg_id INT) RETURNS VARCHAR(200) BEGIN

  • 0
DROP FUNCTION IF EXISTS my_func;
DELIMITER ||
CREATE FUNCTION my_func(arg_id INT) RETURNS VARCHAR(200)
BEGIN
    DECLARE local_id INT;
    DECLARE local_name VARCHAR(200);
    START TRANSACTION; /* <-- this is allowed */
        SELECT      id, name
            INTO    local_id, local_name
            FROM    table
            WHERE   id = arg_id
            FOR UPDATE;
        SELECT my_other_function(local_name) INTO local_name;
        UPDATE table SET name = local_name;
    COMMIT; /* <-- this is not allowed
        and yields an "Explicit or
        implicit commit is not
        allowed..." error */
    RETURN local_name;
END||
DELIMITER ;

Are return statements implicit commits?

How are you supposed to ensure that a certain function runs as a transaction?

Wrap it in a transaction?

START TRANSACTION;
    SELECT my_func(33); /* <-- no transaction statements inside the function */
COMMIT;

Start the transaction inside the function and commit?

SELECT my_func(33); /* <-- contains only the START TRANSACTION line */
COMMIT;

Also i’ve researched the issue and found some info that said something along the lines of: “statements in stored functions are not guaranteed to be executed in the declared order which can make binary logging (and implicitly replication) inconsistent”.

  • 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-05T03:33:07+00:00Added an answer on June 5, 2026 at 3:33 am

    I had to use this before and it worked for me:

    Option 1

    SET autocommit = {0 | 1}
    

    After you have completed what you want to do, you can re-enable it or call an explicit commit.

    Option 2
    To disable autocommit mode implicitly for a single series of statements, use the START TRANSACTION statement:

    START TRANSACTION;
    SELECT @A:=SUM(salary) FROM table1 WHERE type=1;
    UPDATE table2 SET summary=@A WHERE type=1;
    COMMIT;
    

    I got this from the mysql website itself – MySQL


    For your situation, I would think that setting autocommit to false before the function would do the trick (starting a transaction is the same thing if you look at the description of it above). That way, during the transaction, your function, it doesn’t autcommit.

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

Sidebar

Related Questions

I've this function: DROP FUNCTION IF EXISTS find_linkid; DELIMITER // CREATE FUNCTION `find_linkid`(pc1 VARCHAR(50)
function populateDB(tx) { tx.executeSql('DROP TABLE IF EXISTS test'); tx.executeSql('CREATE TABLE IF NOT EXISTS test(course
I'm writing a simple MySQL stored procedure: DELIMITER $ DROP PROCEDURE IF EXISTS GetUserByCaseId
$(item).droppable({ drop: function(event, ui) { console.log(triggered); } }); I try to call drop by
When I set disabled on a drop : $( myDiv ).droppable( { drop: function(
I have the following jQuery: $(document).ready(function () { $(.element).draggable(); $(.element).droppable({ drop: function () {
$(#b).draggable(); $(#map_canvas).droppable({ drop: function() { //alert('dropped'); aFn(); }
I'm trying to understand why $('#title').replaceWith('ha'); will work outside the drop: function(event, ui) {}
I've dug the manual and tried extensivelly to drop the extra function(){...} call after
var UI$Contract$ddlForm_change = function() { //'this' is currently the drop down that fires the

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.