Question

Need a stored procedure to read data from an excel sheet and insert into a table - using oracle 8i

Asked by: hart

I need a stored procedure that will help me to read an excel sheet on the hard disk.
then i need to insert this data into a table..

i am using oracle 8i, i have heard this is possible, but don't have any clue how to work upon this.

PS: Also i cannot create a dsn on the excel sheet as this may differ w.r.t user.

Experts Please Help ....

Awaiting Eagerly

Regards
Hart

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-03-31 at 01:20:13ID20938420
Tags

excel

,

oracle

,

procedure

,

data

,

stored

Topic

Oracle Database

Participating Experts
7
Points
500
Comments
19

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Excel sheet data to oracle database table ?
    How do I get data from an Excel sheet into an Oracle database table without user interface ?
  2. Excel sheet data to oracle database table ?
    How do I get data from an Excel sheet into an Oracle database table without user interface ?
  3. exporting excel data sheets to oracle
    we have oracle 8.0.5 (my client workstation nt4.0 service pack 5. excel 2000). how can export excel data sheets to oracle database by using odbc data source direct not through access microsoft?
  4. Access to Oracle.
    Hi, I have never worked on migration from Access to Oracle. I have few tables in Access , identical to which i have tables in Access and Excel. Example: A table DATA1 in Oracle A table DATA2 in Access A sheet DATA3.xls What should be the best and most convenient way to ...
  5. import Excel sheets in to ORACLE
    hi 1) please help me in importing Many Excel Spreadsheets in to a Table of Oracle Database. I dont want to do it Via MS Access. Is there any direct way to import Excel Spread sheets into a Table. 2) Is there any way to import Spread sheets into Oracle Database via Visual Basi...
  6. Need to do a mass upload the content of the Excel sheet int…
    I need to provide user a browse button. When user clicks the browse button it allows him to select the Excel sheet and after that when user clicks the submit button on the webpage. The content of the excel sheet has to be dumped into the oracle database. I need this option...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: hartPosted on 2004-03-31 at 01:30:20ID: 10722178

Also what i was thinking was to send the path and file name of the file as in parameters to the stored procedure and rest should be done by the sp..

can this be done :-)

Regards
Hart

 

by: schwertnerPosted on 2004-03-31 at 01:36:54ID: 10722215

You have to do this from Excel:

You are looking for information on the methods available for connecting  
MS-Excel 97 to Oracle using ODBC.  
   
Search Words:  
=============  
   
MICROSOFT  
MSQUERY  
QUERY
 
Solution Description:  
=====================  
   
There are two main methods available for connecting from MS-Excel to Oracle  
using ODBC. The first is via MS-Query and the second is using VBA. Both these  
methods require that you have a working Oracle ODBC datasource defined in the  
ODBC administrator.  
   
Connecting to Oracle using MS-Query:  
------------------------------------  
Pros: - Automated so no coding is involved  
Cons: - Formatting layout is limited to the SQL query's format  
      - Requires the use of a file DSN which is not yet creatable via the  
Oracle ODBC driver  
   
Note: To create a manual Oracle File DSN that points to an existing Oracle  
System DSN, use Notepad to create a file with a .dsn extension (eg.  
myoracle.dsn) that has the following two lines in it's document:  
   
  [ODBC]  
  DSN=<MyDSN> -- where <MyDSN> is the name of an existing System DSN  
   
This type of data import is performed via the Excel menu bar. Follow these  
steps:  
   
1) Click on the DATA option on the menu bar  
2) Click on the GET EXTERNAL DATA option on the menu dropdown list  
3) Click on the CREATE NEW QUERY option to launch MS-Query  
4) Connect to Oracle using a File DSN as described above  
5) A Query Wizard will appear to allow you to select/format data  
   
   
Connecting to Oracle using MS-VBA:  
----------------------------------  
Pros: - Formatting layout is completely customizable  
Cons: - Involves coding and a knowledge of MS-Basic  
   
This type of data import is performed via an Excel macro. Follow these steps:  
   
1) Click on the TOOLS option on the menu bar  
2) Click on the CUSTOMIZE option on the menu dropdown list  
3) Check the FORMS option in the options list  
4) Create a button on the spreadsheet using the "Forms" toolbar  
5) This will create a default macro named Buttonx_Click  
6) In the Visual Basic editor, go to the MENU->TOOLS->REFERNECES and check MS  
RDO 2.0  
7) Copy the following code in the Buttonx_Click macro to finish the sample:  
   
' Rdo Sample Code  
Sub Button1_Click()  
   
Dim RdoEnvironment As RdoEnvironment  
Dim RdoDatabase As rdoConnection  
Dim RdoRecordset As rdoResultset  
   
Dim connstr As String  
Dim sqlstmt As String  
   
connstr = "DSN=ORA32;UID=SCOTT;PWD=TIGER;"  
sqlstmt = "select * from emp"  
   
Set RdoEnvironment = rdoEnvironments(0)  
Set RdoDatabase = RdoEnvironment.OpenConnection("", rdDriverNoPrompt, False, _  
  connstr)  
Set RdoRecordset = RdoDatabase.OpenResultset(sqlstmt, _  
  rdOpenDynamic, rdConcurRowver)  
   
r = 10  
c = 1  
While Not RdoRecordset.EOF  
  ActiveSheet.Cells(r, c + 0) = RdoRecordset("EMPNO").Value  
  ActiveSheet.Cells(r, c + 1) = RdoRecordset("ENAME").Value  
  ActiveSheet.Cells(r, c + 2) = RdoRecordset("JOB").Value  
  ActiveSheet.Cells(r, c + 3) = RdoRecordset("MGR").Value  
  ActiveSheet.Cells(r, c + 4) = RdoRecordset("HIREDATE").Value  
  ActiveSheet.Cells(r, c + 5) = RdoRecordset("SAL").Value  
  ActiveSheet.Cells(r, c + 6) = RdoRecordset("COMM").Value  
  ActiveSheet.Cells(r, c + 7) = RdoRecordset("DEPTNO").Value  
  RdoRecordset.MoveNext  
  r = r + 1  
Wend  
   
End Sub  
   
   
-- or --  
   
   
' MS-Query API Sample Code  
Sub Button1_Click()  
   
Dim connstr As String  
Dim sqlstmt As String  
   
connstr = "ODBC;DSN=ORA32;UID=SCOTT;PWD=TIGER;"  
sqlstmt = "select * from emp"  
   
With ActiveSheet.QueryTables.Add(Connection:=connstr,  
Destination:=Range("A10"))ActiveSheet.QueryTables(1).Sql = sqlstmt  
ActiveSheet.QueryTables(1).BackgroundQuery = False  
ActiveSheet.QueryTables(1).Refresh  
   
End With

 

by: hartPosted on 2004-03-31 at 01:40:35ID: 10722233

schwertner : did u read my question sir ??

i can't create a dsn on the file
"PS: Also i cannot create a dsn on the excel sheet as this may differ w.r.t user."

is there some sysytem procedure which helps me to read data directly from the file [no dsn ]

Regards
Hart

 

by: riazpkPosted on 2004-03-31 at 01:45:30ID: 10722262

Algo keep visiting :

http://www.experts-exchange.com/Databases/Oracle/Q_20938386.html

A Question on the Same Subject.

 

by: hartPosted on 2004-03-31 at 02:21:53ID: 10722474

ok thanks so far but let me more clear, just tell me if this can be done or not...

if heterogenous service has to be used, then how do i go about it, is there any documentation on this part

if i can't create a dsn, can i use utl_file.fopen() and do something with it.

please give some snippets or codes that will read through an excel sheet and insert data.

thats all i am asking for. has no one ever done this ???

Regards
Hart

 

by: schwertnerPosted on 2004-03-31 at 03:13:28ID: 10722704

This is the only known way to do this.
The docs you need can be downloaded from the OTN in regard to the Oracle version you use.
The explanation of UTL_FILE is in the OTN doc "Supplied PL/SQL packages"

 

by: anand_2000vPosted on 2004-03-31 at 03:37:43ID: 10722797

check out http://www.oraxcel.com
It might help you. I believe it is quite helpful.

 

by: anand_2000vPosted on 2004-03-31 at 03:39:08ID: 10722802

 

