Solved

Union View locking records

Posted on 2013-12-10
9
381 Views
Last Modified: 2013-12-10
Hi,

I have an Access front-end for a SQL server database.

In SQL Server I have created a view that is a union query on two of the tables.

The problem is that if a user is displaying the result of that union query, no-one can edit the data in the source tables.

Is that normal?

How can I present the data to one user, while allowing it to be edited by another?  In one form the users only need to see one record at a time (although it could be from either source table).  However there is another that displays all, so they can be filtered down to the ones that are of interest.

Cheers
0
Comment
Question by:LJKMartin
[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
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 39709517
A union query (view) is always non updateable.

You will need to develop an alternative for updating records.

Kelvin
0
 

Author Comment

by:LJKMartin
ID: 39709583
Hi Kelvin,

Yes, I know.  I'm not trying to update the union query.

If I open one of the tables directly, it won't let me change the data there while the union query is open in Access.
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 39709673
Hmmmm,
is not behaviour I've experienced before. I don't have any suitable databases around at the moment to test.

Kelvin
0
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 39709703
I just tried it, and saw no problem. I.e. in Access I opened linked table that is linked to the UNION view on sql server, and while it was opened, I was able to edit the records in the underlying tables on sql server from another application.

How is the result of the union query displayed in Access? do you have linked table? query? form?
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 39709715
How are you using the Union query (view) in Access (as a continuous form, datasheet, in a combo or list)?

Have you linked to the view?

Are you creating a recordset from the view?

Can you use a disconnected recordset (http://support.microsoft.com/kb/184397) to perform whatever function you are trying to perform with the union query?
0
 
LVL 27

Accepted Solution

by:
Zberteoc earned 500 total points
ID: 39709781
In the view code use the (NOLOCK) hint in the FROM or JOIN clauses next to any table name you query:

SELECT
   ...
FROM
   table1 t1 (nolock)
  inner join table2 t2 (nolock)
  ...

UNION
SELECT
   ...
FROM
   table3 t3 (nolock)
  inner join table4 t4 (nolock)
  ...
0
 

Author Closing Comment

by:LJKMartin
ID: 39709865
Thank-you Zberteoc - a simple solution that works.
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 39709936
Awesome - I learnt something new today!
0
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 39710024
I don't think it's very good solution, for the following two reasons.

1. This shouldn't be happening in the first place. Which means that something was wrong or misunderstood, and it's left that way. Usually when something is left misunderstood/unresolved, sooner or later it will come back.

2. If for whatever reason and in whatever way Access is placing the lock on the records, but in fact the lock is not in place due to (nolock) hint in sql server (of which Access is unaware), this may have unpredictable results in Access.

It would be better solution to find the exact reason in Access doing it, and eliminate it in Access. For instance, if the view is shown in Access form (the recommended way), or Query, check the form's/querie's property "record locks", and if it's set to "all records", change it accordingly.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

626 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