Stored procedure does not return a value using RETURN statement. But CALL statement gets the values of stored procedures using OUT and INOUT parameters. Below examples shows returning values:
DELIMITER //
CREATE PROCEDURE getNames(OUT name VARCHAR(25), INOUT salary INT)
BEGIN
SELECT empNames INTO name FROM tblNames WHERE salary=1000;
SET salary = salary + 1000;
END
DELIMITER ;
Before calling the procedure INOUT parameter is initialized.
SET @sal = 1000;
CALL getNames(@name, @sal);
SELECT @name, @sal;
This gives the output:
David 2000
Comments
No comments have been made yet.
Please login to leave a comment. Login now