Solved

Importing a text file using a MySQL stored procedure

Posted on 2008-10-02
2
1,262 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
  • 2
2 Comments
 
LVL 11

Accepted Solution

by:
Goodangel Matope earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
A short film showing how OnPage and Connectwise integration works.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

948 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now