Skip to Content

SQL Lock record

Is it possible to lock a record with a SQL command as one can do with MSSQL and WITH(ROWLOCK,UPDLOCK) or MYSQL and FOR UPDATE or LOCK IN SHARE MODE?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Nov 03, 2016 at 02:46 PM

    Anybody have a solution or suggestion?

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 04, 2016 at 06:26 AM

    I use the transaction to lock record

    BEGIN TRAN;

    UPDATE table SET field1=field1 WHERE key=xxxx;

    This record is locked until

    ROLLBACK WORK; or COMMIT WORK;

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 04, 2016 at 12:03 PM

    Thanks Igor, but I tried into Arc32 but it's not functionnal.

    1. Open my data dictionary with Arc32

    2. On list of table included in datadictionary, double click on one table

    3. Open a Windows of SQL utility and execute this SQL:

    BEGIN TRAN;
    UPDATE MyTable SET Field1=Field1 WHERE UniqueField=1;
    

    4. Returned in the window where my table is open and try to modify a record where the information UniqueField = 1 and save the change. The record is saved and I never received the error message 5035.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 04, 2016 at 12:29 PM

    Marius, I used this a lot of times. I think you need to save this connect as open

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 16, 2016 at 07:50 PM

    Marius,

    The help files state that, "Using SQL, it is not possible to control locking explicitly from an application". However, it is possible to create an explicit lock using the Advantage Client Engine, the Tdataset Descendant, or the .NET Data Provider. For other APIs such as ODBC and JDBC, you would need to use a technique similar to the one suggested by Igor.

    I hope this helps,

    Mike Loop - SAP Product Support

    Add comment
    10|10000 characters needed characters exceeded