0

Please help me ....!! I am just learning to use the mysql database.Now what i am trying to do is creating a table that contains roll number, name, Marks in 3 subjects as three columns, and total and grade. first of all I created the table and inserted values of 3 students without inserting values on the columns total and the grade.

+---------+---------+------+------+------+-------+-------+
| ROLL_NO | NAME    | CA   | DCP  | CPP  | TOTAL | GRADE |
+---------+---------+------+------+------+-------+-------+
|      20 | HARITHA |   36 |   42 |   40 |  NULL | NULL  | 
|      21 | HARI    |   39 |   40 |   49 |  NULL | NULL  | 
|      21 | HASHIR  |   35 |   39 |   33 |  NULL | NULL  |
+---------+---------+------+------+------+-------+-------+

Then I created a procedure named grade and I using that for reading the three subjects marks from the student details table to the three variables inside the grade procedure and then finding the total of 3 marks and the percentage of the marks and then with that percentage by checking that percentage and setting the grid for each student and updating for sending these values from the procedure to the table student details.

CREATE PROCEDURE GRADE(IN C INTEGER)
BEGIN
    DECLARE TOT INTEGER;
    DECLARE P FLOAT;
    DECLARE PERCENTAGE INTEGER;
    DECLARE GD CHAR(1);
    DECLARE A INTEGER;
    DECLARE B INTEGER;
    DECLARE C INTEGER;
    SELECT CA,DCP,CPP INTO A,B,C FROM STU_DET WHERE ROLL_NO=C;
    SET TOT=A+B+C;
    UPDATE STU_DET SET TOTAL=TOT WHERE ROLL_NO=C;
    SET P=TOT/300;
    SET PERCENTAGE=P*100;
    IF PERCENTAGE>90 THEN 
        SET GD='S';
    ELSEIF PERCENTAGE>80 THEN 
        SET GD='A';
    ELSEIF PERCENTAGE>70 THEN 
        SET GD='B';
    ELSEIF PERCENTAGE>60 THEN 
        SET GD='C';
    ELSEIF PERCENTAGE>50 THEN 
        SET GD='D';
    ELSE 
        SET GD='F';
    END IF;
    UPDATE STU_DET SET GRADE=GD WHERE ROLL_NO=C;
END$$

Now what I am stuck with is the table created and inserted the three values successfully also created the procedure grade and it also successful but after that when I tried to call the great and assigning values to the grid procedure it shows zero rows affected.

CALL GRADE(21)$$
Query OK, 0 rows affected (0.00 sec)


SELECT * FROM STU_DET$$


+---------+---------+------+------+------+-------+-------+
| ROLL_NO | NAME    | CA   | DCP  | CPP  | TOTAL | GRADE |
+---------+---------+------+------+------+-------+-------+
|      20 | HARITHA |   36 |   42 |   40 |  NULL | NULL  |
|      21 | HARI    |   39 |   40 |   49 |  NULL | NULL  |
|      21 | HASHIR  |   35 |   39 |   33 |  NULL | NULL  |
+---------+---------+------+------+------+-------+-------+

means there is no change in the table and I am spending to solve that for about 3 for 4 hours and I think I get a solution from here.

Iam new in this platform... please help me....!

  • Check your code, it's got a parameter and a variable C. Which is which? – Gerard H. Pille Aug 12 '18 at 20:39
  • Oh... thanks.Finally i found that that duplicate c causes the problem.thank u very much.... – user158297 Aug 12 '18 at 22:58
0

Check your code, it's got a parameter and a variable C. Which is which?

  • 1
    This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review – Michael Green Aug 13 '18 at 5:28
  • @MichaelGreen How odd. More so since it proved to be the cause of the problem, as per the OP's response. – Gerard H. Pille Aug 13 '18 at 7:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.