Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2004

    Unanswered: Updating Unique Primary Keys

    I'm accessing Oracle data using oo4o VB. Here's the problem:
    I'd like to update the unique keys like below. How would I
    implement it using oo40 oradynaset. If it can't be done,
    how to implement it in ADO?

    Ukey (Original -> Target Data)
    10 -> 11
    11 -> 12
    12 -> 10

    Have tried it but there's a unique key violation error
    after I call the Oradynaset.Update method for each row.
    I use begintrans/committrans.

  2. #2
    Join Date
    Sep 2002
    Provided Answers: 1
    If the unique constraint has been defined as DEFERRABLE than you could set it to DEFERRED before doing the updates; that way it will not be checked until you commit all the changes, at which time all the keys will be unique again.

    Alternatively, you can just introduce a dummy key value:

    12 -> 9999999
    11 -> 12
    10 -> 11
    9999999 -> 10

  3. #3
    Join Date
    Jun 2004
    The table used is variable, could be deferrable or not deferrable
    so I can't use that option. The recordset is actually used in a
    grid (TDBGrid), everytime I edit and change row, I must change the
    source data (recordset) somehow temporarily so that cell display
    will not revert to original value. Isn't there some kind of batch
    update in oo4o? In ADO, will adLockBatchOptimistic do the trick?
    Will adLockBatchOptimistic work in Oracle db?


  4. #4
    Join Date
    Jun 2004
    Have tried adLockBatchOptimistic in ADO recordset.
    Then issued .BatchUpdate after I have finished editing
    the rows. Still there was primary key violation error
    from Oracle. It seems BatchUpdate still updates the
    changes by row.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts