Setting environment for using XAMPP for Windows.
Nikhil@N c:\xampp
# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 20
Server version: 10.4.32-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use rstudent;
Database changed
MariaDB [rstudent]> -- Procedure to get details of all students
MariaDB [rstudent]> DELIMITER //
MariaDB [rstudent]> CREATE PROCEDURE p11()
    -> BEGIN
    ->     SELECT * FROM student;
    -> END//
Query OK, 0 rows affected (0.034 sec)

MariaDB [rstudent]> DELIMITER ;
MariaDB [rstudent]>
MariaDB [rstudent]> -- Procedure to get student details based on sid
MariaDB [rstudent]> DELIMITER //
MariaDB [rstudent]> CREATE PROCEDURE p22(IN id INT)
    -> BEGIN
    ->     SELECT * FROM student WHERE sid = id;
    -> END//
Query OK, 0 rows affected (0.006 sec)

MariaDB [rstudent]> DELIMITER ;
MariaDB [rstudent]>
MariaDB [rstudent]> -- Procedure to display name and count of students who took a specific course based on cid
MariaDB [rstudent]> DELIMITER //
MariaDB [rstudent]> CREATE PROCEDURE p33(IN cid INT)
    -> BEGIN
    ->     SELECT s.sname, COUNT(t.sid) AS stud_cnt
    ->     FROM student s
    ->     JOIN taken t ON t.sid = s.sid
    ->     WHERE t.courseid = cid
    ->     GROUP BY s.sid;
    -> END//
Query OK, 0 rows affected (0.005 sec)

MariaDB [rstudent]> DELIMITER ;
MariaDB [rstudent]>
MariaDB [rstudent]> -- Procedure to update GPA based on sizeHS and course count
MariaDB [rstudent]> DELIMITER //
MariaDB [rstudent]> CREATE PROCEDURE p44(IN sid INT)
    -> BEGIN
    ->     DECLARE c_count INT DEFAULT 0;
    ->     DECLARE s_sizeHS INT DEFAULT 0;
    ->
    ->     SELECT COUNT(*) INTO c_count
    ->     FROM taken
    ->     WHERE taken.sid = sid;
    ->
    ->     SELECT sizeHS INTO s_sizeHS
    ->     FROM student
    ->     WHERE student.sid = sid;
    ->
    ->     IF c_count > 5 AND s_sizeHS > 10000 THEN
    ->         UPDATE student SET GPA = GPA + 1
    ->         WHERE student.sid = sid;
    ->     ELSEIF c_count >= 5 AND s_sizeHS < 10000 THEN
    ->         UPDATE student SET GPA = GPA + 0.5
    ->         WHERE student.sid = sid;
    ->     END IF;
    ->
    ->     SELECT course.credits
    ->     FROM course
    ->     JOIN taken ON taken.courseid = course.courseid
    ->     WHERE taken.sid = sid;
    -> END//
Query OK, 0 rows affected (0.005 sec)

MariaDB [rstudent]> DELIMITER ;
MariaDB [rstudent]>
MariaDB [rstudent]> -- Procedure to loop through all students and apply GPA update procedure
MariaDB [rstudent]> DELIMITER //
MariaDB [rstudent]> CREATE PROCEDURE p55()
    -> BEGIN
    ->     DECLARE done INT DEFAULT 0;
    ->     DECLARE stud_id INT;
    ->     DECLARE stud_cursor CURSOR FOR SELECT sid FROM student;
    ->     DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
    ->
    ->     OPEN stud_cursor;
    ->     read_loop: LOOP
    ->         FETCH stud_cursor INTO stud_id;
    ->         IF done THEN
    ->             LEAVE read_loop;
    ->         END IF;
    ->         CALL p44(stud_id);
    ->     END LOOP;
    ->     CLOSE stud_cursor;
    -> END//
Query OK, 0 rows affected (0.007 sec)

MariaDB [rstudent]> DELIMITER ;
MariaDB [rstudent]> call p11();
+-----+---------+------+--------+
| Sid | Sname   | GPA  | sizeHS |
+-----+---------+------+--------+
|   1 | Nihaal  | 8.30 |  19000 |
|   2 | Pratik  | 8.70 |  20000 |
|   3 | Krish   | 7.30 |  15000 |
|   4 | Joseph  | 9.20 |  22000 |
|   5 | Jack    | 6.00 |  25000 |
|   6 | Ramu    | 4.50 |  14000 |
|   7 | Eva     | 7.30 |  19500 |
|   8 | Nick    | 5.30 |  28000 |
|   9 | Charlie | 8.00 |  18000 |
|  10 | Bernard | 6.50 |  16000 |
|  11 | Max     | 7.60 |  13000 |
|  12 | Sam     | 4.10 |    900 |
|  13 | Rahul   | 8.10 |    800 |
|  14 | Kane    | 6.10 |  29000 |
|  15 | Dummy1  | 9.00 |   1000 |
|  16 | Dummy2  | 9.00 |   1000 |
+-----+---------+------+--------+
16 rows in set (0.001 sec)

Query OK, 0 rows affected (0.030 sec)

MariaDB [rstudent]> call p22(5);
+-----+-------+------+--------+
| Sid | Sname | GPA  | sizeHS |
+-----+-------+------+--------+
|   5 | Jack  | 6.00 |  25000 |
+-----+-------+------+--------+
1 row in set (0.001 sec)

Query OK, 0 rows affected (0.006 sec)

MariaDB [rstudent]> call p33(2);
+--------+----------+
| sname  | stud_cnt |
+--------+----------+
| Nihaal |        1 |
| Ramu   |        1 |
| Eva    |        1 |
| Max    |        1 |
| Sam    |        1 |
+--------+----------+
5 rows in set (0.001 sec)

Query OK, 0 rows affected (0.009 sec)

MariaDB [rstudent]> call p44(3);
+---------+
| credits |
+---------+
|       3 |
|       3 |
+---------+
2 rows in set (0.004 sec)

Query OK, 2 rows affected (0.013 sec)

MariaDB [rstudent]> call p55();
+---------+
| credits |
+---------+
|       3 |
|       4 |
|       3 |
+---------+
3 rows in set (0.001 sec)

+---------+
| credits |
+---------+
|       3 |
+---------+
1 row in set (0.006 sec)

+---------+
| credits |
+---------+
|       3 |
|       3 |
+---------+
2 rows in set (0.008 sec)

+---------+
| credits |
+---------+
|       3 |
+---------+
1 row in set (0.012 sec)

+---------+
| credits |
+---------+
|       3 |
+---------+
1 row in set (0.015 sec)

+---------+
| credits |
+---------+
|       4 |
+---------+
1 row in set (0.019 sec)

+---------+
| credits |
+---------+
|       3 |
|       4 |
+---------+
2 rows in set (0.025 sec)

+---------+
| credits |
+---------+
|       3 |
+---------+
1 row in set (0.029 sec)

+---------+
| credits |
+---------+
|       3 |
|       3 |
+---------+
2 rows in set (0.034 sec)

+---------+
| credits |
+---------+
|       3 |
+---------+
1 row in set (0.041 sec)

+---------+
| credits |
+---------+
|       3 |
|       4 |
+---------+
2 rows in set (0.045 sec)

+---------+
| credits |
+---------+
|       3 |
|       4 |
+---------+
2 rows in set (0.048 sec)

+---------+
| credits |
+---------+
|       3 |
+---------+
1 row in set (0.055 sec)

Empty set (0.058 sec)

+---------+
| credits |
+---------+
|       3 |
+---------+
1 row in set (0.058 sec)

+---------+
| credits |
+---------+
|       3 |
+---------+
1 row in set (0.061 sec)

Query OK, 32 rows affected (0.063 sec)