![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
From: "Arnie" <99yoda (AT) newsgroup (DOT) nospam Subject: SQLS 2000 Record Locking Problems (VC++) Date: Fri, 7 Apr 2006 16:26:04 -0400 Lines: 35 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original Message-ID: <ugnfPFoWGHA.1348 (AT) TK2MSFTNGP05 (DOT) phx.gbl Newsgroups: microsoft.public.sqlserver.odbc NNTP-Posting-Host: 24-151-53-204.dhcp.nwtn.ct.charter.com 24.151.53.204 Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFT NGP05.phx.gbl Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.sqlserver.odbc:44877 X-Tomcat-NG: microsoft.public.sqlserver.odbc Sorry for the wordiness. VC++ 8.0, XP Pro SP2, etc. We're porting from Borland C++ Builder/ADO to VC++/ODBC. This worked fine with BCB/ADO. First, the rationale. We have a number of 'batch' (console) apps that can not be run at the same time due to possible conflicts in DB tables. The apps can be run on a number of different servers, and they all access the same DB, so named semaphores were out. We were using a DB table as a semaphore. The idea was to insert a row in the table with the name of a table that should be 'logically' locked. The locked table name column name is unique. We don't actually want to lock the table itself because other read only programs should be able to use the table. I'm sorry if that isn't crystal clear. Here's the problem. I put together a test program in order to determine the problem. Very simply, - Set up the hEnv and hDbc stuff. - Execute "SET LOCK_TIMEOUT 2000" - Set SQL_AUTO_COMMIT_OFF - Execute the INSERT statement - Wait for keyboard input Run the program. Fine. Run another instance and it 'hangs' on the INSERT. Where's my timeout? The second instance won't "come back" until the first instance terminates. Thanks for any help, - Arnie |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
From: "Arnie" <99yoda (AT) newsgroup (DOT) nospam References: <ugnfPFoWGHA.1348 (AT) TK2MSFTNGP05 (DOT) phx.gbl 3ZrASsEXGHA.888 (AT) TK2MSFTNGXA01 (DOT) phx.gbl Subject: Re: SQLS 2000 Record Locking Problems (VC++) Date: Mon, 10 Apr 2006 09:14:11 -0400 Lines: 20 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Message-ID: <uAMQ5BKXGHA.3800 (AT) TK2MSFTNGP03 (DOT) phx.gbl Newsgroups: microsoft.public.sqlserver.odbc NNTP-Posting-Host: 24-151-53-204.dhcp.nwtn.ct.charter.com 24.151.53.204 Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFT NGP03.phx.gbl Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.sqlserver.odbc:44881 X-Tomcat-NG: microsoft.public.sqlserver.odbc Thanks for your reply. Waiting for keyboard input is only done in the test program. It is done so that I can run the second instance of the program to see what happens when it tries to insert an identical record. The problem is that the second instance 'hangs' on the SQLExecute that attempts the insert. Therefore, there is no return code. If I allow the first instance to complete, then the second instance returns from the SQLExecute with, as expected, a unique constraint violation. My question is: Why doesn't the second instance time out? Does the lock timeout value apply to all SQL statements or just to a SELECT? Thanks, - Arnie |
![]() |
| Thread Tools | |
| Display Modes | |
| |