Skip to content
Advertisement

How to create a .txt file and insert data into it in SQL?

I’m learning about triggers and events and I have the following issue:

I have created a trigger that inserts data in a table called updated_movie when an update is made in table movie.

Also, I want to create an event that executes every day at 11:30am that creates a text file with some data from the table updated_movie. I have made this so far:

This is the event I want to be executed every day. How can I create a text file into the path declared in the event with the same file name as the declared variable nameFile?

Also, procedure copyIntoFile looks like this so far:

How can I make it so I can insert some data into the text field?

In case that you are wondering, table updated_movie just have one varchar(255) field.

Advertisement

Answer

Modify conditions, output expressions, add export specifications if needed.

Check secure_file_priv setting and related ones, and justify destination forder accordingly. FILE privilege needed.

PS. BEGIN-END, DELIMITER, etc. – are excess.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement