Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)]> CREATE DATABASE test4;
- Query OK, 1 row affected (0.00 sec)
- MariaDB [(none)]> use test4
- Database changed
- MariaDB [test4]> CREATE TABLE tabela(
- -> id int primary key auto_increment,
- -> suma decimal(10,2));
- Query OK, 0 rows affected (0.20 sec)
- MariaDB [test4]> CREATE TRIGER tabela BEFORE INSERT ON tabela FOR EACH ROW SET @sum=@sum+NEW.suma;
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'TRIGER ta
- MariaDB [test4]> CREATE TRIGER tabela__bi BEFORE INSERT ON tabela FOR EACH ROW SET @sum=@sum+NEW.suma;
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'TRIGER ta
- MariaDB [test4]> CREATE TRIGGER tabela BEFORE INSERT ON tabela FOR EACH ROW SET @sum=@sum+NEW.suma;
- Query OK, 0 rows affected (0.07 sec)
- MariaDB [test4]> INSERT INTO tabela VALUES(0, 155),(0, 45), (0,0);
- Query OK, 3 rows affected (0.15 sec)
- Records: 3 Duplicates: 0 Warnings: 0
- MariaDB [test4]> SET @sum = 0
- -> ;
- Query OK, 0 rows affected (0.00 sec)
- MariaDB [test4]> SELECT @sum AS 'Suma';
- +------+
- | Suma |
- +------+
- | 0 |
- +------+
- 1 row in set (0.00 sec)
- MariaDB [test4]> INSERT INTO tabela VALUES(0, 155),(0, 45), (0,0);
- Query OK, 3 rows affected (0.04 sec)
- Records: 3 Duplicates: 0 Warnings: 0
- MariaDB [test4]> SELECT @sum AS 'Suma';
- +--------+
- | Suma |
- +--------+
- | 200.00 |
- +--------+
- 1 row in set (0.00 sec)
- MariaDB [test4]> ^A
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement