Single Record / Row Locking

Aug 16, 2007

From SQL Server Books Online, there is a topic: Concurrency Effects, and did mention the following side effects:

- Lost updates.
- Uncommitted dependency (dirty read).
- Inconsistent analysis (nonrepeatable read).
- Phantom reads.

Can someone please tell me which type of Isolation Levels in the Database Engine to avoid the above side effects respectively.

For Record Locking issue:
Example, two editors make an electronic copy of the same document. Each editor changes the copy independently and then saves the changed copy thereby overwriting the original document. The editor who saves the changed copy last overwrites the changes made by the other editor.
This problem could be avoided if one editor could not access the file until the other editor had finished and committed the transaction.

For the above example, is it possible to do like this way:
Editor 1: SELECT and Lock a record
Editor 2: Before SELECT the record, check for the record whether it is locked or not. If it is not lock, then the record can be selected

Please advise.

Thanks.


View 2 Replies


ADVERTISEMENT

Query Timeouts When Updating A Record Retrieved Through A Websphere JDBC Datasource - Possible Record Locking Problem

Apr 7, 2008

Hi,

We're running a Sage CRM install with a SQL Server 2000 database at the back end. We're using the Sage web services API for updating data and a JDBC connection to retrieve data as it's so much quicker.

If I retrieve a record using the JDBC connection and then try and update the same record through the web services, the query times out as if the record is locked for updates. Has anyone experienced anything similar or know what I'm doing wrong? If I just use DriverManager.getConnection() to establish the connection instead of the datasource, and then continue with the same code I don't get these record locking problems. Please find more details below.

Thanks,
Sarah

The JDBC provider for the datasource is a WebSphere embedded ConnectJDBC for SQL Server DataSource, using an implementation type of 'connection pool datasource'. We are using a container managed J2C authentication alias for logging on.

This is running on a Websphere Application Server v6.1.

Code snippet - getting the record thru JDBC:


DataSource wsDataSource = serviceLocator.getDataSource("jdbc/dsSQLServer");
Connection wsCon = wsDataSource.getConnection();


// wsCon.setAutoCommit(false); //have tried with and without this flag - same results

Statements stmt = wsCon.createStatement();


String sql = "SELECT * FROM Person where personID = 12345";
ResultSet rs = stmt.executeQuery(sql);


if(rs.next()){
System.out.println(rs.getString("lastName"));
}

if (rs != null){
rs.close();
}
if (stmt != null) {

stmt.close();
}
if (wsCon != null) {

wsCon.close();
}

View 1 Replies View Related

Record Locking

Oct 5, 2000

Hello,

I need help in record locking. As soon as user retrieve records I want to lock those records in database. When other user try to retrieve records from the same table i want to retrieve records those are not locked by other user. How do I do this? Please help...

Thanks in a millian.

Sarika

View 1 Replies View Related

Record Locking

Jul 26, 2001

Hello,

I have a database programmer who in his latest application has deployed manual record locking into code to release certain records to certain users of the application at specified times.

Does anyone know how manual record locking will affect the SQL 2K system? If at all? Are there some standard practices with manual record locking that should be enforced?

Thanks,
Brent.

View 3 Replies View Related

Need Help: Record Locking

Sep 7, 2007

Project spec:
If user is making Delivery Order for sales order,
the other user cannot make Delivery order for same sales order

How to lock a sales-order record, so other user cant use it, except for reporting (read only). I dont want to use a field since it has a lot of weakness. I am using VB6 and connect with ADO

Thanks

View 3 Replies View Related

Record Locking In ADO.net/Sql Server

Feb 18, 2005

Currently I am working on asp.net Intranet system.I need some suggestion on records locking for Sqlserver & ASP.net.
I want to prevent two user to open the same record for modify.Means if some one has open one record (id=xxxxx) for modify then others should not be able to open same same record (id=xxxxx) for modify .otherwise if both user will open/update same record then information in database will not be updated correctly.
Any idea how we can do the record locking so that not two users can open same record(id=xxxxx) for modify.

Thanks in Advance
Arvind

View 2 Replies View Related

How To Do The Record/row Level Locking In SQL 6.5/7.0?

Jan 3, 2000

I am writing a VB program, which needs to update record A in one table using transaction control (BeginTrans & CommitTrans). But due to the page-level locking, before the "CommitTrans", other users couldn't not read other records in the same table.

Is there any way that I can do the record/row level locking? If possible, could you provide me some VB source code? Such as how to use "DBCC ROWLOCK" or how to set for row-level locking.

Thanks for your kind help.

View 1 Replies View Related

Another Record Locking Issue...

Nov 15, 2004

Hi all,

I'm working on a Planning Databse for a factory that allows jobs to be allocated to machines and to be given a priority. This info. is displayed on an Access 2000 form e.g.

MACHINE ONE MACHINE TWO
Priority Job Number Priority Job Number
1 J111 1 J654
2 J562 2 J865
3 j231 3 J821

Both the Production Manager and the Factory Manager have this form open at all times. The problem is this, if for example the Factory Manager changes the priority of a job on his PC, the change is not shown on the Production Managers PC (cos' his screen has not been refreshed with update) The Production Manager therefore has old data on his screen and could mistakenly think that the job priority had not changed at all...
I have managed to write some VBA code to get round this but I was wondering if there was any way of 'pushing ' changes to the front-end when they are made or of using record-locking etc. to achieve the same affect...

Thanks
M

View 6 Replies View Related

SQL/Acces Record Locking

Dec 9, 2005

I am running an Access 2000 front end and MS SQL2000 as a backend and I am having problems with record locking.

I have just found out that If you use ODBC then Access acts as if No Locks are set. In an ideal world I need the record to be locked by a user as soon as they move onto it. If not as soon as they start editing it?

Cheers.

View 2 Replies View Related

Record Locking Bug/Issue

May 3, 2006

Hi there,

Up until this point I've been quite lazy in trying to understand how record locking really works in SQL server however one of my applications now has a bug so the time has come for me to take the issue seriously.

Basically, a user clicks a button in my app and updates a field in a table in SQL Server (say at 10:34:55). At the almost exactly the same time (lets say 10:34:57) another user tries to update the same record (not necessarily the same field) but the second users update is not connected to the database.

How can I store the second users update and then commit to database once the first user is finished...is it possible or do i need to approach this from a different angle?

Thanks

View 5 Replies View Related

Record Locking In Access ADP

Jul 23, 2005

I'm trying to figure out what happened.I have have two Tables in SQLServer called "Contacts", and "Jobs"Whenever someone changes a record in either table I update two fieldscalled "Modby" and "Moddt" with a trigger. The Trigger may alsocontain other things as well.Here's the wierd thing.If the Modby Moddt statement is the first statement in the trigger Idon't get a "record changed by another user" but if it comes later inthe trigger I do.I think it has something to do with the LockDelay Key but I'm not sure.Any Ideas?

View 3 Replies View Related

Locking An MSSQL Record With ADO.NET

Jul 23, 2005

Is there a way using ADO.NET to lock a record so that you can performan atomic Test and Set operation on one of its fields?I want to set an application level lock bit on a record's field (set itfrom 0 to 1) and at the same time determine that it was 0 before Ibegan and that I was the one who set it to 1, or that it was 1 before Igot to it (and thus I do not own the lock to the record).I don't see anything that explains if this can be done using ADO.NETusing MSSQL. Any help is greatly appreciated.

View 3 Replies View Related

ODBC And Record Locking

Mar 15, 2007

I found this interesting paper at http://ftp.sas.com/techsup/download/v8papers/odbcdb.pdf, comparing OLEDB to ODBC.

It says that OLEDB provides record locking where ODBC doesn't. I can't quite reconcile that statement; what does it mean? How is the access layer involved in determining type of locks used by the server in executing a statement?

.B ekiM

View 3 Replies View Related

What Is The Most Effective Method Of Record Locking?

Feb 25, 2004

I have built my own functions in the past that involve a timestamp and record lock column in each table (to support some other DB).

I am currently using SQL 2000 and was wondering if there is a better (OK, easier) way to lock records and even prevent edits from taking place when a record is open.

Any input appreciated.

View 25 Replies View Related

P2P Transactional Replication And Record Locking

Jul 15, 2007

I've been considering implementing a P2P Transactional Replication concept using three different sites. My qustion is:

Instead of have records only available for editing by specific sql servers (partitioning), can I implement some sort of record locking? For exampel all sql nodes have r/w access to all data unless one sql node has the record locked?

View 1 Replies View Related

Tricky Record Locking Problems

Jul 20, 2005

I have a problem with record locking / blocking within an application.The app is quite straight forward. Written in Delphi 5 using BDE toaccess a SQL 7 database (Win2K server).Every so often the users (when they bother to tell me) find that theapplication locks up and they are unable to work. No errors areproduced (error trapping in the app is good). They 'shout round' toeach other and get someone to exit the data entry screen. This seemsto free up the locking/blocking issue.There are about 50,000 records in the table (script below) and it isaccessed through a simple query (script below). All users will accessthis in the same way. I'm assuming that a new record is being editedwhen the problem occurs, but this shouldn't cause locking/blockinguntil it gets committed (right ?).The problem is tracking down the source of this and finding thepattern which I can work back from. I've used Erland's aba_lockinfoscript (a few months back admittedly so will re-visit this), butnothing obvious is jumping out at me.No other tables should be in use at this point.Any suggestions ?ThanksRyan/* Code for query component - users navigate to the record they needto editthere could be 15,000 records showing as outstanding - perhaps thisis the area that I need to re-visit so that less records can be edited? */SELECT *FROMPostReceivedWHEREToDelete = 0 ANDCompleted <> 1ORDER BYPostID/* Table in question */if exists (select * from sysobjects where id =object_id(N'[dbo].[PostReceived]') and OBJECTPROPERTY(id,N'IsUserTable') = 1)drop table [dbo].[PostReceived]GOCREATE TABLE [dbo].[PostReceived] ([PostID] [int] IDENTITY (1, 1) NOT NULL ,[Type] [varchar] (100) NULL ,[ClientsName] [varchar] (100) NULL ,[DateReceived] [datetime] NULL ,[EnteredBy] [varchar] (100) NULL ,[AssignedTo] [varchar] (100) NULL ,[DateAssignedTo] [datetime] NULL ,[Adviser] [varchar] (100) NULL ,[TargetDate] [datetime] NULL ,[CompletionDate] [datetime] NULL ,[Completed] [bit] NULL ,[KeyAccount] [varchar] (100) NULL ,[Notes] [text] NULL ,[Specific1] [varchar] (20) NULL ,[Specific2] [varchar] (20) NULL ,[Specific3] [varchar] (20) NULL ,[Specific4] [varchar] (20) NULL ,[Specific5] [varchar] (20) NULL ,[ToDelete] [bit] NULL ,[EnterUser] [varchar] (20) NULL) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]GO

