Re: Excel to Oracle, need a help

From: Dave Smith <scudderfish_at_my-dejanews.com>
Date: Mon, 05 Apr 1999 22:57:15 GMT
Message-ID: <7ebf47$j4o$1_at_nnrp1.dejanews.com>


In article <37040402$0$26227_at_fountain.mindlink.net>,   "Gennady" <gennadyb_at_halcosoftware.com> wrote:
> Hello,
> I need to create a procedure to insert and update data in Oracle database
> table
> from Excel spreadsheet. I use OO4O to connect Oracle.
> Could you give me a hint or reference to a sample, please?
>
> Gennady
>
>

OO4O should come with examples of interfacing to Excel. What version are you using? I can e-mail the files to you if you want. To get you started, here is part of one of the example sheets, which is concerned with copying data from Excel to an Oracle db.

Regards,
Dave

 Sub Update_Data()

  ' Create and initialize the necessary objects   Dim OraSession As Object
  Dim OraDatabase As Object
  Dim EmpDynaset As Object
  Dim ColNames As Object
  Set OraSession = CreateObject("OracleInProcServer.XOraSession")   Set OraDatabase = OraSession.OpenDatabase("2:", "scott/tiger", 0&)   Set EmpDynaset = OraDatabase.DbCreateDynaset("select * from emp", 0&)   Set ColNames = EmpDynaset.Fields

  i = 2

  ' the BeginTrans and CommitTrans are optional   OraSession.BeginTrans
  While Worksheets("DataSheet").Cells(i, 1).Value <> ""     EmpDynaset.dbedit
    For j = 1 To ColNames.Count
      ColNames(j - 1).Value = Worksheets("DataSheet").Cells(i, j).Value     Next j
    EmpDynaset.dbupdate
    EmpDynaset.dbmovenext
    i = i + 1
  Wend
  OraSession.CommitTrans

End Sub

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Tue Apr 06 1999 - 00:57:15 CEST

Original text of this message