Solved

Union View locking records

Posted on 2013-12-10
9
370 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
  • 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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 47

Expert Comment

by:Dale Fye (Access MVP)
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 26

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
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.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

830 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