示例OUT文件(工作)
DELIMITER ##
CREATE PROCEDURE exportFile(IN inFilePath varchar(100))
BEGIN
DECLARE filename VARCHAR(255);
SET filename = CONCAT(
inFilePath,
NOW(),
'.csv');
SET @outfilestmt = concat(
'SELECT * INTO OUTFILE ',
"'", filename,"'",
'FIELDS TERMINATED BY \',\'',
' FROM RESULTS');
PREPARE stmt FROM @outfilestmt;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END ##
DELIMITER ;
示例INFILE(不工作)
DELIMITER ##
CREATE PROCEDURE loadFile1(IN inFilePath varchar(100))
BEGIN
DECLARE filename VARCHAR(255);
SET filename = inFilePath;
SET @loadFilestmt = CONCAT(
'LOAD DATA INFILE ',
"'", filename,"'",
' INTO TABLE INPUT'
);
PREPARE stmt FROM @loadFilestmt;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END ##
DELIMITER ;
这会产生相同的行为吗?