Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Oracle > Updating Unique Primary Keys

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-14-04, 05:46
josePidal josePidal is offline
Registered User
 
Join Date: Jun 2004
Posts: 3
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.
Reply With Quote
  #2 (permalink)  
Old 06-14-04, 06:21
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 4,874
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
__________________
Tony Andrews
http://tonyandrews.blogspot.com
Reply With Quote
  #3 (permalink)  
Old 06-14-04, 22:02
josePidal josePidal is offline
Registered User
 
Join Date: Jun 2004
Posts: 3
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?

thanks.
Reply With Quote
  #4 (permalink)  
Old 06-15-04, 03:16
josePidal josePidal is offline
Registered User
 
Join Date: Jun 2004
Posts: 3
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On