Account Options

  1. Sign in
Google Groups Home
« Groups Home
excel to oracle
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tim B  
View profile  
 More options Oct 5 2007, 10:37 am
Newsgroups: comp.databases.oracle.misc
From: "Tim B" <nos...@someisp.ca>
Date: Fri, 05 Oct 2007 14:37:55 GMT
Local: Fri, Oct 5 2007 10:37 am
Subject: excel to oracle
I have some data in an Excel spreadsheet - about 100 -200 records - that I
need to import into Oracle, likely with some transformation required. I can
convert it to csv or xml via MS Access and then set it up as an external
table and proceed from there. What other ways could you suggest that might
be feasible for this task? Is there another way to do it with xml as the
source?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Charles Hooper  
View profile  
 More options Oct 5 2007, 11:16 am
Newsgroups: comp.databases.oracle.misc
From: Charles Hooper <hooperc2...@yahoo.com>
Date: Fri, 05 Oct 2007 08:16:19 -0700
Local: Fri, Oct 5 2007 11:16 am
Subject: Re: excel to oracle
On Oct 5, 10:37 am, "Tim B" <nos...@someisp.ca> wrote:

> I have some data in an Excel spreadsheet - about 100 -200 records - that I
> need to import into Oracle, likely with some transformation required. I can
> convert it to csv or xml via MS Access and then set it up as an external
> table and proceed from there. What other ways could you suggest that might
> be feasible for this task? Is there another way to do it with xml as the
> source?

If you have Access, the easiest way to do this is to:
1. Connect to the Excel spreadsheet as an external table source in
Excel
2. Create a query in Access to retrieve all rows from the Excel
spreadsheet and rename the columns so that they match the Oracle
table.
3. Create an external table source connection to the Oracle table
(through an ODBC connection).
4. Modify the query definition so that it is an append query, and
select the connection to the Oracle table.
5. Run the query.

Much easier than it is to explain.

Charles Hooper
IT Manager/Oracle DBA
K&M Machine-Fabricating, Inc.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark D Powell  
View profile  
 More options Oct 5 2007, 11:50 am
Newsgroups: comp.databases.oracle.misc
From: Mark D Powell <Mark.Pow...@eds.com>
Date: Fri, 05 Oct 2007 08:50:13 -0700
Local: Fri, Oct 5 2007 11:50 am
Subject: Re: excel to oracle
On Oct 5, 11:16 am, Charles Hooper <hooperc2...@yahoo.com> wrote:

Or you can just save the data as a delimited file via Excel save as
and feed the delimited file into a sqlldr task that contains the
reformatting functions as part of the load.

Then again you could potentially use an external table to mask the
file and process it via Oracle.

Charles method is good if you know Access.  If not, a little scripting
can automate the file transfer and load.

The best way to do this might depend on if this is going to be a
repeated process and if you want it to be customer driven or if it
needs to be a regular scheduled task.

HTH -- Mark D Powell --


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
joel garry  
View profile  
 More options Oct 5 2007, 7:17 pm
Newsgroups: comp.databases.oracle.misc
From: joel garry <joel-ga...@home.com>
Date: Fri, 05 Oct 2007 16:17:19 -0700
Local: Fri, Oct 5 2007 7:17 pm
Subject: Re: excel to oracle
On Oct 5, 7:37 am, "Tim B" <nos...@someisp.ca> wrote:

> I have some data in an Excel spreadsheet - about 100 -200 records - that I
> need to import into Oracle, likely with some transformation required. I can
> convert it to csv or xml via MS Access and then set it up as an external
> table and proceed from there. What other ways could you suggest that might
> be feasible for this task? Is there another way to do it with xml as the
> source?

Last week someone suggested Apex, so I gave it a try.  It was real
easy (I mean including downloading XE, installing, creating a wizard
and cut-and-pasting a spreadsheet into it), but it screwed up on
special characters like copyright.

I normally use awk in korn shell scripts to masticate and load csv's
with sqlplus or sqlloader.  Then I can deal with the special
characters, commas, ampersands and other cleansing issues, since
people do all sorts of weirdness getting stuff into Excel, thinking
they are being helpful.

jg
--
@home.com is bogus.
What's not in your database?  http://www.signonsandiego.com/uniontrib/20071002/news_1m2russian.html


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim B  
View profile  
 More options Oct 5 2007, 9:16 pm
Newsgroups: comp.databases.oracle.misc
From: "Tim B" <nos...@someisp.ca>
Date: Sat, 06 Oct 2007 01:16:11 GMT
Local: Fri, Oct 5 2007 9:16 pm
Subject: Re: excel to oracle

"Charles Hooper" <hooperc2...@yahoo.com> wrote in message

news:1191597379.577870.194270@r29g2000hsg.googlegroups.com...

Well, today I found out that for every record I import from my spreadsheet I
will need to add a record to an additional table, and I'll have to deal with
a couple of sequences. What I'm likely going to do is import the spreadsheet
into Access and use some VBA to read the records, create the needed insert
statements, and save them to a text file. I'll keep your solution in mind
for when  I have a more straightforward import to do. Thanks.

Tim B


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Malcolm Dew-Jones  
View profile  
 More options Oct 5 2007, 10:17 pm
Newsgroups: comp.databases.oracle.misc
From: yf...@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Date: 5 Oct 2007 18:17:15 -0800
Local: Fri, Oct 5 2007 10:17 pm
Subject: Re: excel to oracle
Tim B (nos...@someisp.ca) wrote:

: I have some data in an Excel spreadsheet - about 100 -200 records - that I
: need to import into Oracle, likely with some transformation required. I can
: convert it to csv or xml via MS Access and then set it up as an external
: table and proceed from there. What other ways could you suggest that might
: be feasible for this task? Is there another way to do it with xml as the
: source?

Excel can directly access Oracle queries, but I haven't used it recently
enough to say if this would help or how to do it.

Perl can use module Spreadsheet-ParseExcel (from CPAN) to input excel, and
then DBI DBD-Oracle to write to Oracle.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Charles Hooper  
View profile  
 More options Oct 6 2007, 7:14 am
Newsgroups: comp.databases.oracle.misc
From: Charles Hooper <hooperc2...@yahoo.com>
Date: Sat, 06 Oct 2007 04:14:53 -0700
Local: Sat, Oct 6 2007 7:14 am
Subject: Re: excel to oracle
On Oct 5, 9:16 pm, "Tim B" <nos...@someisp.ca> wrote:

Expanding on a suggestion by Malcolm Dew-Jones - just do it all in
Excel.  Following is a code sample that I produced a while ago to show
someone how to select from and update an Oracle database based on the
values in an Excel spreadsheet.  Word wrapping will make this a little
ugly, but each line is indented, so it should be easy to undo the word
wrapping.

Macro security must be medium or low to access the macro.  The macro
code looks like this:
------------------------------------
Sub CheckSpreadsheet()
    Dim dbMyDB As New ADODB.Connection
    Dim snpData As New ADODB.Recordset
    Dim intLastRowChecked
    Dim intFoundFirstBlank
    Dim intResult As Integer
    Dim intColumn
    Dim strColumn
    Dim strFilename
    Dim strWorkbookname
    Dim strSheet
    Dim strExcelValue
    Dim strSQL
    Dim strMessage

    'You must create a reference to Microsoft ActiveX Data Objects
(Tools menu)

    'Make sure that we don't crash - looks ugly
    On Error Resume Next

    'Replace MyODBCConnection with an ODBC connection name, MyUserName
with a database user name and MyPassword with the user's password
    dbMyDB.ConnectionString = "Data Source=MyODBCConnection;User
