Transactions examples needed
Please add some examples with transactions. I get command out of sync error
the only way for me is to avoid transactions and prepare the statement list, one per line in a variable and then:
mySQLstatements.each_line do |line|
client.query(line)
end
but I risk that someone else execute a query between statements.
You forgot to write versions and that error is so short? When did you get it? Details are important, so write them.
Code is like this:
tMaxCrmid = 0
tSQL = "start transaction; \n"
results_codici.each do |row|
tMaxCrmid = tMaxCrmid + 1
cprod = row["codice"]
tSQL << "INSERT into table1 (cola,colb,colc,cold,cole) VALUES ( "
tSQL << "#{tMaxCrmid},'Products',now(),now(),'#{cprod}');\n"
tSQL << "INSERT into table2 (cola,colb,colc,cold) VALUES ("
tSQL << "#{tMaxCrmid}, '#{cprod}', 0,now() ) ;\n"
end
tSQL << "COMMIT;"
client.query(tSQL)
It generates more than 100 lines in tSQL variable.
There's a garbage collection problem. I started investigating a solution a few years ago in https://github.com/brianmario/mysql2/pull/1048 but never got that PR finished.