BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

MS SQLServer "FOR UPDATE"

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder Databases
View previous topic :: View next topic  
Author Message
Magnus
Guest





PostPosted: Thu Oct 26, 2006 12:06 am    Post subject: MS SQLServer "FOR UPDATE" Reply with 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 ");
Back to top
Magnus
Guest





PostPosted: Thu Oct 26, 2006 6:59 am    Post subject: Re: MS SQLServer "FOR UPDATE" - update Reply with quote



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





PostPosted: Fri Oct 27, 2006 1:41 am    Post subject: Re: MS SQLServer "FOR UPDATE" Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder Databases All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.