mirror of
https://github.com/opelly27/WinStudentGoalTracker.git
synced 2026-05-20 01:47:41 +00:00
added first controller and corresponding stored procedures.
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
DROP PROCEDURE IF EXISTS sp_Student_Delete;
|
||||
DELIMITER $$
|
||||
|
||||
CREATE PROCEDURE sp_Student_Delete(IN p_id_student INT)
|
||||
BEGIN
|
||||
DELETE FROM student
|
||||
WHERE id_student = p_id_student;
|
||||
|
||||
SELECT ROW_COUNT() AS rows_affected;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
@@ -0,0 +1,18 @@
|
||||
DROP PROCEDURE IF EXISTS sp_Student_GetAll;
|
||||
DELIMITER $$
|
||||
|
||||
CREATE PROCEDURE sp_Student_GetAll()
|
||||
BEGIN
|
||||
SELECT
|
||||
id_student,
|
||||
id_program,
|
||||
identifier,
|
||||
program_year,
|
||||
enrollment_date,
|
||||
expected_grad,
|
||||
created_at
|
||||
FROM student
|
||||
ORDER BY id_student;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
@@ -0,0 +1,19 @@
|
||||
DROP PROCEDURE IF EXISTS sp_Student_GetById;
|
||||
DELIMITER $$
|
||||
|
||||
CREATE PROCEDURE sp_Student_GetById(IN p_id_student INT)
|
||||
BEGIN
|
||||
SELECT
|
||||
id_student,
|
||||
id_program,
|
||||
identifier,
|
||||
program_year,
|
||||
enrollment_date,
|
||||
expected_grad,
|
||||
created_at
|
||||
FROM student
|
||||
WHERE id_student = p_id_student
|
||||
LIMIT 1;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
@@ -0,0 +1,47 @@
|
||||
DROP PROCEDURE IF EXISTS sp_Student_Insert;
|
||||
DELIMITER $$
|
||||
|
||||
CREATE PROCEDURE sp_Student_Insert(
|
||||
IN p_id_student INT,
|
||||
IN p_id_program INT,
|
||||
IN p_identifier VARCHAR(50),
|
||||
IN p_program_year INT,
|
||||
IN p_enrollment_date DATE,
|
||||
IN p_expected_grad DATE
|
||||
)
|
||||
BEGIN
|
||||
INSERT INTO student
|
||||
(
|
||||
id_student,
|
||||
id_program,
|
||||
identifier,
|
||||
program_year,
|
||||
enrollment_date,
|
||||
expected_grad,
|
||||
created_at
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
p_id_student,
|
||||
p_id_program,
|
||||
p_identifier,
|
||||
p_program_year,
|
||||
p_enrollment_date,
|
||||
p_expected_grad,
|
||||
UTC_TIMESTAMP()
|
||||
);
|
||||
|
||||
SELECT
|
||||
id_student,
|
||||
id_program,
|
||||
identifier,
|
||||
program_year,
|
||||
enrollment_date,
|
||||
expected_grad,
|
||||
created_at
|
||||
FROM student
|
||||
WHERE id_student = p_id_student
|
||||
LIMIT 1;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
@@ -0,0 +1,25 @@
|
||||
DROP PROCEDURE IF EXISTS sp_Student_Update;
|
||||
DELIMITER $$
|
||||
|
||||
CREATE PROCEDURE sp_Student_Update(
|
||||
IN p_id_student INT,
|
||||
IN p_id_program INT,
|
||||
IN p_identifier VARCHAR(50),
|
||||
IN p_program_year INT,
|
||||
IN p_enrollment_date DATE,
|
||||
IN p_expected_grad DATE
|
||||
)
|
||||
BEGIN
|
||||
UPDATE student
|
||||
SET
|
||||
id_program = COALESCE(p_id_program, id_program),
|
||||
identifier = COALESCE(p_identifier, identifier),
|
||||
program_year = COALESCE(p_program_year, program_year),
|
||||
enrollment_date = COALESCE(p_enrollment_date, enrollment_date),
|
||||
expected_grad = COALESCE(p_expected_grad, expected_grad)
|
||||
WHERE id_student = p_id_student;
|
||||
|
||||
SELECT ROW_COUNT() AS rows_affected;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
Reference in New Issue
Block a user