Solved

Insert row into Oracle table using VBA

Posted on 2000-04-12
5
2,359 Views
Last Modified: 2013-12-25
I am new to Visual Basic, so please humour me even if this is a dumb question!

I am using VBA in Excel 97. I have used Objects for Session, Database and Dynaset.

I can execute Oracle stored procedures
using :

dim session as object
dim oradatabase as object
dim oradynaset as object
dim query_string as string

Set orasession = CreateObject("OracleInProcServer.XOraSession")

Set oradatabase = orasession.DbOpenDatabase("dbalias", "userid/password", 0&)

query_string = "select oracle_stored_procedure(parm1, parm2) from dual"

set oradynaset = oradatabase.dbcreatedynaset(query_string, 0&)

Everything works out fine!

Now, I want to execute 'Insert into table values( ,  , )' kind of statements. And here I am lost on what is the way to go about achieving this.

This is a one-time code execution, so I don't need to worry about efficiency, modularity, etc.

I would appreciate samples of code which will enable me to do this.

Thanks,
Cuckie.
0
Comment
Question by:cuckie
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:arcusd
ID: 2710480
ordatabase.execute "insert statment....
0
 

Author Comment

by:cuckie
ID: 2712560
Hi arcusd,

I had tried this y'day afternoon. But for some reason I get the following error on the oradatabase.execute "insert into...." stmt :

Run-time error '438':
Object doesn't support this property or method

0
 
LVL 4

Accepted Solution

by:
gcs001 earned 100 total points
ID: 2713416
An easier way of seeing which properties/methods are available for the Oracle InProcServer is to reference the Oracle InProcServer using the Project-References menu and then to declare them as the appropriate types as in:

Dim OraSession As OraSession
Dim OraDatabase As OraDatabase
Dim OraDynaset As OraDynaset

This is commonly referred to as early binding.

Then if you type in OraDatabase. it will display a dropdown list of available properties/methods for the OraDatabase object.  See if you have ExecuteSQL there.

Regards,
Grant.

0
 

Author Comment

by:cuckie
ID: 2713802
Thanks, Grant.

That did the trick!
0
 
LVL 4

Expert Comment

by:gcs001
ID: 2713868
Pleasure cuckie.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now