Im trying to convert multivalued column in Table A into rows of Table B(The data type of the column is varchar). For ex:
Table A
id value
ae [1,2,4,5]
ac [1,6]
Table B
id value
ae 1
ae 2
ae 4
ae 5
ac 1
ac 6
I wrote an after insert trigger on Table A
CREATE DEFINER = CURRENT_USER TRIGGER `p`.`table_A_AFTER_INSERT` AFTER INSERT ON `table_A` FOR
EACH ROW
BEGIN
drop temporary table if exists p.temp;
create temporary table p.temp( val char(255) );
set @sql = concat("insert into p.test (val) values ('", replace(( selectgroup_concat(distinct
txt) as data from pmo.t), ",", "'),('"),"');");
prepare stmt1 from @sql;
execute stmt1;
insert into p.table_B (val )
select val
from p.temp;
END
I encounter error
Error 1336: Dynamic SQL is not allowed in stored function or trigger SQL Statement
What is the way to work around this?