Solved

Multiple inserts from VB6 to Oracle using ADO

Posted on 2003-10-23
4
661 Views
Last Modified: 2013-12-25
Hi,

I'm currently developing a DLL in VB 6 which will be contacting an Oracle database over WAN. This file will need to insert between 500 and 1000 rows from a text file to the database as fast as possible. When I've tested the performance of the DLL I've seen the performance is not as good as it should be. So far I've been using a loop like this:
...
    Set Reader = Fso.OpenTextFile(strSQLFileName, ForReading)
    Do Until Reader.AtEndOfStream
      strQuery = Reader.ReadLine
      If Len(strQuery) > 5 Then
          Conn.Execute strQuery
      End If
    Loop
...

Here is an example of the file content:
INSERT INTO c_u_s(c_i, s_g_i, s_f_i, crt_ts, upd_ts, s_v) VALUES('1-07', 'Scope', 'C_OD[2,1]', sysdate, sysdate, '''''');
INSERT INTO c_u_s(c_i, s_g_i, s_f_i, crt_ts, upd_ts, s_v) VALUES('1-07', 'Scope', 'C_ST[2,1]', sysdate, sysdate, '''AAW''');
INSERT INTO c_u_s(c_i, s_g_i, s_f_i, crt_ts, upd_ts, s_v) VALUES('1-07', 'Scope', 'C_SH[2,1]', sysdate, sysdate, '''--H3--''');

Now when I change the above code from
strQuery = Reader.ReadLine
to
strQuery = Reader.ReadAll
I get the error message "[Oracle][ODBC Oracle Driver][Oracle OCI]ORA-00911: invalid character"

I beleive I could improve the performance of the DLL by inserting all rows at once, but my question is, is it possible? And if it is possible how? Do I have to use some other method or object in ADO or?
0
Comment
Question by:GSA
  • 2
4 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 300 total points
ID: 9605017
you might try this:

strQuery = Reader.ReadAll
strQuery = "BEGIN " & replace(strQuery, vbcrlf, " ") & " END;"

Cheers
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 9605056
Try like:

Private Function ReadFileText(ByVal FileName As String) As String
    On Error GoTo EHandler
    Dim Handle As Integer
    Handle = FreeFile
    Open FileName For Input As #Handle
        ReadFileText = Input$(LOF(Handle), Handle)
        On Error Resume Next
    Close #Handle
    Exit Function
EHandler:
    On Error Resume Next
    Close #Handle
End Function

tmp = ReadFileText("C:\scripts.txt")
tmpArr = Split(tmp, vbcrlf)


for i = 0 to ubound(tmpArr)
       
     Conn.Execute tmpArr(i)

next i
0
 

Author Comment

by:GSA
ID: 9605058
Excellent. How easy life can be some times.

Cheers
Glenn
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 9605064
hmm.. i must be too late to refresh my browser before my post :-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

932 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

10 Experts available now in Live!

Get 1:1 Help Now