 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Simon Yeung Guest
|
Posted: Mon Jul 26, 2004 3:47 am Post subject: 'How to know whether the table has been locked. |
|
|
I want to lock a table when someone access it, at this time, another user
cannot access the table. please tell me which command or method that can let
me know the state (locked or unlock) of table.
Thx
|
|
| Back to top |
|
 |
Dmitry Arefiev [gs-soft.r Guest
|
Posted: Mon Jul 26, 2004 6:01 am Post subject: Re: 'How to know whether the table has been locked. |
|
|
Hi Simon !
To answer with technical details i should know your RDBMS.
1) In general, most simple method will be to try lock a table.
If trial has been failed - table is locked (most probably).
2) Some RDBMS have API's returning extensive info and
statistic about own state. For example, Oracle has dynamic
views, including v$lock. It returns a list of all locks in
instance.
3) What for at all you need to lock full table ? May be some
subset of rows will be enough ? Try define precise subset
and keep it locked for minimal time ...
Regards,
Dmitry
--
Dmitry Arefiev, gs-soft Company, community.gs-soft.com
Personal - www.da-soft.com
SAPx - Delphi to SAP R/3 direct access
Saphir - SAP R/3 metadata on your fingertips
MetaBase - ERWIN model in Delphi applications
NCOCI8 - Freeware Delphi to ORACLE direct access
Simon Yeung wrote:
| Quote: | I want to lock a table when someone access it, at this time, another user
cannot access the table. please tell me which command or method that can let
me know the state (locked or unlock) of table.
Thx
|
|
|
| Back to top |
|
 |
Simon Yeung Guest
|
Posted: Mon Jul 26, 2004 6:43 am Post subject: Re: 'How to know whether the table has been locked. |
|
|
First, thank for your reply, and then sorry for missing some information.
I am using Microsoft SQL DB, development tool is delphi.
thank for your suggestion. I am using your first method now, although it is
work, i want to know whether have method to know the state of table. so i
need not to waiting for "time-out" message if the table is locked.
Thx for your attention
"Dmitry Arefiev [gs-soft.ru]" <darefiev (AT) gs-soft (DOT) ru> 在郵件
news:41049d51 (AT) newsgroups (DOT) borland.com 中撰寫...
| Quote: | Hi Simon !
To answer with technical details i should know your RDBMS.
1) In general, most simple method will be to try lock a table.
If trial has been failed - table is locked (most probably).
2) Some RDBMS have API's returning extensive info and
statistic about own state. For example, Oracle has dynamic
views, including v$lock. It returns a list of all locks in
instance.
3) What for at all you need to lock full table ? May be some
subset of rows will be enough ? Try define precise subset
and keep it locked for minimal time ...
Regards,
Dmitry
--
Dmitry Arefiev, gs-soft Company, community.gs-soft.com
Personal - www.da-soft.com
SAPx - Delphi to SAP R/3 direct access
Saphir - SAP R/3 metadata on your fingertips
MetaBase - ERWIN model in Delphi applications
NCOCI8 - Freeware Delphi to ORACLE direct access
Simon Yeung wrote:
I want to lock a table when someone access it, at this time, another
user
cannot access the table. please tell me which command or method that can
let
me know the state (locked or unlock) of table.
Thx
|
|
|
| Back to top |
|
 |
Dmitry Arefiev [gs-soft.r Guest
|
Posted: Mon Jul 26, 2004 1:05 pm Post subject: Re: 'How to know whether the table has been locked. |
|
|
Hi Simon !
1) To avoid waiting time-out use following batch query:
SET LOCK_TIMEOUT 0;
SELECT * FROM MyTab WITH(ROWLOCK,UPDLOCK) WHERE ...
And see MSSQL docu, chapter "Locking Hints", for details about
content of WITH clause. TABLOCK may be interesting for you.
2) See SP_LOCK system procedure. It returns info about current locks
in system.
Regards,
Dmitry
--
Dmitry L. Arefiev, gs-soft Company, http://www.gs-soft.com
Personal - http://www.da-soft.com
SAPx - Delphi to SAP R/3 direct access
Saphir - SAP R/3 metadata on your fingertips
MetaBase - ERWIN model in Delphi applications
GISx - GIS system booster and simplifier
NCOCI8 - Freeware Delphi to ORACLE direct access
SCard - Complete PKCS11 and X509 solution
|
|
| Back to top |
|
 |
Simon Yeung Guest
|
Posted: Tue Jul 27, 2004 2:05 am Post subject: Re: 'How to know whether the table has been locked. |
|
|
Dear Dmitry:
Thx so much, I don't know that I can set lock timeout, it is very useful
command.
Regards,
Simon
"Dmitry Arefiev [gs-soft.ru]" <darefiev (AT) da-soft (DOT) com> 在郵件
news:41050047 (AT) newsgroups (DOT) borland.com 中撰寫...
| Quote: | Hi Simon !
1) To avoid waiting time-out use following batch query:
SET LOCK_TIMEOUT 0;
SELECT * FROM MyTab WITH(ROWLOCK,UPDLOCK) WHERE ...
And see MSSQL docu, chapter "Locking Hints", for details about
content of WITH clause. TABLOCK may be interesting for you.
2) See SP_LOCK system procedure. It returns info about current locks
in system.
Regards,
Dmitry
--
Dmitry L. Arefiev, gs-soft Company, http://www.gs-soft.com
Personal - http://www.da-soft.com
SAPx - Delphi to SAP R/3 direct access
Saphir - SAP R/3 metadata on your fingertips
MetaBase - ERWIN model in Delphi applications
GISx - GIS system booster and simplifier
NCOCI8 - Freeware Delphi to ORACLE direct access
SCard - Complete PKCS11 and X509 solution
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|