E
E
Eugene Ordinary2017-04-26 11:18:26
JavaScript
Eugene Ordinary, 2017-04-26 11:18:26

Is executing a stored procedure in MySQL one transaction?

Is executing a stored procedure in MySQL one transaction? In other words, can someone change the data in the tables it works with while the procedure is running? Whether it is necessary to do LOCK TABLE in procedure?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Anton Spirin, 2018-05-23
@RushV

If you need to perform some action every second, then it is more correct to use setInterval :

function startTimer(secs) {
  var i = 0;
  var timer = document.getElementById('timer');

  var interval = setInterval(function() {
    if (++i >= secs) {
      clearInterval(interval);
      timer.innerHTML = 'Done!';
    } else {
      ++timer.innerHTML;
    }
  }, 1000);
}

startTimer(10);
Demo.
If you don’t need to perform an action every second, then it’s more rational to set one timeout for the entire duration:
function startTimer(secs) {
  var timer = document.getElementById('timer');
  setTimeout(function() {
      timer.innerHTML = 'Done!';
  }, secs * 1000);
}

startTimer(10);
Demo.

T
TerNik, 2018-05-23
@TerNik

You are not using setTimeout
correctly Look at what should be passed in the parameters, and what you have.

P
Polina, 2018-05-23
@paulinekorkina

First, you are trying to call a function within itself. Secondly, the syntax of the if condition is incorrect.
If I understood the task correctly, then it should look like this:

function timer() { //Объявили функцию
  var s = Number(document.getElementById("timer").innerHTML); //Получили число из дива
  s++; //Увеличили на единичку
  
  if (s < 10) { //Если число меньше десяти
    document.getElementById("timer").innerHTML = s; //В див выведем новое значение s
  } else { //Если нет, т.е. если число меньше 10, то напишем 12
    document.write("12");
  }
}
//Подождем 1000 мс после загрузки страницы и вызовем функцию
setTimeout(timer, 1000);

Working example:
https://jsfiddle.net/gbq1Lkwv/2/

A
Alexey Ukolov, 2018-05-23
@alexey-m-ukolov

https://jsfiddle.net/d63me5rg/

R
Rsa97, 2017-04-26
@Rsa97

No, executing a stored procedure is not an atomic operation.
Transactions (BEGIN/COMMIT/ROLLBACK) can be used in a procedure, table locks (LOCK TABLE) cannot.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question