Convert text to UPPER case when inserting/updating data
Create table
For example, we create a table, localitati, as follows:
1 2 3 4 5 |
DROP TABLE IF EXISTS localitati; CREATE TABLE localitati ( codPost INT(6) PRIMARY KEY auto_increment , denLoc CHAR(35) NOT NULL , denJud CHAR(2) NOT NULL); |
Trigger la inserare
1 2 3 4 5 |
CREATE TRIGGER ins_CAPS BEFORE INSERT ON localitati FOR EACH ROW SET NEW.denJud = UPPER(NEW.denJud); |
If it is created in phpMyAdmin, it could look like the figure below.
Trigger on update
1 2 |
CREATE TRIGGER upd_CAPS BEFORE UPDATE ON localitati FOR EACH ROW SET NEW.denJud = UPPER(NEW.denJud); |
Because neat work can be of real use in the field of computer science, as you can see, I rendered the two contents of the triggers arranged differently.
I have also restored the visual option for this trigger.