I need to create a procedure with a transaction that takes employeeID and AppointmentID as parameter and then transfers all information from appointment table where appointmentID param matches the appointmentID in the appointment table to the completed_doses table and additionally insert the employeeID param in the same row.
this is my code so far:
enter code here
DELIMITER //
create procedure appointment_finished (in employeeID mediumint, in appointmentID int(10))
begin
declare vSQLSTATE char(5) default '00000';
declare continue handler for sqlexception
begin
get diagnostics condition 1
vSQLSTATE = returned_SQLSTATE;
end;
start transaction;
insert into completed_doses
select
(select *
from appointment
where appointmentID = appointment.appointmentID),
(employeeID);
select vSQLSTATE;
if vSQLSTATE = '00000' then commit;
else rollback;
end if;
end //
DELIMITER ;