Solved

Table problems (Oracle linked table)

Posted on 2011-02-17
7
368 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now