简体   繁体   中英

Stored Procedure not returning values

I'm creating a stored procedure to update a field with an instructor who makes less than a certain value. The procedure creates and runs, but when it runs it only returns the rows. No data shows up once I call the procedure. It only has one field to update so I don't need to implement cursors. Any help would be appreciated.

DELIMITER $$
drop procedure if exists update_salary$$
create procedure update_salary()
begin
declare Instructor_ID int;
declare Salary int;
select Instructor_ID, Salary from Instructor where Instructor_ID = 13;
if Salary < 53000 then
update Instructor set Salary = 61000 where Instructor_ID = People.Person_ID;
end if;
end $$ 

I'm not quite sure where People.Person_ID comes from, but if your goal is to update a specific record in the Instructor table only if the Salary is under 53 000, you should use a simple UPDATE query, like so :

UPDATE Instructor SET Salary = 61000 WHERE Instructor_ID = 13 AND Salary < 53000

To see the results of the update afterwards, you need to run a SELECT statement, like so :

SELECT Instructor_ID, Salary FROM Instructor WHERE Instructor_ID = 13

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM