Solved

Insert row into Oracle table using VBA

Posted on 2000-04-12
5
2,385 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 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