1

This has to be simple and I am just missing it. I am trying to run a stored procedure like this;

DELIMITER $$
DROP PROCEDURE IF EXISTS Testing$$
CREATE  PROCEDURE `Testing`(out d varchar(10))
BEGIN
  select @v1 =  'Value 1';
  select @v2 =  'Value 2';
  select @v3 =  'Value 3';

  set d = @v1;
END$$

DELIMITER ;


call Testing(@d);
select d;

The problem is that when runs it returns

enter image description here

This makes no sense to me. Sorry for the simple question trying to convert a MS SQL DB to MySQL.

2 Answers 2

2

Mysql is a bit quirky in SELECT,this statement

select @v1 =  'Value 1';

is in fact,a comparison;it compares @v1 which is by default NULL to value 1,which will return null.If you want to assign a value use :=

select @v1 :=  'Value 1';

Or,use SET;

SET @v1 =  'Value 1';
Sign up to request clarification or add additional context in comments.

Comments

1

As i have tested @d is not any variable in your code which you have used to take output value from procedure.

but your last select @v3 = 'Value 3' inside procedure is working as an output to console. as you can see output is null but the column name is select @v3 = 'Value 3' not output of the procedure in your output window.

Hope it is cleared.

Comments

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.