Microsoft Windows [Versión 10.0.22631.3880] (c) Microsoft Corporation. Todos los derechos reservados. C:\Users\A01-1-0504-20>cd/xampp/mysql/bin C:\xampp\mysql\bin>mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 9 Server version: 10.4.21-MariaDB mariadb.org binary distribution 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)]> source C:/xampp/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, 1 row affected (0.022 sec) Database changed Query OK, 0 rows affected (0.117 sec) Query OK, 0 rows affected (0.066 sec) Query OK, 0 rows affected (0.001 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 5 rows affected (0.020 sec) Records: 5 Duplicates: 0 Warnings: 0 Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.001 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.083 sec) Query OK, 0 rows affected (0.001 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]> show tables; +------------------------+ | Tables_in_subconsultas | +------------------------+ | articulo | | detalle | +------------------------+ 2 rows in set (0.001 sec) MariaDB [subconsultas]> selec * from articulo; 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 'selec * from articulo' at line 1 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.002 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.002 sec) MariaDB [subconsultas]> update detalle set valorventa = (select valorunitario + (valorunitario * 0.23) from articulo where articulo.codigo = detall -> e.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 'e.codigo)' at line 2 MariaDB [subconsultas]> update detalle set valorventa = (select valorunitario + (valorunitario * 0.23) from articulo where articulo.codigo = detalle.codigo); Query OK, 7 rows affected (0.001 sec) Rows matched: 7 Changed: 7 Warnings: 0 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]> update detalle set total = cantidad * valorventa; Query OK, 7 rows affected (0.000 sec) Rows matched: 7 Changed: 7 Warnings: 0 MariaDB [subconsultas]> select * from detalle; +----+------------+------------+----------+------------+---------+--------+ | id | nrofactura | fecha | cantidad | valorventa | total | codigo | +----+------------+------------+----------+------------+---------+--------+ | 1 | 1200 | 2010-01-30 | 3 | 1168500 | 3505500 | 150 | | 2 | 1250 | 2010-02-13 | 5 | 1168500 | 5842500 | 150 | | 3 | 1250 | 2010-02-13 | 7 | 922500 | 6457500 | 250 | | 4 | 1300 | 2010-03-02 | 1 | 1205400 | 1205400 | 350 | | 5 | 1300 | 2010-03-02 | 2 | 135300 | 270600 | 300 | | 6 | 1400 | 2010-03-11 | 3 | 1476000 | 4428000 | 200 | | 7 | 1500 | 2010-03-21 | 5 | 922500 | 4612500 | 250 | +----+------------+------------+----------+------------+---------+--------+ 7 rows in set (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.000 sec) MariaDB [subconsultas]> update articulo set existencia = cantidad - (select sum(cantidad) from detalle where detalle.cantidad = articulo.cantidad); Query OK, 0 rows affected, 5 warnings (0.001 sec) Rows matched: 5 Changed: 0 Warnings: 5 MariaDB [subconsultas]> update articulo set existencia = cantidad - (select sum(cantidad) from detalle where detalle.codigo = articulo.codigo); Query OK, 5 rows affected (0.001 sec) Rows matched: 5 Changed: 5 Warnings: 0 MariaDB [subconsultas]> select * from articulo; +--------+------------+----------+---------------+------------+ | codigo | articulo | cantidad | valorunitario | existencia | +--------+------------+----------+---------------+------------+ | 150 | nevera | 25 | 950000 | 17 | | 200 | televisor | 11 | 1200000 | 8 | | 250 | estufa | 30 | 750000 | 18 | | 300 | ventilador | 17 | 110000 | 15 | | 350 | lavadora | 13 | 980000 | 12 | +--------+------------+----------+---------------+------------+ 5 rows in set (0.000 sec) MariaDB [subconsultas]> drop database subconsultas; Query OK, 2 rows affected (0.084 sec) MariaDB [(none)]> show database; 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 'database' at line 1 MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | phpmyadmin | | test | +--------------------+ 5 rows in set (0.015 sec) MariaDB [(none)]> source C:/xampp/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, 1 row affected (0.001 sec) Database changed Query OK, 0 rows affected (0.000 sec) Query OK, 0 rows affected (0.090 sec) Query OK, 0 rows affected (0.001 sec) Query OK, 0 rows affected (0.000 sec) Query OK, 5 rows affected (0.002 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.000 sec) Query OK, 0 rows affected (0.071 sec) Query OK, 0 rows affected (0.001 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]> show tables; +------------------------+ | Tables_in_subconsultas | +------------------------+ | articulo | | detalle | +------------------------+ 2 rows in set (0.001 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.001 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.002 sec) MariaDB [subconsultas]> delimiter // MariaDB [subconsultas]> crear 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 -> // 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 'crear trigger valorventa after insert on articulo for each row begin update ...' at line 1 MariaDB [subconsultas]> ; -> // ERROR 1065 (42000): Query was empty 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.099 sec) 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]> delimiter ; 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.000 sec) 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 | 2024-08-17 16:27:50.41 | NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION | root@localhost | cp850 | cp850_general_ci | utf8_general_ci | +------------+--------+----------+-------------------------------------------------------------------------------------------------------------------------------------------------+--------+------------------------+-----------------------------------------------------+----------------+----------------------+----------------------+--------------------+ 1 row in set (0.024 sec) MariaDB [subconsultas]> insert into articulo values('450','Secador Remington 1600',10,250000,0); Query OK, 1 row affected (0.002 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]> 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]> delimiter // MariaDB [subconsultas]> create trigger actualizar_existenciap after insert on detalle -> for each -> begin -> update articulo set existencia = cantidad - (select sum(cantidad) from detalle where detalle.codigo = articulo.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 'begin update articulo set existencia = cantidad - (select sum(cantidad) from ...' at line 3 MariaDB [subconsultas]> // ERROR: No query specified 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.059 sec) MariaDB [subconsultas]> delimiter ; 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 | 2024-08-17 16:27:50.41 | NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION | root@localhost | cp850 | cp850_general_ci | utf8_general_ci | | actualizar_existenciap | INSERT | detalle | begin update articulo set existencia = cantidad - (select sum(cantidad) from detalle where detalle.codigo = articulo.codigo); end | AFTER | 2024-08-17 16:37:08.13 | NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION | root@localhost | cp850 | cp850_general_ci | utf8_general_ci | +------------------------+--------+----------+-------------------------------------------------------------------------------------------------------------------------------------------------+--------+------------------------+-----------------------------------------------------+----------------+----------------------+----------------------+--------------------+ 2 rows in set (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) insert into detalle(nrofactura,fecha,cantidad,valorventa,total,codigo) values( Query OK, 1 row affected (0.003 sec)detalle(nrofactura,fecha,cantidad,valorventa,total,codigo) values('2001','2020-08-29',1,0,0,450); MariaDB [subconsultas]> select * from articulo; +--------+------------------------+----------+---------------+------------+ | codigo | articulo | cantidad | valorunitario | existencia | +--------+------------------------+----------+---------------+------------+ | 150 | nevera | 25 | 950000 | 17 | | 200 | televisor | 11 | 1200000 | 8 | | 250 | estufa | 30 | 750000 | 18 | | 300 | ventilador | 17 | 110000 | 15 | | 350 | lavadora | 13 | 980000 | 12 | | 450 | Secador Remington 1600 | 10 | 250000 | 9 | +--------+------------------------+----------+---------------+------------+ 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 | | 8 | 2001 | 2020-08-29 | 1 | 0 | 0 | 450 | +----+------------+------------+----------+------------+-------+--------+ 8 rows in set (0.001 sec) MariaDB [subconsultas]> exit Bye C:\xampp\mysql\bin>mysqldump -B uroot -p --routines subconsultas>c: /xampp/subconsultas.sql Acceso denegado. C:\xampp\mysql\bin>mysqldump -B uroot -p --routines subconsultas>c:/xampp/subconsultast.sql Enter password: mysqldump: Got error: 1045: "Access denied for user 'A01-1-0504-20'@'localhost' (using password: NO)" when trying to connect C:\xampp\mysql\bin>mysqldump -B -uroot -p --routines subconsultas>c:/xampp/subconsultast.sql Enter password: C:\xampp\mysql\bin>