INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Bulk Import Text Files

Bulk Import Text Files

(OP)
I need to import Text files into a Pervasive DB
We are Using Pervasive v9.6. I have Created a table with 2 fields :
ItemNo CHAR 50
ExtDesc LONGVARCHAR (As data will be more that 255 CHARS)

What would be the best way to populate this table.

Can I somehow get a stored procedure to read a dir and import all teh txt files in it ?
 

RE: Bulk Import Text Files

Stored Procedures can't access external files.  
You'll need to write (or have written) a program to import the data.  There's a number of interfaces and methods but you'll need to pick it.
There is another option.  You could use BDU (Bulk Data Utility).  It's BDU.EXE and it was included with v9 and later.  It's a command line tool, you might look at the options to see if it'll work for you.
 

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
http://www.mirtheil.com

RE: Bulk Import Text Files

(OP)
Thank you for Idea,
I think I will use VBA from Excel to read the txt file into a string and then insert, HOWEVER is it posssible to UPDATE SINERT in one SQL command.....?
Would someting like this work :

CODE

INSERT INTO users (username)
SELECT 'Jo'
WHERE 'Jo'
  NOT IN (SELECT username FROM users)

UPDATE users
SET email = 'jo@email.com'
WHERE username = 'Jo'

or even this:

CODE

IF (EXISTS (SELECT * FROM AA_TestTable AS t1
  WHERE t1.ord_num = 'FFF'))
begin
  UPDATE AA_TestTable
  SET ord_qty = 999
  WHERE ord_num = 'FFF'
end
else
begin
  INSERT INTO AA_TestTable (ord_num, top_assy, ord_qty)
  VALUES('GGG', 'XYZ', 567)
end

 

RE: Bulk Import Text Files

Your code would need to issue an INSERT or UPDATE.  You can't pass both to the engine at the same time.  You might be abel t do something similar to your second code segment but it would have to be inside a stored procedure.   

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
http://www.mirtheil.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close