Results 1 to 2 of 2
  1. #1
    Join Date
    May 2016
    Posts
    1

    Unhappy Unanswered: student_id and their MAX score as one OUT parameter

    This is my first ever procedure in MySQL and all I know is that there can be IN, OUT and INOUT procedures and that we pass the IN parameters to the Sproc, and the OUT parameter from the Sproc. Until now I didn't think we could assign two values to one OUT parameter. I have attempted to begin writing the procedure below!! I would appreciate if you could help me alter the procedure below.


    DELIMITER $



    DROP PROCEDURE IF EXISTS MAX_SCORE$



    CREATE PROCEDURE MAX (IN start_student_id INT,
    IN end_student_id INT,
    OUT,
    OUT rc INT

    )


    BEGIN



    BEGIN


    set rc := -1;



    SELECT NAME, MAX(SCORE),MIN(SCORE),AVG(SCORE)
    FROM STUDENT, SCORE

    WHERE STUDENT.STUDENT_ID = SCORE.STUDENT_ID

    AND STUDENT.STUDENT_ID = in_student_id

    GROUP BY NAME

    ;


    set rc:=0;


    END;


    END$




    DELIMITER ;



    These are things I want in the procedure:

    a. The procedure takes TWO input parameters for student Id’s, {start_student_id and end_student_id and it has TWO output parameters}.

    b. Identify the student who has received maximum score among these students.

    c. The procedure should return the student_id and their MAX score as one OUT parameter

    d. The procedure also returns return code indicating success / failure.

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Seems a silly requirement to combine two pieces of data in a single parameter. Is the code that runs this procedure going to have to decode the two facts, or does the combination have any business meaning?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •