1
USE `sakila`;
DROP procedure IF EXISTS `change_user_name`;

DELIMITER $$
USE `sakila`$$
CREATE PROCEDURE `change_user_name` (actor_id int, first_name varchar(45), last_name varchar(45))
BEGIN

UPDATE actor SET first_name='first_name', last_name='last_name' WHERE actor_id='actor_id';


END$$

DELIMITER ;

Why this procedure won't work, I don't receive any error message from mysql workbench

1
  • You have a premature DELIMITER in there,also you are using strings insted of input values and naming parameters the same as columns Commented Apr 6, 2016 at 11:11

1 Answer 1

2

I'm not sure about the DELIMITER part, but to the function it should be something like this:

CREATE PROCEDURE `change_user_name` (actor_id_in int, first_name_in varchar(45), last_name_in varchar(45))
BEGIN

UPDATE actor
SET first_name=first_name_in,
    last_name=last_name_in 
WHERE actor_id=actor_id_in;

Note that when you specify text inside two quote 'example' it will see it as a string, not a column. You only have to use (back tic/double quotes/brackets not quotes) when dealing with columns/tables that have the name of a reserved word in your DBMS

Sign up to request clarification or add additional context in comments.

3 Comments

@FAMO_php No problem, I'll appreciate an approval then.
no problem, since I am relatively new in here how to do approval? Did I do it right way for your answer?
Yes you did @FAMO_php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.