views:

14

answers:

2

It's a bit silly asking homework questions here, however I'm genuinely stumped as to what this question is asking.

Create a stored procedure to add results. The procedure should take four (4) parameters. These are; The student's name (first and last), the name of the apparatus and the score. When the data has been inserted, return a message to the user advising that the data has been inserted. Name the procedure, addresults_xxx(), where xxx is to be replaced by your initials. Include the date.

I've highlighted the part in bold that I don't understand.

This is what I have so far.

DELIMITER //
CREATE PROCEDURE addresults_JB( IN student_first_name VARCHAR(20),
                IN student_last_name VARCHAR(20),
                IN apparatus_name VARCHAR(20),
                IN test_result INT)
BEGIN
    DECLARE student_id INT;
    DECLARE apparatus_id INT;

    SELECT studentid INTO student_id
    FROM tblstudents
    WHERE studentfirstname = student_first_name
    AND studentlastname = student_last_name;

    SELECT apparatusid INTO apparatus_id
    FROM tblapparatus
    WHERE apparatusname = apparatus_name;


    INSERT INTO tblresults (studentid, apparatusid, result, date_added)
    VALUES  (student_id, apparatus_id, test_result, NOW());

END //
DELIMITER ;

How can I return a message from a stored procedure?

+1  A: 

You could do: SELECT "The data has been inserted"

RyanHennig
Thanks for answering, you both said the same thing so I had to accept the first answer I received!
TomTimChop
+1  A: 

This will work, unfortuately I don't think there is a Print command like in MS SQL.

select "Procedure Completed" as "Result";
JonVD