?
Solved

Importing a text file using a MySQL stored procedure

Posted on 2008-10-02
2
Medium Priority
?
1,278 Views
Last Modified: 2012-05-05
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
Comment
Question by:Simon336697
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 11

Accepted Solution

by:
Goodangel Matope earned 2000 total points
ID: 22630598
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
 
LVL 11

Expert Comment

by:Goodangel Matope
ID: 22630626
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

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question