DELIMITER $$

DROP PROCEDURE IF EXISTS `hrprocess_temp`.`sp_alltabinsert1` $$
CREATE DEFINER=`invensis`@`%` PROCEDURE `sp_alltabinsert1`(empid varchar(10),fname varchar(45),lname varchar(45),
fathername varchar(30),dob varchar(20),gender varchar(6),maritalstatus varchar(9),spousename varchar(15),children varchar(8),
commadd varchar(250),permadd varchar(250),mobileno varchar(15),landlineno varchar(15),email varchar(40),
languages varchar(25),nationality varchar(25),bloodgroup varchar(5),drivingno varchar(20),panno varchar(15),
passportno varchar(15),imagepath varchar(100),resumepath varchar(1000),skill varchar(250),deptname varchar(30),
Course varchar(20),Specialize varchar(35),institute varchar(25),PassYear varchar(10),
Organization varchar(25),Designation varchar(25),FromDt varchar(15),ToDt varchar(15),ReasonsChange varchar(100))
begin
declare empno int;
insert into Employee   (Emp_Id,First_Name,Last_name,Father_Name,Date_Birth,Gender,Marital_Status,Spouse_Name,
Children_No,Comm_Add,Perm_Add,Mobile_No,Land_No,Email_id,Language,Nationality,Blood_Group,Passport_No,
Pan_No,Driving_No,Image,Resume,skills ,Dept_Name)
                                      values (empid,fname,lname,fathername,dob,gender,maritalstatus,spousename,children,commadd,
                                       permadd,mobileno,landlineno,email,languages,nationality,bloodgroup,drivingno,panno,passportno,
                                        imagepath,resumepath,skill,deptname);

set@empno= last insert Emp_No();

 insert into Education ( Course, Specialize,institute,Pass_year,Emp_No)
                     values(course,specialize,institute,passyear,@empno);

insert into Experience (Organization,Designation,From_Dt,To_Dt,Reasons_Change,Emp_No)
                     values (Organization,Designation,FromDt,ToDt,ReasonsChange,@empno);
end $$

DELIMITER ;

You are probably looking for the mysql function LAST_INSERT_ID()

Try LAST_INSERT_ID()

Threads merged, please do not multipost in the future

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.