View 3 Replies View Related

To Get An Unique Sequence Number (record Locking)

Aug 27, 2007

can someone pls show me a way to get an unique sequence at below senario:

PC1 & PC2 using their own local client progam to access to Database Server at SERVER1.
In the SERVER1, there is a table SEQUENCE in a database DATABASE1.
And the table's structure of SEQUENCE are SeqType & SeqNo.
Here is the sample data:

SeqType SeqNo
Invoice 100
DeliveryOrder 200

Now, how to prevent PC1 & PC2 to get a same Invoice No. if they request the Invoice No. at the same time?
Is it possible to lock the record Invoice when i perform a SELECT statement, then i update the Invoice to 101, lastly release the lock for Invoice?

pls advise. thanks.

View 1 Replies View Related

OLEDB Provider For DB2 - Record Locking &&amp; Open Sessions

Feb 13, 2008

We have a linked server configured on our SQL Server 2005 server that points to our iSeries. A step in a scheduled job successfully updates data in tables on the iSeries using an update query and the 4-part naming convention (job reports success and updates can be verified), but it appears to leave locked records and open connections on the iSeries. No open sessions showing in SQL Activity Monitor.

The linked server is configured using Microsoft's OLEDB Provider for DB2. Are there additional settings that can be configured on the linked server to prevent this behavior or is this an issue that need needs to be addressed on the iSeries? A timeout setting perhaps (not sure if this fixes the record locks though)?

