문제

I am using MySQL benchmark. I have to create a table and write a procedure to read 10 from textfilnd load them to the created table.

I used the query:

use test; 
DELIMITER $$ 

CREATE DEFINER=`root`@`localhost` PROCEDURE `p_table`() 
BEGIN 
LOAD DATA LOCAL INFILE "D:/tablevalue.txt" 
INTO TABLE new_table 
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n'; 

END $$ 

DELIMITER ; 

But error like load data is not allowed in stored procedure, and then I used the query.

use test; 
drop procedure if exists `proctable`; 
DELIMITER $$ 

create definer =`root`@`localhost` procedure `proctable`() 
begin 

do sys_exec(concat('perl LOAD_DATA_INFILE.pl test.new_table ', 'D:\tablevalue.txt')); 

end $$ 

DELIMITER ; 

But data is not uploading from the file to the table.

If is there any other option let me know

도움이 되었습니까?

해결책

There are some restrictions on stored procedures. For example - it is not possible to use LOAD DATA INFILE command. Try to do it without procedures, just call your LOAD DATA INFILE statement as alone command.

Restrictions on Stored Programs.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top