Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- db_VISTA III - d_rblset http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   D_RBLSET

SUMMARY
   d_rblset([dbn])
   int dbn;

ARGUMENTS
   dbn         (optional)The number of the database containing the record

DESCRIPTION
   Function d_rlbset is called to set the record lock bit of the current
   record. The data file which contains the record need not be locked.
   The db_VISTA runtime  will automatically synchronize access to the record.
   The current record is accessed directly without using the cashe so that
   upon successfull completion of the call bit is physically set in the
   record on the disk.
   Function d_rlbset will return status S_UNAVAIL if the system cannot gain
   access to the data file (due to its being write or exclusive locked).
   Status S_LOCKED is returned if the current record's lock bit is already
   set.
   Status S_OKAY is returned when the function has succesfully set the lock
   bit If db_rlbset is called witin a transaction , the operation still goes
   directly to the file, bypassing use uf cashe.Thus, a d_trabort call does
   not undo any record lock bit settings which were performed within the
   transaction.

   No records which have been locked by the programm should remain locked
   after the database is closed. The DATABASE CONSISTENCY CHECK utility.
   dbcheck, can be used to report all record occurences which have the
   lock bit set.

   This function is present in the single user version of db_VISTA, but
   performs no action.This allows multi-user applications to link with the
   single user version for operation on stand-alone computer.

------------------------------------------------------------------------------
NOTE
   The setting of a record's lock bit will not automatically prevent another
   process from updating the locked record. It is the responsibility of the
   application to chek to see if a record occurence is locked before allowing
   updates to it either calling d_rlbset or d_rlbtst or cheking global integer
  variable rlb_status after reading the record's contens.
------------------------------------------------------------------------------

CURRENCY CHANGES
   None.

RETURN CODES

     0      S_OKAY       The lock bit has been successfully set.

     5      S_UNAVAIL    System unable to get access to the current
                         record's data file .Try again later.

     8      S_LOCKED     Current record's lock bit is already set.

    -7      S_NOCR       The cuurent record is null.


EXAMPLE
    /*fetch record to be modified*/
    ...
    if(d_rblset()!=S_OKEY)
    /* unable to access record*/
     ...
    else{
     /*display record and allow user to edit it*/
     ...
     d_trbegin("mod");
     while(d_reclock(REC,"w")==S_UNAVAIL)
        ;/*wait for file's become available */
     d_recwrite(&rec); /*update record*/
     d_rlbclr();       /*unlock record*/
     d_trend();        /*end transaction*/
    }

See Also: d_rlbset d_rlbtst

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson