How to create a trigger that loopes in MySQL

0

In my database I have the following tables: module_user, module and control.

I need to create a trigger that is executed after an insert in the table user_group.

This trigger should make a select in the module table and create a loop that traverses each row returned from this select, inside the loop make an insert in the control table, containing the id of the group that just was inserted and the id of the module that will be returned in the current line of the select.

Is it possible to do this?

    
asked by anonymous 17.06.2017 / 19:38

1 answer

0

I found a way to solve, for this it is necessary to use cursors in MySQL, from them it is possible to iterate under results of queries.

Reference Manual for Cursors in My SQL: MySQL Cursors

    
18.06.2017 / 18:34