SQL Procedure error in printing statement - mysql

Delimiter $$;
create procedure greetings()
dbms_output.put_line('Hello'); $$
This gives the following error:
ERROR 1064 (42000): 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 '.put_line('Hello')' at line 1
Any solutions?

MySQL does not provide dbms_output.put_line().
Instead of that you can simply try below code in your procedure.
SELECT 'Hello';

Related

MySQL 8: Alter definer of stored procedure

In versions of MySQL prior to 8, altering the definer of a stored procedure is possible by manipulating the mysql.proc table. This table was removed in 8 and replaced by the data dictionary. It looks like the definer can be modified using ALTER PROCEDURE, but for the life of me I cannot get the syntax specified to work.
mysql> alter procedure refresh_basic sql security definer=`foo`#`127.0.0.1`;
ERROR 1064 (42000): 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 '=`foo`#`127.0.0.1`' at line 1
mysql> alter procedure refresh_basic sql security definer='foo#127.0.0.1';
ERROR 1064 (42000): 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 '='foo#127.0.0.1'' at line 1
I also tried both of the above without using =, but got similar errors. How does one actually do this? Thanks!

MySQL throws an error but still executes the query

I am trying to execute this query in MySQL:
INSERT INTO eier_borettslag(bsID, eierID)
VALUES(1, 1);
MySQL prompts me with this error message:
1064 - 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 '' at line 1
Could someone help me identify the syntax error and explain why the query gets executed even though the syntax is wrong?

I am trying to insert into a table using "&" operator in MySql

I am using Server version: 5.6.26 MySQL Community Server (GPL).I am trying to insert into subodh table using & operator using following query
insert into subodh values(&date_of_birth,&name,&age,&qualification,&id);
but it is showing the following error
ERROR 1064 (42000): 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 '&date
_of_birth,&name,&age,&qualification,&id)' at line 1
please help me.
Thanks

MySQL update Trigger to update data table value After Insert on another table

I have been stumbling on writing some an MySQL trigger and was hopping someone could help me find the most elegant solution to solve my issue. I have Looked many places and cannot seem to find where the bug is in this code. I also tried not adjusting the delimiter as it seems to create problems I am able to create a trigger without setting the delimiter if I replace the update statement by something else.
The code I have is:
USE MyTable
DELIMITER //
--Trigger to update Scheduling 'Status' and 'Retries' values
CREATE TRIGGER `Scheduling-Updatde_After_Result-Insert`
AFTER INSERT ON Results
FOR EACH ROW BEGIN
UPDATE `Scheduling`
SET
Running = FALSE,
Retries = Retries + 1
WHERE ID = NEW.ID;
END//
DELIMITER ;
I get the following errors:
18:03:25 [DELIMITER - 0 row(s), 0.000 secs] [Error Code: 1064, SQL State: 42000] 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
CREATE TRIGGER acapella.Scheduling-Updatde_After_Result-Insert
' at line 1
Code: 1064 SQL State: 42000 --- 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
CREATE TRIGGER Scheduling-Updatde_After_Result-Insert
' at line 1
18:03:25 [END - 0 row(s), 0.000 secs] [Error Code: 1064, SQL State: 42000] 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 'END
DELIMITER' at line 1
Code: 1064 SQL State: 42000 --- 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 'END
DELIMITER' at line 1

Cannot drop procedure with weird names in MySQL

In MySQL, I cannot drop procedure mobisys_mtly_db`cms_partner_add_or_edit because it has symbol `.
Detailed example in console
mysql> DROP PROCEDURE mobisys_mtly_db`cms_partner_add_or_edit;
`> `
-> ;
ERROR 1064 (42000): 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 'cms_partner_add_or_edit; ' at line 1
mysql> DROP PROCEDURE "mobisys_mtly_db\`cms_partner_add_or_edit";
ERROR 1064 (42000): 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 '"mobisys_mtly_db`cms_partner_add_or_edit"' at line 1
The following do not work:
DROP PROCEDURE mobisys_mtly_db`cms_partner_add_or_edit
DROP PROCEDURE mobisys_mtly_db\`cms_partner_add_or_edit
DROP PROCEDURE 'mobisys_mtly_db`cms_partner_add_or_edit'
DROP PROCEDURE 'mobisys_mtly_db\`cms_partner_add_or_edit'
DROP PROCEDURE "mobisys_mtly_db`cms_partner_add_or_edit"
DROP PROCEDURE "mobisys_mtly_db\`cms_partner_add_or_edit"
You should use this query -
DROP PROCEDURE `mobisys_mtly_db``cms_partner_add_or_edit`
Documentation page - Schema Object Names.