Select statement inside cursor in mysql stored procedure is not taking into keyword -
this stored procedure not reading keyword "into" in select statement inside cursor loop. "select empid into vempid" appreciated.
begin declare processed,vattendempid,vnoofdays, vempid, vbasic_pay, vallowance, vda, vhra, vmeal_voucher, vcar_allowance, vchild_education ,vid int default 0; declare curattendance cursor select empid, count(in_date_time) d1 emp_attendance_processed date_format( in_date_time, '%m' ) = process_month , date_format( in_date_time, '%y' ) = process_year group empid order empid; declare continue handler not found set processed = 1 ; open curattendance; repeat fetch curattendance vattendempid, vnoofdays; if not processed select vnoofdays; select empid vempid, basic_pay vbasic_pay, allowance vallowance, da vda, hra vhra, meal_voucher vmeal_voucher, car_allowance vcar_allowance, child_education vchild_education** empsalary empid= vattendempid; set vbasic_pay = vbasic_pay*(vnoofdays/date_format( last_day(concat(process_year,'-',process_month,'-','01')),'%d')); set vallowance = vallowance *(vnoofdays/date_format( last_day(concat(process_year,'-',process_month,'-','01')),'%d')); set vda = vda *(vnoofdays/date_format( last_day(concat(process_year,'-',process_month,'-','01')),'%d')); set vhra = vhra *(vnoofdays/date_format( last_day(concat(process_year,'-',process_month,'-','01')),'%d')); set vmeal_voucher = vmeal_voucher *(vnoofdays/date_format( last_day(concat(process_year,'-',process_month,'-','01')),'%d')); set vcar_allowance = vcar_allowance *(vnoofdays/date_format( last_day(concat(process_year,'-',process_month,'-','01')),'%d')); set vchild_education = vchild_education *(vnoofdays/date_format( last_day(concat(process_year,'-',process_month,'-','01')),'%d')); insert emp_salary_processed (empid, basic_pay, allowance, da, hra, meal_voucher, car_allowance, child_education) values(vempid, vbasic_pay, vallowance, vda, vhra, vmeal_voucher, vcar_allowance, vchild_education); commit; end if; until processed end repeat; close curattendance; commit; end
correct syntax select ... ...
is:
select col1, ..., coln var1, ..., varn ...
this similar fetch
statement.
fetch curattendance vattendempid, vnoofdays;
change statement:
select empid vempid, basic_pay vbasic_pay, allowance vallowance, da vda, hra vhra, meal_voucher vmeal_voucher, car_allowance vcar_allowance, child_education vchild_education empsalary empid= vattendempid;
to:
select empid, basic_pay, allowance, da, hra, meal_voucher, car_allowance, child_education vempid, vbasic_pay, vallowance, vda, vhra, vmeal_voucher, vcar_allowance, vchild_education empsalary empid = vattendempid;
Comments
Post a Comment