by: seazodiacPosted on 2004-03-31 at 04:49:50ID: 10723153

@hart:

except for plsql which is limited in handling proprietary format, do you know JAVA?

we do this loading part from excel to oracle using JAVA...


is this acceptable solution?

 

by: hartPosted on 2004-03-31 at 04:55:05ID: 10723188

does anyone know about sql*loader and how to use it, i found out that even that can be used...

Regards
Hart

 

by: hartPosted on 2004-03-31 at 05:08:21ID: 10723268

the basic requirement was this...

1. user uploads an excel sheet...
2. it gets renamed to an uniqueid from th db..
3. now what i have to do is read this file insert into the database.
4. i am a coldfusion developer and i know how to read the data from the xls file using cf, but then i require a dsn for it.
5. the dsn can't be set as the files are dynamic..
6. so i thought if theres a way i could do this process using a stored procedure which takes in the file name and path and just runs a loop on it and inserts it into the db would be great.
7. i could also consider java, if java can run a loop on the file with out a dsn.
8. eventually what i would do is call a class file pass two parameters to it and the rest will be done by the java class.
9. i hope java doesn't require dsn for doing this


So here i am hoping for a concrete solution

Regards
Hart

 

by: seazodiacPosted on 2004-03-31 at 05:08:22ID: 10723269

yes, but sqlloader is strictly working on the text file not binary files.

 

by: schwertnerPosted on 2004-03-31 at 05:31:06ID: 10723414

The normal way if you use SQL*Loader is:
1. Create the relevant Oracle tables
2. Save the Excel sheet as CVS file.
3. Using the CVS file as input to SQL*Loader to place the Excel data in the Oracle table.

This method is the most used. You can find here more examples how to manage the SQL*Loader to do this.

 

by: aabbasPosted on 2004-03-31 at 05:55:15ID: 10723600

hart:
After reading your true requirement, the only thing that hits my mind is "Oracle interMedia".

User will upload Excel file, and the file will actually loaded into the database. This way, you will not need to rename the file as unique-id, rather a primary column for the uploaded files' table will solve the purpose.

Oracle interMedia has a lot of other powerful features. Just hang to it and you will find a true managable and scalable solution.

Best of luck.

 

by: seazodiacPosted on 2004-03-31 at 06:00:10ID: 10723630

@Hart:

seriously agree with aabbas.

I meant to recommend oracle intermedia to you in the first place, but I am afraid that it's too advanced for you to tackle ...

I don't mean to be rude, but for most of times, the poster here ask for just quick and dirty, one time solution...

Oracle intermedia allows you to load all types of documents to Oracle database,
such as MS word, excel, pdf , html, and provide a means to convert them into other formats....
and it also faciliate the mining and analysis of those documents.

 

by: aabbasPosted on 2004-03-31 at 06:00:16ID: 10723631

OR if you get the Excel files of same columns (identical column names/types), and you intend not to use interMedia, you can create a utility, which will be scheduled to work on each upload (or may be periodically) to convert Excel file to CSV file (Comma Separated Values) and load the rows in certain table using SQL*Loader.

When you talk about bulk data loading, nothing is as easy as Oracle SQL*Loader.

Hope, it will through some light for you towards SOLUTION.

 

by: DanielztPosted on 2004-03-31 at 06:18:37ID: 10723800

 

by: alligatorsqlPosted on 2004-03-31 at 09:07:39ID: 10725321

Hello,

Just some questions: Do you have installed Excel on the system, where your database ist installed ?
Reading the excel file directly from a stored procedure is possoble with UTL_FILE ... that is true ... but what happens then ?
You get binary coded characters into a PL/SQL var. This Excel file is encrypted, so that you can not access XLS directly without EXCEL
itselfs ... do you know what I mean.
So ... If you have installed EXCEL on your database server system (for example an NT) - You are able to write a DLL extent function
to read the excel file and transport the cell values to you stored procedure. We have several examples to do that.
So, if you need help in creating such a DLL - pls let me know.

Hope that helps?

Best regards
Manfred Peter

 

by: hartPosted on 2004-04-01 at 00:10:07ID: 10730283

thank you all...

Regards
Hart

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...