Y.M
Y.M

Reputation: 11

Import data from a csv to Mysql table using a stored procedure

The following query does the Job: LOAD DATA LOCAL INFILE 'C:/x/y.csv' INTO TABLE test FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1 ROWS;

But i want to achieve the same by using a Stored procedure. Have come across various discussions where it is mentioned that "Load Data" cannot be used in a Stored procedure, but i couldn't find an alternate option to do this.

Can some one please provide other alternatives which can be used to load data from CSV to Mysql table using a stored procedure. Thanks in advance!

Upvotes: 0

Views: 4788

Answers (1)

C.B.
C.B.

Reputation: 786

You can create a external script that does the LOAD DATA, then in the stored procedure use sys_exec to execute that command.

Upvotes: 0

Related Questions