ID=MyUserName;Password=MyPassword;"

    dbMyDB.ConnectionTimeout = 40
    dbMyDB.CursorLocation = adUseClient
    dbMyDB.Open

    strWorkbookname = Right(ActiveWorkbook.FullName,
Len(ActiveWorkbook.FullName) - InStrRev(ActiveWorkbook.FullName, "\"))
    strSheet = ActiveSheet.Name

    intLastRowChecked = 1 'Set to skip the first row
    intColumn = 65  'Column A
    strColumn = Chr(intColumn)

    Do While intFoundFirstBlank = False
        intLastRowChecked = intLastRowChecked + 1

        'Read the value from the spreadsheet
        strExcelValue =
Format(Workbooks(strWorkbookname).Worksheets(strSheet).Range(strColumn
& Format(intLastRowChecked)).Value)

        If strExcelValue = "" Then
            intFoundFirstBlank = True
        Else
            'Could perform an INSERT statement rather than a SELECT
statement
            strSQL = "SELECT" & vbCrLf
            strSQL = strSQL & "  LINE_NO," & vbCrLf
            strSQL = strSQL & "  PART_ID," & vbCrLf
            strSQL = strSQL & "  USER_ORDER_QTY," & vbCrLf
            strSQL = strSQL & "  DESIRED_SHIP_DATE" & vbCrLf
            strSQL = strSQL & "FROM" & vbCrLf
            strSQL = strSQL & "  CUST_ORDER_LINE" & vbCrLf
            strSQL = strSQL & "WHERE" & vbCrLf
            strSQL = strSQL & "  CUST_ORDER_ID='" & strExcelValue &
"'" & vbCrLf
            strSQL = strSQL & "ORDER BY" & vbCrLf
            strSQL = strSQL & "  DESIRED_SHIP_DATE"

            snpData.Open strSQL, dbMyDB

            Do While Not snpData.EOF
                strMessage = strExcelValue & "/" &
Format(snpData("line_no")) & " " &
Format(snpData("desired_ship_date"), "m/d/yyyy") & " " &
snpData("part_id") & " Qty " & Format(snpData("user_order_qty"))
                MsgBox strMessage

                snpData.MoveNext
            Loop
            snpData.Close
        End If
    Loop

    Set snpData = Nothing
    dbMyDB.Close
    Set dbMyDB = Nothing
End Sub
------------------------------------

The above macro pulls customer order IDs out of the spreadsheet (in
column A, stopping when a blank cell is found), and for each of those
customer orders, lists the order lines in the database, sorted by
desired ship date.  Change it around a little, and you can then update
the database, rather than just querying information from the database.

With the above method, it should not be a problem dealing with
sequences.

Charles Hooper
IT Manager/Oracle DBA
K&M Machine-Fabricating, Inc


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Niall Litchfield  
View profile  
 More options Oct 6 2007, 1:58 pm
Newsgroups: comp.databases.oracle.misc
From: Niall Litchfield <niall.litchfi...@dial.pipex.com>
Date: Sat, 06 Oct 2007 18:58:45 +0100
Local: Sat, Oct 6 2007 1:58 pm
Subject: Re: excel to oracle

Tim B wrote:
> Well, today I found out that for every record I import from my spreadsheet I
> will need to add a record to an additional table, and I'll have to deal with
> a couple of sequences. What I'm likely going to do is import the spreadsheet
> into Access and use some VBA to read the records, create the needed insert
> statements, and save them to a text file. I'll keep your solution in mind
> for when  I have a more straightforward import to do. Thanks.

If you are going to write vba, why not just do it from excel and avoid
the access intermediate step altogether.

--
Niall Litchfield
Oracle DBA
http://www.orawin.info/services


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim B  
View profile  
 More options Oct 8 2007, 1:37 pm
Newsgroups: comp.databases.oracle.misc
From: "Tim B" <nos...@someisp.ca>
Date: Mon, 08 Oct 2007 17:37:03 GMT
Local: Mon, Oct 8 2007 1:37 pm
Subject: Re: excel to oracle

"Charles Hooper" <hooperc2...@yahoo.com> wrote in message

news:1191669293.305305.13870@o80g2000hse.googlegroups.com...

<snip useful code example>
Thanks for the example code, it will save me some time if  end up doing it
all in Excel.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »