If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Slow INSERT speed

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-16-03, 18:42
ed207_us ed207_us is offline
Registered User
 
Join Date: Dec 2003
Posts: 1
Slow INSERT speed

For this particular application I am using Visual Basic and Interbase 6.0. I have a very good OLE DB provider and is working just fine. My problem is that I would like to find the fastest way possible to insert new records into a table. Right now I am just transfering some older data from an Access table to the Interbase table. I will have to do this for awhile before I transfer completely over. In the future the ADO recordset would be replaced with some arrays. Right now I am getting about 50 inserts per second. I appreciate any help thanks!

Dim fCount As Long
Dim i As Long
Dim tmpStr As String
Dim rCount As Long
Dim Phone As Double
Dim strState As String
Dim strFlag As String
Dim pVal As Long


Set tmpRec = New ADODB.Recordset
tmpStr = "SELECT * FROM DNC"
If tmpRec.State <> adStateClosed Then tmpRec.Close
tmpRec.Open tmpStr, DBCON.OLDDB.ConnectionString, adOpenDynamic, adLockBatchOptimistic

If DBCON.LeadsDB.State <> adStateOpen Then DBCON.LeadsDB.Open

PB1.Value = 0
pVal = 0
Do While Not tmpRec.EOF
DBCON.LeadsDB.BeginTrans
Phone = CDbl(tmpRec.Fields("PHONE").Value)
strState = CStr(tmpRec.Fields("STATE").Value)
fCount = tmpRec.Fields.Count - 1
For i = 2 To fCount
If tmpRec.Fields.Item(i).Value <> "" Then strFlag = tmpRec.Fields.Item(i).Value
tmpStr = "INSERT INTO LOCALDNC(PHONE,ST,FLAG) VALUES(" & Phone & ",'" & strState & "','" & strFlag & "')"
If Len(strFlag) = 3 Then

DBCON.LeadsDB.Execute tmpStr


Else
Exit For
End If
DBCON.LeadsDB.CommitTrans
DBCON.LeadsDB.BeginTrans
Next i
tmpRec.MoveNext
pVal = pVal + 1
If pVal Mod 10 = 0 Then


Command1.Caption = pVal & " Records Processed"
DoEvents
End If
If pVal Mod 10000 = 0 Then
If ((pVal / rCount) * 100) < PB1.Max Then PB1.Value = ((pVal / rCount) * 100)
End If

Loop
Set tmpRec = Nothing
DBCON.LeadsDB.CommitTrans
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On