Results 1 to 9 of 9

Thread: locking a record with SQL

  1. #1

    Thread Starter
    Addicted Member trasher's Avatar
    Join Date
    Jun 2001
    Location
    Quebec city, Qc, Canada
    Posts
    255

    locking a record with SQL

    I want to lock (read-only) a record with an SQL statement.

    How can I do that ?
    I'm not an expert in sql....

  2. #2

    Thread Starter
    Addicted Member trasher's Avatar
    Join Date
    Jun 2001
    Location
    Quebec city, Qc, Canada
    Posts
    255
    is it possible do to that with a select statement ??

  3. #3
    Fanatic Member Bonker Gudd's Avatar
    Join Date
    Mar 2000
    Location
    Saturn
    Posts
    748

    Well ...

    Yeah, with SQL Server you can put (UPDLOCK) after the table name in the FROM clause to lock the data you've selected until you update it.
    What database are you using?

  4. #4

    Thread Starter
    Addicted Member trasher's Avatar
    Join Date
    Jun 2001
    Location
    Quebec city, Qc, Canada
    Posts
    255
    That's complicated..
    My database is on an AS/400 server.
    I'm using an activeX called ActiveObject/400
    With this activeX , there's a control wich can be use to send sql commands on the server. This is why I wanted to know if it was possible to do so...
    Maybe I should use a ADO or something like this to send my command...

    Thanks for any help

  5. #5
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    Locking is not supported by standard SQL - there may be extensions that support it (as with SS7) but it is application specific. The locking is almost always defined by the database engine and can be passed off to the driver (e.g. OLE DB or ODBC). It is not possible to give you an outright answer because it depends upon your specific database.

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  6. #6

    Thread Starter
    Addicted Member trasher's Avatar
    Join Date
    Jun 2001
    Location
    Quebec city, Qc, Canada
    Posts
    255
    that's what I thought, but I wanted to be sure that it was impossible to do this with a standard sql command..

    thanks for help

  7. #7

    Thread Starter
    Addicted Member trasher's Avatar
    Join Date
    Jun 2001
    Location
    Quebec city, Qc, Canada
    Posts
    255
    But I heard that it was a pissibility to use locking with the command Set Transaction ...
    But Ì don't know much more about this command..

  8. #8
    Fanatic Member Bonker Gudd's Avatar
    Join Date
    Mar 2000
    Location
    Saturn
    Posts
    748

    Well ...

    BEGIN TRANSACTION starts a transaction and COMMIT ends it. You could try these in your SQL, everything must be done in the same session though.

  9. #9
    Addicted Member
    Join Date
    Jan 1999
    Posts
    165

    TRANS

    Hi,
    I think you will find that TRANSACTIONS do not neccessarily lock the records. Without going into too much detail you would need to consider the Transactional Level being enforced.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width