MariaDB [subconsultas]> source C:\Users\A01-1-0504-12\Downloads\subconsultas.sql Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Database changed Query OK, 0 rows affected (0.001 sec) Query OK, 0 rows affected (0.030 sec) Query OK, 0 rows affected (0.006 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 5 rows affected (0.001 sec) Records: 5 Duplicates: 0 Warnings: 0 Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.001 sec) Query OK, 0 rows affected (0.020 sec) Query OK, 0 rows affected (0.007 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 7 rows affected (0.000 sec) Records: 7 Duplicates: 0 Warnings: 0 Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.000 sec) MariaDB [subconsultas]> select * from articulo; +--------+------------+----------+---------------+------------+ | codigo | articulo | cantidad | valorunitario | existencia | +--------+------------+----------+---------------+------------+ | 150 | nevera | 25 | 950000 | 0 | | 200 | televisor | 11 | 1200000 | 0 | | 250 | estufa | 30 | 750000 | 0 | | 300 | ventilador | 17 | 110000 | 0 | | 350 | lavadora | 13 | 980000 | 0 | +--------+------------+----------+---------------+------------+ 5 rows in set (0.001 sec) MariaDB [subconsultas]> delimiter // MariaDB [subconsultas]> create trigger valorventa after insert in articulo -> for each row -> begin -> update detalle set valorventa = (select valorunitario + (valorunitario * 0.23) from articulo where articulo.codigo = detalle.codigo); -> end -> // 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 'in articulo for each row begin update detalle set valorventa = (select valoru...' at line 1 MariaDB [subconsultas]> delimiter // MariaDB [subconsultas]> create trigger valorventa after insert on articulo -> for each row -> begin -> update detalle set valorventa = (select valorunitario + (valorunitario * 0.23) from articulo where articulo.codigo = detalle.codigo); -> end -> // Query OK, 0 rows affected (0.056 sec) MariaDB [subconsultas]> delimiter ; MariaDB [subconsultas]> show trigger; 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 'trigger' at line 1 MariaDB [subconsultas]> show triggers; +------------+--------+----------+-------------------------------------------------------------------------------------------------------------------------------------------------+--------+------------------------+-----------------------------------------------------+----------------+----------------------+----------------------+--------------------+ | Trigger | Event | Table | Statement | Timing | Created | sql_mode | Definer | character_set_client | collation_connection | Database Collation | +------------+--------+----------+-------------------------------------------------------------------------------------------------------------------------------------------------+--------+------------------------+-----------------------------------------------------+----------------+----------------------+----------------------+--------------------+ | valorventa | INSERT | articulo | begin update detalle set valorventa = (select valorunitario + (valorunitario * 0.23) from articulo where articulo.codigo = detalle.codigo); end | AFTER | 2023-08-19 16:21:09.32 | NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION | root@localhost | cp850 | cp850_general_ci | utf8_general_ci | +------------+--------+----------+-------------------------------------------------------------------------------------------------------------------------------------------------+--------+------------------------+-----------------------------------------------------+----------------+----------------------+----------------------+--------------------+ 1 row in set (0.031 sec) MariaDB [subconsultas]> select * from detalle; +----+------------+------------+----------+------------+-------+--------+ | id | nrofactura | fecha | cantidad | valorventa | total | codigo | +----+------------+------------+----------+------------+-------+--------+ | 1 | 1200 | 2010-01-30 | 3 | 0 | 0 | 150 | | 2 | 1250 | 2010-02-13 | 5 | 0 | 0 | 150 | | 3 | 1250 | 2010-02-13 | 7 | 0 | 0 | 250 | | 4 | 1300 | 2010-03-02 | 1 | 0 | 0 | 350 | | 5 | 1300 | 2010-03-02 | 2 | 0 | 0 | 300 | | 6 | 1400 | 2010-03-11 | 3 | 0 | 0 | 200 | | 7 | 1500 | 2010-03-21 | 5 | 0 | 0 | 250 | +----+------------+------------+----------+------------+-------+--------+ 7 rows in set (0.012 sec) MariaDB [subconsultas]> insert into articulo values('450','Secador Remington 1600',10,250000,0); Query OK, 1 row affected (0.014 sec) MariaDB [subconsultas]> select * from articulo; +--------+------------------------+----------+---------------+------------+ | codigo | articulo | cantidad | valorunitario | existencia | +--------+------------------------+----------+---------------+------------+ | 150 | nevera | 25 | 950000 | 0 | | 200 | televisor | 11 | 1200000 | 0 | | 250 | estufa | 30 | 750000 | 0 | | 300 | ventilador | 17 | 110000 | 0 | | 350 | lavadora | 13 | 980000 | 0 | | 450 | Secador Remington 1600 | 10 | 250000 | 0 | +--------+------------------------+----------+---------------+------------+ 6 rows in set (0.000 sec) MariaDB [subconsultas]> select * from detalle; +----+------------+------------+----------+------------+-------+--------+ | id | nrofactura | fecha | cantidad | valorventa | total | codigo | +----+------------+------------+----------+------------+-------+--------+ | 1 | 1200 | 2010-01-30 | 3 | 1168500 | 0 | 150 | | 2 | 1250 | 2010-02-13 | 5 | 1168500 | 0 | 150 | | 3 | 1250 | 2010-02-13 | 7 | 922500 | 0 | 250 | | 4 | 1300 | 2010-03-02 | 1 | 1205400 | 0 | 350 | | 5 | 1300 | 2010-03-02 | 2 | 135300 | 0 | 300 | | 6 | 1400 | 2010-03-11 | 3 | 1476000 | 0 | 200 | | 7 | 1500 | 2010-03-21 | 5 | 922500 | 0 | 250 | +----+------------+------------+----------+------------+-------+--------+ 7 rows in set (0.000 sec) MariaDB [subconsultas]> dilimiter // -> create trigger actualizar_existenciap after insert on detalle -> for each row -> begin -> update articulo set existencia = cantidad - (select sum(cantidad) from detalle where detalle.codigo = articulo.codigo); 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 'dilimiter // create trigger actualizar_existenciap after insert on detalle fo...' at line 1 MariaDB [subconsultas]> delimiter // MariaDB [subconsultas]> create trigger actualizar_existenciap after insert on detalle -> for each row -> begin -> update articulo set existencia = cantidad - (select sum(cantidad) from detalle where detalle.codigo = articulo.codigo); -> end -> // Query OK, 0 rows affected (0.053 sec) MariaDB [subconsultas]> delimiter ; MariaDB [subconsultas]> insert into detalle(nrofactura,fecha,cantidad,valorventa,total,codigo) values('2001','2020-08-29',1,0,0,450); Query OK, 1 row affected (0.006 sec) MariaDB [subconsultas]> select * from detalle; +----+------------+------------+----------+------------+-------+--------+ | id | nrofactura | fecha | cantidad | valorventa | total | codigo | +----+------------+------------+----------+------------+-------+--------+ | 1 | 1200 | 2010-01-30 | 3 | 1168500 | 0 | 150 | | 2 | 1250 | 2010-02-13 | 5 | 1168500 | 0 | 150 | | 3 | 1250 | 2010-02-13 | 7 | 922500 | 0 | 250 | | 4 | 1300 | 2010-03-02 | 1 | 1205400 | 0 | 350 | | 5 | 1300 | 2010-03-02 | 2 | 135300 | 0 | 300 | | 6 | 1400 | 2010-03-11 | 3 | 1476000 | 0 | 200 | | 7 | 1500 | 2010-03-21 | 5 | 922500 | 0 | 250 | | 8 | 2001 | 2020-08-29 | 1 | 0 | 0 | 450 | +----+------------+------------+----------+------------+-------+--------+ 8 rows in set (0.000 sec) MariaDB [subconsultas]> exit Bye C:\xampp\mysql\bin>mysqldum -B -uroot --routines subconsultas>c:/xampp/subconsultas.sql "mysqldum" no se reconoce como un comando interno o externo, programa o archivo por lotes ejecutable. C:\xampp\mysql\bin>mysqldump -B -uroot --routines subconsultas>c:/xampp/subconsultas.sql C:\xampp\mysql\bin>