我在执行程序时创建了一个mysql程序 - 没有错误。但结果没有显示出来。
CREATE PROCEDURE `proc1`()
BEGIN
(SELECT 'idTienda', 'idArticulo', 'Descripcion', 'Peso', 'Precio', 'Importe' )
UNION
(SELECT idTienda, idArticulo, Descripcion, Peso, Precio, Importe
FROM dat_ticket_linea
INTO OUTFILE 'C:/tmp/sales.csv'
FIELDS ENCLOSED BY '"'
TERMINATED BY ';'
ESCAPED BY '"'
LINES TERMINATED BY '\r\n');
END
感谢是否有人帮我解决它
答案 0 :(得分:0)
我无法重现这个问题。
mysql> DROP TABLE IF EXISTS `dat_ticket_linea`;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE TABLE IF NOT EXISTS `dat_ticket_linea` (
-> `idTienda` INT UNSIGNED NOT NULL,
-> `idArticulo` INT UNSIGNED NOT NULL,
-> `Descripcion` VARCHAR(255) DEFAULT NULL,
-> `Peso` DECIMAL(7, 2) DEFAULT NULL,
-> `Precio` DECIMAL(7, 2) DEFAULT NULL,
-> `Importe` DECIMAL(7, 2) DEFAULT NULL
-> );
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO `dat_ticket_linea` (
-> `idTienda`,
-> `idArticulo`,
-> `Descripcion`,
-> `Peso`,
-> `Precio`,
-> `Importe`
-> ) VALUES (
-> 1, 1, 'Descripcion 1', 100, 200, 300
-> ), (
-> 1, 2, 'Descripcion 2', 400, 500, 600
-> ), (
-> 2, 3, 'Descripcion 3', 700, 800, 900
-> );
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> DROP PROCEDURE IF EXISTS `proc1`;
Query OK, 0 rows affected (0.00 sec)
mysql> DELIMITER //
mysql> CREATE PROCEDURE `proc1`()
-> BEGIN
-> SELECT
-> 'idTienda',
-> 'idArticulo',
-> 'Descripcion',
-> 'Peso',
-> 'Precio',
-> 'Importe'
-> UNION
-> SELECT
-> `idTienda`,
-> `idArticulo`,
-> `Descripcion`,
-> `Peso`,
-> `Precio`,
-> `Importe`
-> FROM
-> `dat_ticket_linea`
-> INTO OUTFILE '/path/to/file/sales.csv'
-> FIELDS TERMINATED BY ';'
-> ENCLOSED BY '"'
-> ESCAPED BY '"'
-> LINES TERMINATED BY '\r\n';
-> END//
Query OK, 0 rows affected (0.00 sec)
mysql> DELIMITER ;
mysql> CALL `proc1`;
Query OK, 4 rows affected (0.01 sec)
mysql> \! sudo cat /path/to/file/sales.csv
"idTienda";"idArticulo";"Descripcion";"Peso";"Precio";"Importe"
"1";"1";"Descripcion 1";"100.00";"200.00";"300.00"
"1";"2";"Descripcion 2";"400.00";"500.00";"600.00"
"2";"3";"Descripcion 3";"700.00";"800.00";"900.00"