Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.9 kB
9
Indexable
Never
15/02/2024
=============================
store procedure continue:-
----------------------------------------
parameter:-
1.IN :-input 
2.OUT :- output
3.INOUT:-
-----------------------------------------------------------------------------------------------------
1 In:-
synatx:-
delimiter $$
create procedure proce_name(IN column_name datatype)
begin
statement
#select * from user where usercolumn_name=column_name ;
end $$

ex:
mysql> delimiter $$
mysql> create procedure selectuser(IN id int)
    -> begin
    -> select * from user where user_id=id;
    -> end $$

call procedure with input parameter;
syntax:-call proc_name(argument(input value))
ex:
call selectuser(101);
---------------------------------------------------------------------------------------------------------

OUT:-
syntax:-
delimiter $$
create procedure proce_name(OUT column() datatype
begin
statemenmt
#select * from user  ;
end $$

exa:- mysql> create procedure countuser(OUT count1 int)
    -> begin
    -> select count(*) into count1 from user;
    -> end$$

call procedure with out parameter

exa:- call coutuser(@count);
select @count;
---------------------------------------------

ex;-delimiter //
mysql> create procedure inoutuser(IN name varchar(222) ,OUT total int)
    -> begin
    -> select count(*) into total from user where user_name=name;
    -> end //

call procedure:-
=============
mysql> call inoutuser("prakash",@count);
    

mysql> select @count;

---------------------------------------------------------------------------------------------------------------------------
Drop procedure:
syntax: drop procedure proce_name;
 eax:-drop procedure inoutuser;


___________________________________________________________________________________________________________________________

listing store procedure:

 show procedure status where db="third";

Leave a Comment