For a class assignment I need to move a record from the Checked_Out_Media table to a History table, where the tables are identical. Then I need to delete the record from the Checked_Out_Media Table. I've gotten it down to this:
Create Procedure spMoveToHistory( IN in_UserID char(6), IN in_MediaBarcode char(3) )
BEGIN
SELECT @NextRow := (MAX(History_TUID) + 1)
From History;
Insert into History
Select @NextRow, COM.User_ID, COM.Media_Barcode,
COM.Checked_Out_Date, COM.Return_Date
From Checked_Out_Media COM
Where COM.User_ID = in_UserID AND
COM.Media_Barcode = in_MediaBarcode;
END;
The above code seems to work perfectly fine until I run it. It doesn't do anything, good or bad. When I check the procedure after it is created, It shows that there is an error at the End statement. I'm not sure why that only shows up AFTER I create it... Either way, I was hoping someone could clarify why the above doesn't work so I can try to add the below code. Also, the main reason for this post is to ask: Is it even possible to implement more than one transaction in a procedure?
Delete From checked_out_media
Where User_ID = in_UserID AND Media_Barcode = in_MediaBarcode;