Solved

Table problems (Oracle linked table)

Posted on 2011-02-17
7
406 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

707 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