Re: Transaction problem (delete / select)
From: Joao Rosa (joaorosa_at_netcabo.pt)
Date: 01/18/05
- Next message: Mac: "Re: Weird stuff happening with views after upgrade to 2000"
- Previous message: Jason Thorn: "Re: SQL Server Bug: Using scalar functions within a subquery ON Cl"
- In reply to: Mike Epprecht (SQL MVP): "Re: Transaction problem (delete / select)"
- Next in thread: David Browne: "Re: Transaction problem (delete / select)"
- Reply: David Browne: "Re: Transaction problem (delete / select)"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 18 Jan 2005 17:32:50 -0000
I confirmed that the problem is the locks when using delete.
I use the isolation level for transactions as read commited, so the chages i
made in computer 1 not visible in computer 2 until the end of the
transaction.
I understand your answer but i tried the same thing on Access 2000 and
oracle 9i and no problem ocurred, only with sql server 2000.
Forgive my ignorance but is any way to work around?
Can the locks be configured?
I'm gonna explain the code i have, and the context:
In computer 1 i have a form with data from table students and a grid from
table students_payments.
The table students_payments contains the payments that the students have
made.
When editing a student i can also delete, edit or insert in the grid
payments for the student.
The transaction begins before editing the student and ends when i don't need
to edit anymore.
Until then the table students_payments had several rows changed that cannot
be visible to others users until i commit the transaction.
The problem is here when i delete 1 row from table students_payments the
other users cannot use this table.
The transaction ends when i close the form (save or cancel).
Regards from Portugal
Joćo Rosa
---------------------------------------
"Mike Epprecht (SQL MVP)" <mike@epprecht.net> escreveu na mensagem
news:10451535-E9C6-4BCC-9A05-BF5FF56CCF4F@microsoft.com...
> Hi
>
> It is not a bug. This behavior can be expected. SQL Server may take a row
> lock or a page lock during the delete. If you select needs to access a row
> that is on the same page as the record that is being deleted, the select
has
> to wait.
>
> Having a good clustered index can help alleviate the problem.
>
> Having long running transactions, including ones that do DB work, then
wait
> for user input before they commit are going to have terrible blocking
> problems.
>
> Regards
> Mike
>
> "Joao Rosa" wrote:
>
> > Hi Mike
> > Thanks for you help.
> >
> > The delete is using a where clause. (sorry not to mention it).
> > begin transaction
> > delete from [table A] where [field 1] = [value]
> >
> >
> > Until i do not make a commit or rollback on computer 1, shouldn“t the
> > computer 2 bewave normaly? Like there is no change going on computer 1?
> > Until the end of the transaction the table should be available to fetch
all
> > records, so the changes going on computer 1 are not efective, and on
> > computer 2 it should work normaly.
> >
> > I tried with Access 2000 and this is not a problem.
> > Could it be a bug, or some other thing?
> >
> >
> > I hope i explained things well.
> > Sorry for my english.
> >
> > Regards from Portugal
> > Joćo Rosa
> > ---------------------------------------
> >
> >
> > "Mike Epprecht (SQL MVP)" <mike@epprecht.net> escreveu na mensagem
> > news:16F9FEB5-7002-48BD-AC71-ED1202A8A990@microsoft.com...
> > > Hi
> > >
> > > Do you have WHERE clauses in the DELETE and SELECT statements?
> > >
> > > If not, you are expecting SQL Server to look at data that will all be
> > removed.
> > >
> > > You could add the lock hint into the select "WITH (NOLOCK)", but be
aware,
> > > you could be reading rows that are removed by the time the data is
> > returned
> > > to you client program.
> > >
> > > What are you trying to do?
> > >
> > > Regards
> > > Mike
> > >
> > > "Joao Rosa" wrote:
> > >
> > > > I have 2 computers linking to sql server 2000.
> > > >
> > > > computer 1:
> > > > ....
> > > > begin transaction
> > > > delete from [table A]
> > > > ....
> > > >
> > > > computer 2:
> > > > select * from [table A]
> > > >
> > > >
> > > > While the transaction is on computer 1, the select command on
computer 2
> > > > hangs, until computer 1 makes a commit or rollback.
> > > > This only happens with the delete command, the insert and update are
ok.
> > > > The code in computer 1 is gona take a while to execute until a
commit or
> > > > rollback can be made, meanwhile computer 2 needs to access the
table.
> > > > I tried inclusive in sql analyzer with the same results.
> > > >
> > > >
> > > > If anyone could help, i apreciated.
> > > > Thanks
> > > >
> > > > Joćo Rosa
> > > >
> > > >
> > > >
> >
> >
> >
- Next message: Mac: "Re: Weird stuff happening with views after upgrade to 2000"
- Previous message: Jason Thorn: "Re: SQL Server Bug: Using scalar functions within a subquery ON Cl"
- In reply to: Mike Epprecht (SQL MVP): "Re: Transaction problem (delete / select)"
- Next in thread: David Browne: "Re: Transaction problem (delete / select)"
- Reply: David Browne: "Re: Transaction problem (delete / select)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|