Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2535
  • Last Modified:

Insert row into Oracle table using VBA

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
cuckie
Asked:
cuckie
  • 2
  • 2
1 Solution
 
arcusdCommented:
ordatabase.execute "insert statment....
0
 
cuckieAuthor Commented:
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
 
gcs001Commented:
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
 
cuckieAuthor Commented:
Thanks, Grant.

That did the trick!
0
 
gcs001Commented:
Pleasure cuckie.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now