 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Magnus Guest
|
Posted: Thu Oct 26, 2006 12:06 am Post subject: MS SQLServer "FOR UPDATE" |
|
|
Hi,
I use the below stmt to do a "lock" on the table.
It works great on JDS and MySQL but I get the following error on MS SQL
Server 2000:
e:com.microsoft.sqlserver.jdbc.SQLServerException: Line 1: FOR UPDATE
clause allowed only for DECLARE CURSOR.
Can anyone point me in the right direction here?
TIA
---
rs = stmt.executeQuery("select path from location " +
"where compid = \'" + compId + "\' " +
"and location = \'" + location + "\' " +
"FOR UPDATE "); |
|
| Back to top |
|
 |
Magnus Guest
|
Posted: Thu Oct 26, 2006 6:59 am Post subject: Re: MS SQLServer "FOR UPDATE" - update |
|
|
Magnus wrote:
| Quote: | Hi,
I use the below stmt to do a "lock" on the table.
It works great on JDS and MySQL but I get the following error on MS SQL
Server 2000:
e:com.microsoft.sqlserver.jdbc.SQLServerException: Line 1: FOR UPDATE
clause allowed only for DECLARE CURSOR.
Can anyone point me in the right direction here?
TIA
---
rs = stmt.executeQuery("select path from location " +
"where compid = \'" + compId + "\' " +
"and location = \'" + location + "\' " +
"FOR UPDATE ");
I managed to get it to work using 2 statements: |
stmt.executeUpdate("DECLARE cursor_name CURSOR FOR " +
"select path from location " +
"where compid = \'" + compId + "\' " +
"and location = \'" + location + "\' " +
"FOR UPDATE ");
rs = stmt.executeQuery("select path from location " +
"where compid = \'" + compId + "\' " +
"and location = \'" + location + "\' ");
I don't know if this will lock the rows though.
After I'm done, as part of cleaning up, I "DEALLOCATE cursor_name" to
release everything. Otherwise I got an error the second time I went to
the same setup screen and tried to insert more values ... |
|
| Back to top |
|
 |
John Moore (TeamB) Guest
|
Posted: Fri Oct 27, 2006 1:41 am Post subject: Re: MS SQLServer "FOR UPDATE" |
|
|
Magnus
Sorry, but I have not tried anything like that recently.. Remember these
forums are primarily for the support of DataExpress, therefore more
general JDBC/Driver support issues should be posted to the specific JDBC
vendor's support forums.. (for the best answers..)
John..
wrote:
| Quote: | Hi,
I use the below stmt to do a "lock" on the table.
It works great on JDS and MySQL but I get the following error on MS SQL
Server 2000:
e:com.microsoft.sqlserver.jdbc.SQLServerException: Line 1: FOR UPDATE
clause allowed only for DECLARE CURSOR.
Can anyone point me in the right direction here?
TIA
---
rs = stmt.executeQuery("select path from location " +
"where compid = \'" + compId + "\' " +
"and location = \'" + location + "\' " +
"FOR UPDATE ");
|
--
=============================================
TeamB are volunteer helpers. Please DO NOT REPLY VIA EMAIL!
Post all questions and replies to this newsgroup ONLY
For papers on DataExpress, Applets, JSP, and Web Development go to:
http://www.microps.com/mps/paperFAQ.html
==================================================== |
|
| 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
|
|