delimiter $$
create procedure sp_emp_details(id int )
begin
declare emp_name varchar(20);
declare cur1 cursor for
select concat(firstname,' ',lastname) as EMP_NAME from table1 where emp_id=id ;
open cur1 ;
fetch cur1 into emp_name ;
select emp_name;
close cur1;
end $$
call sp_emp_details(4);
CREATE DEFINER=`db_user`@`%` PROCEDURE `sp_insert_details`(id int)
begin
declare emp_name varchar(20);
declare cur cursor for
select concat(firstname,' ',lastname) as EMP_NAME from table1 where emp_id=id ;
open cur;
fetch cur into emp_name;
insert into emp_details
select emp_name;
end
call sp_emp_details(1);
No comments:
Post a Comment