* * *

Author Topic: MySQL Rename problem  (Read 1351 times)

xaver13

  • Jr. Member
  • **
  • Posts: 79
MySQL Rename problem
« on: October 14, 2016, 08:37:05 pm »
Hello,
DROP,SELECT,INSERT are working. But when I want:

  FormZadavani.Query.SQL.Text := 'RENAME TABLE vyr1  TO vyr1old, vyr1new TO vyr1';
  FormZadavani.Query.ExecSQL;

command ExecSQL never ends, unless I stopped debugging. After that RENAME is done.
(Problem is not that I rename 2 tables in one command, with only one table to rename is the problem the same.)

Maybe I forgot something? Thank you very much for help!
--
Jiri Cvrk

rvk

  • Hero Member
  • *****
  • Posts: 2974
Re: MySQL Rename problem
« Reply #1 on: October 14, 2016, 10:04:06 pm »
Which MySQL version are you using? The latest?

Also, there can't be any transactions active when issuing a rename command.
Are you absolutely sure this is the first command you use after making the connection with the database. And are you also absolutely sure nobody else (or machine) is using the database at the moment?

xaver13

  • Jr. Member
  • **
  • Posts: 79
Re: MySQL Rename problem
« Reply #2 on: October 15, 2016, 09:17:34 am »
you must be true, when I move this rename piece of code to a standalone application it works.

Thank you, I am searching  ;)
--
Jiri Cvrk

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5875
Re: MySQL Rename problem
« Reply #3 on: October 15, 2016, 03:13:46 pm »
Use executedirect for DDL/tables manipulation. This doesn't parse the SQL in sqldb internally.


See also:

http://wiki.freepascal.org/SqlDBHowto#How_to_execute_direct_queries.2Fmake_a_table.3F

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus