Solved

Table problems (Oracle linked table)

Posted on 2011-02-17
7
388 Views
Last Modified: 2013-11-05
Hi Experts

I have a oracle table with 3 primary keys, that together are not unique. One of the primary keys is a empty column that i want to update with a unique number. Is that possible?
0
Comment
Question by:DCRAPACCESS
  • 4
  • 3
7 Comments
 
LVL 23

Expert Comment

by:OP_Zaharin
ID: 34914164
You can't create a primary key if the combination of the three field is not unique. You should update the empty field with unique number (or running number) first. Only after that you create the primary key.
0
 

Author Comment

by:DCRAPACCESS
ID: 34914308
Hi op zaharin

it looks like this might work?

Dim rs As DAO.Recordset
Dim inti As Integer
Set rs = CurrentDb.OpenRecordset("SELECT id FROM xxx", dbOpenDynaset)
inti = 0
With rs
    Do Until .EOF
        .Edit
        inti = inti + 1
        !ID = inti
        .Update
        .Bookmark = .LastModified
    .MoveNext
    Loop
End With

but this was only tested on a access table and not the oracle table.
0
 
LVL 23

Accepted Solution

by:
OP_Zaharin earned 500 total points
ID: 34914327
OR during the insert statement into the table, include the unique/running number to that "empty field".

if u are using Oracle, you can use Oracle sequence. Create a trigger for that table so that everytime a record is inserted to that table, the trigger will create a unique running number (using sequence).
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 23

Expert Comment

by:OP_Zaharin
ID: 34914407
Your code will do it for now.

But what if after the primary key have been created and you want to insert a new record to the table? So the next step is for you to modify by adding the unique number calculation into the insert statement for new records.
0
 

Author Comment

by:DCRAPACCESS
ID: 34914427
Long story, but i can't insert new rows or put a sequence on the table. I'm only allowed to update the fields from access or delete rows. Please don't ask why (bureaucracy at my work).
0
 
LVL 23

Expert Comment

by:OP_Zaharin
ID: 34940607
Hi DCRAPACCESS,
Have u able to update the field and create the primary key?
0
 

Author Closing Comment

by:DCRAPACCESS
ID: 34940690
Sorry for the late answer. But it worked.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question