Solved

Union View locking records

Posted on 2013-12-10
9
335 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
Comment Utility
A union query (view) is always non updateable.

You will need to develop an alternative for updating records.

Kelvin
0
 

Author Comment

by:LJKMartin
Comment Utility
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
Comment Utility
Hmmmm,
is not behaviour I've experienced before. I don't have any suitable databases around at the moment to test.

Kelvin
0
 
LVL 40

Expert Comment

by:Vadim Rapp
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
Comment Utility
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
Comment Utility
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
Comment Utility
Thank-you Zberteoc - a simple solution that works.
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
Comment Utility
Awesome - I learnt something new today!
0
 
LVL 40

Expert Comment

by:Vadim Rapp
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

763 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

7 Experts available now in Live!

Get 1:1 Help Now