MySQL procedure Modes

MySQL procedure Modes

IN parameter

It is the default mode. It takes a parameter as input, such as an attribute. When we define it, the calling program has to pass an argument to the stored procedure. This parameter’s value is always protected.

OUT parameters

It is used to pass a parameter as output. Its value can be changed inside the stored procedure, and the changed (new) value is passed back to the calling program. It is noted that a procedure cannot access the OUT parameter’s initial value when it starts.

INOUT parameters

It is a combination of IN and OUT parameters. It means the calling program can pass the argument, and the procedure can modify the INOUT parameter, and then passes the new value back to the calling program.

Stored Procedure without Parameter

DELIMITER &&  
CREATE PROCEDURE get_merit_student ()  
BEGIN  
    SELECT * FROM studentregister WHERE  grade="b.tech";  
END &&  
DELIMITER ;

Execution
call get_merit_student() 



Stored Procedure with IN Parameter

DELIMITER &&  
CREATE PROCEDURE get_merit_student1 (IN highgrade varchar(100))  
BEGIN  
    SELECT * FROM studentregister WHERE  grade=highgrade;  
END &&  
DELIMITER

Execution
call get_merit_student1("b.tech")

Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

*

*