• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1288
  • Last Modified:

Importing a text file using a MySQL stored procedure

Hi guys,
Id like to find out from you kind gurus if there is a way to create a stored procedure, that accepts one parameter (that being the name of a text file), to be able to import that text file into a mysql table?

Any help greatly appreciated.
0
Simon336697
Asked:
Simon336697
  • 2
1 Solution
 
Goodangel MatopeSoftware ArchitectCommented:
Absolutely! You can use the LOAD DATA INFILE statement in your query. You can get a detailed explanation in your MYSql Reference, but below is an idea of what you can do. All you do is create a procedure that accepts the file name
LOAD DATA INFILE filename
  INTO TABLE t1
  FIELDS TERMINATED BY ','
  (column1, column2)

Open in new window

0
 
Goodangel MatopeSoftware ArchitectCommented:
Oops, sorry, LOAD DATA is not allowed in stored procedures. so you will have to run a query with the LOAD DATA statement from your PHP / ASP / application directly! :-(
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now