I created a simple script in MySQL
.... the idea is to create a procedure that shows the data of the last record of a specific table.
This would be the code of the script:
DROP PROCEDURE IF EXISTS mostrarUltimaAlta;
DELIMITER $$
CREATE PROCEDURE mostrarUltimaAlta ()
BEGIN
SELECT id, nombre_completo, correo FROM USUARIOS WHERE id = (select max(id));
END;
$$
DELIMITER;
The idea is to make an initial drop
to eliminate some similar procedure already created.
Then with delimiter
I create the content of script
...
during the procedure I make a select
to show the desired fields of the last inserted record.
Finally the procedure ends ...
Once I finish I save the code of the script and I leave MySQL
... and from prompt
I try to launch the script:
usuario@ubuntu: mysql -u root -p DB_MENSAJES <script.sql
But when I run it, it gives me this error:
ERROR 1064 (42000) at line 12: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1
I can not see what is wrong with the code so that the delimiter does not work ... can you help me? thanks !!