We help IT Professionals succeed at work.

Batch import using C# and Oracle database

Itudk_2010
Itudk_2010 asked
on
Hi all,

I have a large text file with customer information and I would like to import this text file using C# and parse the text and insert into Oracle Database. I would like to batch import using C# console application. I would like to make checks whether the data already exits in the customer table in the code. Do you guys have any code examples with some descriptions?

Thanks in advance
Comment
Watch Question

SILVER EXPERT
Most Valuable Expert 2012
Distinguished Expert 2019
Commented:
Seems like you already have a plan and just need to write it.

What parts of this are you finding confusing?  

Before I went down writing custom code, look into sql loader.  It is an Oracle utility that is made to load text files into Oracle.

You could create a staging table if you were worried about duplicates.  Load the data there then merge it into the primary table.

Author

Commented:
Hi slightwv,

Thanks for your reply. But I would like to use C# not just SQL Loader. I have never used SQL Loader and I don't know how to do that. Do you have any C# examples?

Thanks a lot.
SILVER EXPERT
Most Valuable Expert 2012
Distinguished Expert 2019

Commented:
>>I have never used SQL Loader and I don't know how to do that.

Never having used a hammer doesn't mean you should not use one when you need to drive a nail.  I mean you can drive a nail with a rock, but knowing a hammer exists, why would you?

sql loader isn't that difficult to learn/use.  If you can provide some sample data and a table definition I can probably provide a sample control file for you.

>>Do you have any C# examples?

To do what?  You never answered the question:  What parts of this are you finding confusing?  


Reading a line from the file?
Parsing the line into individual columns?
Inserting the individual columns into the database?
???

Author

Commented:
Hi,

I don't have any code, I am just looking for some examples based on the assumption I made in my previous post. If  you could send me some code examples that would be great?

Looking forward to your reply.

Thanks a lot
SILVER EXPERT
Most Valuable Expert 2012
Distinguished Expert 2019

Commented:
Again, examples to do what?

I'm not going to write the entire project for you but if a particular piece of it is giving you problems, I'll see what I can do.

I still suggest you not write a utility and have to account for ALL possible errors you might encounter and use a utility that has already been written and more important, proven reliable over many years of use.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.