Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Req: best way to copy a record?
currently I'm doing the following:
Dim rs As ADODB.Recordset Dim rsNew As ADODB.Recordset Dim av() As Variant Set rs = New ADODB.Recordset Set rs.ActiveConnection = oConnection rs.Source = sSQL rs.CursorType = adOpenDynamic rs.LockType = adLockOptimistic rs.Open On Error GoTo Err_RecordsetOpen If not rs.EOF Then 'clone record found Set rsNew = rs.Clone ReDim av(rs.Fields.Count) For iIndex2 = 0 To rs.Fields.Count - 1 av(iIndex2) = rs(iIndex2) Next rsNew.AddNew For iIndex2 = 0 To rs.Fields.Count - 1 rsNew(iIndex2) = av(iIndex2) Next rsNew!PrimaryKeyField = "new primary key value" rsNew.Update
There has to be a better way, no?
On Mon, 03 Apr 2000 19:45:53 GMT, michael.engshun_at_usa.net (Michael Engshun) wrote:
>Hi everyone.
>
>Using Oracle 8.x , VB 6.x, and ADO 2.x, what is the best way to copy
>an existing record from a table, change the primary key and insert it?
>
>Basically I have a recordset that I'm using as a template, and the
>only thing that changes is the primary key for the actual instance
>(like copying a employee record).
>
>Thanks in advance!
>
>(was previosly posted on comp.databases.oracle.misc and
>microsoft.public.vb.database)
>
>Regards,
>M. Engshun
>michael.engshun_at_usa.net
Received on Mon Apr 03 2000 - 18:36:29 CDT
![]() |
![]() |