For statement in Firebird to Loop statement in Mysql -
i have sql code in firebird , works well
set term !! ; execute block declare variable vtable_name varchar(31); begin select table_name mytables :vtable_name execute statement 'drop table ' || :vtable_name || ';'; end!! set term ; !!
now i'm trying 1 similar in mysql database. reading mysql manual read loop satement , while statement.
this mysql code, don't works
while (set @vtable_name = (select table_name mytables)) begin drop table @vtable_name; end; end while;
your issue "(select table_name mytables)" statment homecoming result set , assign entire result set variable. sec issue drop / select statement not allow dynamic table name / column names.
you can utilize dynamic sql, see demo: http://sqlfiddle.com/#!2/cf278/1
and use variable table name in mysql sproc
mysql firebird
No comments:
Post a Comment