Results 1 to 4 of 4

Thread: Console - Determining if a table is in use and in what cursor

  1. #1
    Senior Member
    Join Date
    Jan 2016
    Posts
    160

    Console - Determining if a table is in use and in what cursor

    I know there is a way to do this, but maybe someone can remind me of what command I use to see if a table is open and what cursors are in use. I tried used("table"), but it did not appear to work.

  2. #2
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,840
    Hi Rdd,

    Yes, USED("alias-name" | cursor-number), specifying the alias name or the cursor/workarea number - returns .T. or .F.

    Also INUSE("alias-name") - returns .T. or .F.

    Or SELECT("alias-name") - returns 0 or the cursor/workarea number if open.

    Did USED() return an error or just not the result you were expecting?

    Regards,

    Yvonne

  3. #3
    Member
    Join Date
    Sep 2013
    Location
    Bristol UK
    Posts
    95
    rdd,

    You should be able to use the Used() or the Inuse() functions to determine if a given table is open in any work area.

    One thing to note is that both functions accept an alias parameter rather than a table name so both used("employees") and inuse("employees") should return .T. if there is a table open with the alias "employees" in any work area.

    As far as I can see, the only difference between the two functions is that you can run used() without passing a parameter and it will return .T. if any table is open in the current work area. If you run inuse() without a parameter it will generate an error.

    So...

    close all
    select 1
    use southwindw!employees
    ?used() returns .T.
    ?used("employees") returns .T.
    ?inuse("employees") returns .T.

    select 2
    ?used() returns .F.
    ?used("employees") returns .T.
    ?inuse("employees") returns .T.
    ?used("company ") returns .F.

    close all
    select 1
    use southwindw!employees alias test1
    ?used() returns .T.
    ?used("employees") returns .F.
    ?inuse("employees") returns .F.
    ?used("test" returns .T.
    ?inuse("test") returns .T.
    Cheers,

    Rob C

  4. #4
    Senior Member
    Join Date
    Jan 2016
    Posts
    160
    Thanks Guys, great information. I figured it was something simple. I was forgetting the ? in front of the command.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us