Skip Headers
Oracle® Objects for OLE Developer's Guide
11g Release 2 (11.2) for Microsoft Windows

Part Number E12245-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

Edit Method

Applies To

OraDynaset Object

Description

Begins an edit operation on the current row by copying the data to the copy buffer.

Usage

oradynaset.Edit
oradynaset.DbEdit  

Remarks

The Edit method causes the locally cached data to be compared to the corresponding row of an Oracle Database. An error is generated if Oracle Database data is not the same as the data currently being browsed. If this operation succeeds, the row is locked using a "SELECT ... FOR UPDATE" statement until the edit is completed with an Update method or until database movement occurs, which discards any edits in progress. The behavior of the "SELECT ... FOR UPDATE" statement is affected by the Lock Wait mode of the options flag used when the OpenDatabase method was called.

Note:

The cached data is not compared to the database with BLOB and CLOB, Object, REF, and collection types, and the data is updated regardless (dirty writes).

During editing, changes made to fields are kept in a shadowed copy buffer and do not yet reflect the actual contents of the database. However, all references to the row return the newly modified data as long as the edit operation is still in progress.

When data is modified within a data control attached to this dynaset, the Edit method is invoked automatically upon the next record movement. Thus, this method is required only when modifications are made to field data within code.

Note:

A call to an Edit, AddNew, or Delete method cancels any outstanding Edit or AddNew calls before proceeding. Any outstanding changes not saved using an Update operation are lost during the cancellation.

Examples

This example demonstrates the use of the Edit and Update methods to update values in a database. Copy and paste this code into the definition section of a form. Then, press F5.

Sub Form_Load ()
 
'Declare variables
Dim OraSession As OraSession 
Dim OraDatabase As OraDatabase 
Dim OraDynaset As OraDynaset 
 
'Create the OraSession Object.
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
 
'Create the OraDatabase Object by opening a connection to Oracle.
Set OraDatabase = OraSession.OpenDatabase("ExampleDb", "scott/tiger", 0&)
 
'Create the OraDynaset Object.
Set OraDynaset = OraDatabase.CreateDynaset("select * from emp", 0&)
 
 'Traverse until EOF is reached, settingeach employee's salary to zero
 Do Until OraDynaset.EOF
   OraDynaset.Edit
   OraDynaset.Fields("sal").value = 0
   OraDynaset.Update
   OraDynaset.MoveNext
 Loop
 MsgBox "All salaries set to ZERO."
 
End Sub