Any help is greatly appreciated.

KS

View 2 Replies View Related

Can't Delete Single Record? HELP!

May 28, 2004

OK,

This one is driving me nuts. I've issued a very simple statement to delete a single row from a table. It appears that when I execute it in SQL Query Analyzer the CPUTime spikes and holds one of the CPUs on the box pegged at 100%. I've let this thing run for over a day, and it's not deleting the one damn record. Any thoughts? :confused: :confused: Here's the command I'm executing:

DELETE FROM Invoices WHERE InvoiceID = 153345

Running SELECT * FROM Invoices WHERE InvoiceID = 153345 returns only a single record as it should. InvoiceID is the PK in this table. Any and all help is greatly appreciated. I've rebooted the server, but to no avail. Same thing happens after a reboot.

TIA

View 12 Replies View Related

How To Get The 2nd The 2nd Record AND DISPLAY IN SINGLE ROW ?

Apr 18, 2006

Can you please assist me on how to get the 2nd record in case there are3 or more records of an employee, the query below gets the MAX and MINBasicSalary. However, my MIN Basic Salary is wrong because I should getthe Basic Salary Prior to the 1st Record (DESC)in case there are 3 ormore records and not the last Basic Salary of the Last Record.How to GET the 2nd Row of Record in Case that There are 3 or morerecords IN A SINGLE ROW ???---------------------------------------------------------------------------*-----This query gets the Max and Min Basic Salary on a certain Date Range.In case there are 5 records of an employee on certain date range howcan I get the record before the Max and would reflect as my OLDBASIC,if I use TOP2 DESC it will display 2 records. I only need one recordwhich should be the Basic Salary before the 1st record on a DESC order.Please add the solution to my 2nd Select Statement which get theOLDBASIC salary Thanks ...SELECT TOP 100 PERCENT E.EmployeeNo, E.LastName, E.FirstName,E.SectionCode, E.Department, E.DateHired, E.Remarks,(SELECT TOP 1 ([BasicSalary])FROM empsalaries AS T14WHERE T14.employeeno = E.employeeno AND startdate BETWEEN @FromDate AND@ToDateORDER BY startdate DESC) AS NEWBASIC,******************************* BELOW I SHOULD ALWAYS GET THE BASICSALARY PRIOR TO THE 1ST RECORD AND IN A SINGLE ROW ???(SELECT TOP 1 ([BasicSalary]) (FROM empsalaries AS T14WHERE T14.employeeno = E.employeeno AND startdate BETWEEN @FromDate AND@ToDateORDER BY startdate ASC) AS OLDBASICFROM dbo.Employees EWHERE CONVERT(VARCHAR(10),E.DateHired, 101) BETWEEN @FromDate AND@ToDate ORDER BY E.LastName

View 2 Replies View Related

Stopping A Single Record From Being Deleted

Sep 26, 2006

 I am using a drop down list box to select values from an SQL 2000 DB.  I have put a record into the table which says"...Select Item"I used the dots so that It will apear at the top of the list and therefore display at startup.  I also have a gridview to allow users to edit and delete from the same table.I am worried that a user may accidently delete the "...Select Item" row from the table.Can anyone think of a way round this?  Is it possible with SQL Server 2000 to stop a single record from being deleted?Any help would be most appreciated.ThanksPaul     

View 4 Replies View Related

Returning One Single Record Rather Than Multiples

Feb 12, 2007

HiIs it possible to return the results of a query so that instead ofhaving say 10 rows its concatenated, egMy query returns 'M' 10 times, can this be returned as 'M M M M M M MM M M'?ThanksLee

View 3 Replies View Related

Get Value Of A Single Record Instead Of Aggregated Value With GROUP BY

Oct 12, 2007

How to get


Code Block

a record value instead of aggregated value with GROUP BY?

Assume that I have a PRODUCT_COMMENT table defined as below. It logs
the multiple comments for products. A product may have multiple
comments logged at different time.





Code Block

CREATE TABLE [dbo].[PRODUCT_COMMENT](
[COMMENT_ID] [int] IDENTITY(1,1) NOT NULL,
[PRODUCT_ID] [int] NOT NULL,
[COMMENT] [nvarchar](50) NULL,
[UPDATED_ON] [datetime] NOT NULL,
CONSTRAINT [PK_PRODUCT_COMMENT] PRIMARY KEY CLUSTERED
(
[COMMENT_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[PRODUCT_COMMENT] WITH CHECK ADD CONSTRAINT
[FK_PRODUCT_COMMENT_PRODUCT] FOREIGN KEY([PRODUCT_ID])
REFERENCES [dbo].[PRODUCT] ([PRODUCT_ID])
GO
ALTER TABLE [dbo].[PRODUCT_COMMENT] CHECK CONSTRAINT
[FK_PRODUCT_COMMENT_PRODUCT]

I would like to use the following SQL statement to get the latest
comments for all products.







Code Block

SELECT PRODUCT_ID, COMMENT, UPDATED_ON
FROM PRODUCT_COMMENT
GROUP BY PRODUCT_ID
HAVING UPDATED_ON = MAX(UPDATED_ON)



But this leads to the following error:




Code Block

Column 'PRODUCT_COMMENT.UPDATED_ON' is invalid in the HAVING clause
because it is not contained in either an aggregate function or the
GROUP BY clause.



Is there a way to do that?

Thanks!

View 5 Replies View Related

Convert Single Record To Table

Sep 20, 2007

Hi all!

I have imported a table into SQL Server from a legacy program. Each record has a repeating sequence of similar fields. (Ex. Accnt1, Assesed1, Paid1, Accnt2, Assesed2, Paid2, etc.) I would like to take a single record and put data from these fields into a table that has the columns Accnt, Assesed, and Paid. I am doing this for easier use in a program I am developing in VB 2005. Can this be done in SQL or do I need to have help from some VB code? If it's possible, what might the SQL look like?

Thanks.

View 3 Replies View Related

How To Retriece Single Record In Database By Using SqlDataSource???

Jun 19, 2007

Is me again,and now i facing problem to retrieve a single record from the database.
here is my code:
 
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click        Dim user As String        user = TextBox1.Text        Dim varpassword        Dim mydata As SqlDataSource
        mydata.SelectCommand = "Select * from tbluser where uLogin = '" & user & "'"        varpassword = mydata.SelectCommand.uPassword
    End SubEnd Class
 
but i get the error : 'uPassword' is not a member of 'String'
i wan to retrieve the password of that user,can anyone help me?
thanks

View 3 Replies View Related

Single Statement To Delete Record Into More Tables

Aug 6, 2004

Hi ,

I little question for you ... is it possibile to write a SQL statement to delete records in several tables at the same time?

For example if I've two tables involved by join

DELETE <...> from Customers A
INNER JOIN CustomerProperties B ON A.CustomerID=B.CustomerID

I Must use two statement to remove records from both the tables?

Thx

View 3 Replies View Related

SP Return Multiple Records For A Single Record

May 3, 2007

I have two tables
TermID, Term
1--- Abc
2--- Test
4--- Tunic

and
TermID, RelatedTermID
1 --- 2
1--- 4
2--- 4

I need to get back something like this

TermID, Term, RelatedTermsInformation
1--- test--- test,tunic#1,4


that above was my solution, get the relatedterms information and comma separate, and then put a # and get all the ids comma separate them and then put the in one field. then I can later parse it in the client

this does not seem like a very good solution ( or is it?)
If posible it would be nice to get something like this

TermID, Term, RelatedTermsInformation
1 test RelatedTermsTwoDimentionalArray

but I am not sure how this idea could be implemented using the capabilities of SQL.

my other option is have the client make one call to the database to get the terms and then lots of another calls to get the relatedTerms, but that will mean one trip to the DB for the list term, and one call for every single term found.

any ideas in how to make this better ?

View 8 Replies View Related

Combine Multiple Rows Into Single SQL Record

Jan 28, 2008

Hello:

I have the following table. There are eight section IDs in all. I want to return a single row for each product with the various section results that I have information on.

productID SectionID statusID
10 1 0
10 2 1
10 3 2
10 4 1
10 5 3
10 6 1
11 1 0
11 2 1
11 3 2
11 7 3
11 8 3

Need to return two rows with the respective values for each section.

productID section1 section2 section3 section4 section5 section6 section7 section8
10 0 1 2 1 3 1
11 0 1 2 3 3

Any information or if you can point me in the right direction would be appreciated.

Thanks

View 4 Replies View Related

Config Table - Single Record For All Packages

May 2, 2008

Is there any way to use a single record (Which had Connection String) for all my packages in the project ?

I don't want to have multiple connection informations for each of the packages (Based on Configuration Filter)

View 3 Replies View Related

Concatenate Values From Same Column But Different Record In Single Row

Mar 26, 2008

Hi, I have a difficult case that I need to solve. I will try to be the very clear explaining my problem:


I have a sql query which brings me many records.
This records have a column in common which have the same value (COL1)

There is a second column (COL2) which has different values bewteen these records.
I need to concatenate values from the second column in records with same value in COL1. And I need only one record of the ones that have the same values. If two records have the same COL1 value, only one row should be in my result.

Let me give you an example:
COL1 COL2
RECORD1 1-A HHH
RECORD2 1-A GGG
RECORD3 1-B LLL
RECORD4 1-B MMM
RECORD4 1-B OOO
RECORD5 1-C NNN

Me result should be:


COL1 COL2
RECORD 1-A HHHGGG
RECORD 1-B LLLMMMOOO
RECORD 1-C NNN

It is clear what I need? I dont know if I can solve it through sql or any function inside SSIS.
Thanks for any help you can give me.

View 5 Replies View Related

SQL Server 2012 :: Query For Single Entry Record Only?

May 26, 2015

I have records like below, single query to get result below, basically records that has single entry only, which has type '0'

table : temp_test
idtype
c10
c25
c30
c40
c47
c59
c64
c60
c77
c80
c90

Result out of query

idtype
c10
c30
c80
c90

View 4 Replies View Related

Transact SQL :: Pull All Records From One Table And Just A Single Record From Another

Aug 7, 2015

I'm trying to pull all records from one table and just a single record from another.  I have this join, (see below).  It works ok, but the problem is if a blog record doesn't have a corresponding image record it doesn't return.  The end result should be the blog record and a single corresponding image record.  But always a blog record.

SELECT
[Blogs].[ID],
[Blogs].[BlogTitle],
[Blogs].[BlogType],
[Blogs].[BlogText],

[code]...

View 6 Replies View Related

Transact SQL :: How To Select A Single Record In A Left Join

Sep 16, 2015

My tables look like this:

 Users //
table
 UserID // pk
 UserName // varchar
UserFamilyName // varchar
User_Friends //
table
 FriendsID // pk
 UserID // fk
 FamilyName // varchar

MY query:

 SELECT
U.UserFamilyName, F.FamilyName
 FROM  
Users U LEFT
JOIN User_Friends
F ON U.UserID = 
F.UserID
 WHERE     
U.UserName = ‘JOHN’

How do I adjust my query to select just the very first record from Users_friends, I want only the top first one.And if there are no friends how can I return an empty string instead of Null.

View 10 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved