Thread View: borland.public.jbuilder.database
3 messages
3 total messages
Started by Magnus
Wed, 25 Oct 2006 19:06
MS SQLServer "FOR UPDATE"
Author: Magnus
Date: Wed, 25 Oct 2006 19:06
Date: Wed, 25 Oct 2006 19:06
19 lines
1386 bytes
1386 bytes
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 ");
Re: MS SQLServer "FOR UPDATE" - update
Author: Magnus
Date: Thu, 26 Oct 2006 01:59
Date: Thu, 26 Oct 2006 01:59
37 lines
2361 bytes
2361 bytes
Magnus wrote:
> 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 ...
Re: MS SQLServer "FOR UPDATE"
Author: John Moore (TeamB)
Date: Thu, 26 Oct 2006 20:41
Date: Thu, 26 Oct 2006 20:41
39 lines
2168 bytes
2168 bytes
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:
> 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
====================================================
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads