In the settings of UniServer might be too little value to "thread_stack",
so you can not execute the procedures.
In order to enable them:
- Stop MySQL.
- In the menu choose MySQL and then "Edit ConfigFile my.ini"
- Search this "thread_stack = 128K"
- And change it to "thread_stack = 256K"
- Save the file and close it
- Restart MySQL
Procedures
Read the examples about procedures and transactions from here
- Make a Stored Procedure named addHours. That procedure should add a given amount of hours to given person(id_person) to given project (id_project). So, you should be able to call it like this:
CALL addHours(x, y, z)
.
Where
- x is the id_person
- y is the id_project
- z is the amount of hours
You can test your procedure with below values
- CALL addHours(9999,101,500); -> should not success
- CALL addHours(201,101,500); -> should success
- CALL addHours(201,105,500); -> should success
- Make a Stored Procedure named addHoursNew. That procedure should work in the same ways as addHours, but if the x and y already exists in the hour-table, it will add the amount to the existing amount.
In order to test the procedure, execute first this command:
DELETE FROM hour where id_project='105';
And then execute several times CALL addHoursNew(201,'105',500);
Triggers
- Read the about triggers from this page
- Create table named person_log which has fields:
- id_personLog INT PRIMARY KEY AUTO_INCREMENT
- Explanation VARCHAR(255)
- Logtime DATETIME
- Create trigger which will add Text "Person updated" and Date of today to the table person_log, if you update person data