Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update record in Oracle

Status
Not open for further replies.

chris6user

Programmer
Dec 10, 2001
56
0
0
CA
I am trying to update certan record in Oracle table. For some reason it updates all the recods in this table. This is my code:

Dim RecSet As ADODB.Recordset

sSQL = "select * from export_val where rec_id = " & mvarRec_id
Set RecSet = New ADODB.Recordset
RecSet.Open sSQL, con, adOpenDynamic,adLockPessimistic
If RecSet.EOF Then
RecSet.AddNew
End If
RecSet!Rec_ID = mvarRec_id
RecSet!Year = mvarYear
RecSet.update
RecSet.Close

is something wrong with it?
 
Hi there

I don't use oracle, i use SQL but i have done similar type things.

This is a sample of code i have that worked:
Dim strsql As String
Dim rst As Recordset

Set rst = New ADODB.Recordset
rst.Open "SELECT * FROM Projects WHERE ProjectID = " & lngID, con, adOpenKeyset, adLockOptimistic

rst.Fields("ProjectCode").Value = strNumber
rst.Fields("Description").Value = strDesc

rst.Update

Set rst = Nothing

The differences are that I don't have
If rst.EOF Then
rst.AddNew
End If

because it's an update so you shouldn't need this.

Also I have adOpenKeyset, adLockOptimistic when i open my recordset and not adOpenDynamic,adLockPessimistic

Hope this helps!

Transcend
[gorgeous]
 
to Transcend,

I use addnew in case if the record does not exist to create a new one. But even if I remove it and change to adOpenKeyset is still updates everything. I use Oracle and adodb all the time and it works, the only diference this time I have windows xp.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top