I have MySQLvariable
@query = CONCAT('INSERT INTO history VALUES (',1,',',50,',UTC_TIMESTAMP()');
I want to execute the insert statement present in a variable.
You must first prepare the statement using PREPARE , and then use EXECUTE
PREPARE
EXECUTE
See here: http://dev.mysql.com/doc/refman/5.0/en/sql-syntax-prepared-statements.html
Sort of:
SET @query = CONCAT("INSERT INTO history VALUES (",1,",",50,",UTC_TIMESTAMP()"); PREPARE stmt1 FROM @query; EXECUTE stmt1; DEALLOCATE PREPARE stmt1;
Set @query = CONCAT("INSERT INTO history VALUES (",1,",",50,",UTC_TIMESTAMP()");
and then
PREPARE stmt_name FROM @query
and finally
EXECUTE stmt_name
delete CONCAT (), it does nothing but generate an error, as it tries to combine the string with nothing else.
Source: https://habr.com/ru/post/913028/More articles:dbExpress "Record not found or modified by another user" - delphiHow to access ValueStack objects in a Struts iterator? - javaCakephp ClassRegistry :: init at boot - cakephpWhere are all the possible locations of the UninstallString registry entries? - uninstallif else if else in a prolog similar to C / C ++ - prologString truncation when passing to ClientDataset - delphiWhy use an empty abstract class instead of an interface? - javaHow can I parse an H264 file and frames - c ++How does `if (Test-Path ...)` actually work? - syntaxhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/913033/how-to-add-some-prebuild-steps-to-jenkins&usg=ALkJrhgMv50NjiMAvsgPC6LWyGOWfse4JQAll Articles