Clears the copy buffer and begins a record insertion operation into the specified dynaset and associated database.
AddNew operation is initiated, values of fields present within the dynaset are maintained in a copy buffer and do not reflect the actual contents of the database.
The values of the fields are modified through the
OraField object, and committed with an
Update operation or when database movement occurs, which discards the new row. Field values that have not been explicitly assigned are either set to
Null or allowed to default by way of the Oracle default mechanism, depending on the Column Defaulting mode of the options flag used when the
OpenDatabase method was called. In either case, fields that appear in the database table but not in the dynaset are always defaulted by the Oracle default mechanism.
Internally, records are inserted by the
AddNew method using the
(...)" SQL statement, and are added to the end of the table.
When adding a row that has object, collection, and
REF columns, these column values should be set to a valid
OraRef interface or to the
Null value. The column values can also be set with the automation object returned by the
CreateOraObject method. When adding a row having a
BFILE column, the column value should be set to a valid
Empty. Setting a
BFILE column to an
Empty value inserts an empty LOB value into the database.
Note:A call to
Deletemethods cancels any outstanding
AddNewmethod calls before proceeding. Any outstanding changes not saved using an
Updatemethod are lost during the cancellation.
This example demonstrates the use of the
Update methods to add a new record to a dynaset. Copy 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&) 'Begin an AddNew. OraDynaset.AddNew 'Set the field(column) values. OraDynaset.Fields("EMPNO").Value = "1000" OraDynaset.Fields("ENAME").Value = "WILSON" OraDynaset.Fields("JOB").Value = "SALESMAN" OraDynaset.Fields("MGR").Value = "7698" OraDynaset.Fields("HIREDATE").Value = "19-SEP-92" OraDynaset.Fields("SAL").Value = 2000 OraDynaset.Fields("COMM").Value = 500 OraDynaset.Fields("DEPTNO").Value = 30 'End the AddNew and Update the dynaset. OraDynaset.Update MsgBox "Added one new employee." End Sub