UNLOCK

UNLOCK

Release file/record locks set by the current user

Syntax

      UNLOCK [ALL]

Arguments

ALL releases all current locks in all work areas. If not specified, only the lock in the current work area is released.

Description

UNLOCK is a network command that releases file or record locks set by the current user. Use it when you want to release the current lock without setting a new lock. Both FLOCK() and RLOCK() release the current lock before setting a new one.

After an UNLOCK, an update to a shared database file and associated index and memo files becomes visible to DOS and other applications, but is not guaranteed to appear on disk until you perform a COMMIT or close the file.

Refer to the “Network Programming” chapter in the Programming and Utilities Guide for more information on the principles of locking and update visibility.

Notes

. SET RELATION: UNLOCK does not automatically release a record lock along a RELATION chain unless you UNLOCK ALL.

Examples

      .  This example attempts an update operation that requires a
         record lock.  If the RLOCK() is successful, the record is updated
         with a user-defined function and the RLOCK() is released with UNLOCK:

      USE Sales INDEX Salesman SHARED NEW
      IF RLOCK()
         UpdateRecord()
         UNLOCK
      ELSE
         ? "Record update failed"
         BREAK
      ENDIF

Seealso

DBUNLOCK(), DBUNLOCKALL(), FLOCK(), RLOCK(), SET RELATION

SET SOFTSEEK

SET SOFTSEEK

Toggle relative seeking

Syntax

      SET SOFTSEEK on | OFF | <xlToggle>

Arguments

ON causes the record pointer to be moved to the next record with a higher key after a failed index search.

OFF causes the record pointer to be moved to EOF() after a failed index search.

<xlToggle> is a logical expression that must be enclosed in parentheses. A value of true (.T.) is the same as ON, and a value of false (.F.) is the same as OFF.

Description

SET SOFTSEEK enables relative seeking, a method of searching an index and returning a record even if there is no match for a specified key.

When SOFTSEEK is ON and a match for a SEEK is not found, the record pointer is set to the next record in the index with a higher key value than the SEEK argument. Records are not visible because SET FILTER and/or SET DELETED are skipped when searching for the next higher key value. If there is no record with a higher key value, the record pointer is positioned at LASTREC() + 1, EOF() returns true (.T.), and FOUND() returns false (.F.). FOUND() returns true (.T.) only if the record is actually found. It never returns true (.T.) for a relative find.

When SOFTSEEK is OFF and a SEEK is unsuccessful, the record pointer is positioned at LASTREC() + 1, EOF() returns true (.T.), and FOUND() returns false (.F.).

Notes

. SET RELATION: SET RELATION ignores SOFTSEEK updating the record pointer in all linked child work areas as if SOFTSEEK is OFF.

Examples

      .  This example illustrates the possible results of a SEEK with
         SET SOFTSEEK ON:

      SET SOFTSEEK ON
      USE Salesman INDEX Salesman NEW
      ACCEPT "Enter Salesman: " TO cSearch
      SEEK cSearch
      DO CASE
      CASE FIELD->Salesman = cSearch
         ? "Match found:", FOUND(), EOF(), FIELD->Salesman
      CASE !EOF()
         ? "Soft match found:", FOUND(), EOF(), ;
                  FIELD->Salesman
      OTHERWISE
         ? "No key matches:", FOUND(), EOF(), FIELD->Salesman
      ENDCASE

Seealso

FOUND(), SEEK, SET INDEX, SET ORDER, SET RELATION

JOIN

JOIN

Create a new database file by merging records/fields from two work areas

Syntax

      JOIN WITH <xcAlias> TO <xcDatabase>
             FOR <lCondition> [FIELDS <idField list>]

Arguments

WITH <xcAlias> is the name of the work area to merge with records from the current work area. You can specify it either as a literal alias or as a character expression enclosed in parentheses.

TO <xcDatabase> is the name of the target database file specified either as a literal filename or as a character expression enclosed in parentheses.

FOR <lCondition> selects only records meeting the specified condition.

FIELDS <idField list> is the projection of fields from both work areas into the new database file. To specify any fields in the secondary work area, reference them with the alias. If the FIELDS clause is not specified, all fields from the primary work area are included in the target database file.

Description

JOIN creates a new database file by merging selected records and fields from two work areas based on a general condition. JOIN works by making a complete pass through the secondary work area for each record in the primary work area, evaluating the condition for each record in the secondary work area. When the <lCondition> is true (.T.), a new record is created in the target database file using the FIELDS specified from both work areas.

If SET DELETED is OFF, deleted records in both source files (i.e., the two files being JOINed) are processed. However, their deleted status is not retained in the target <xcDatabase>. No record in the target file is marked for deletion regardless of its deleted status in either of the source files.

If SET DELETED is ON, no deleted records are processed in either of the source files. Thus, deleted records do not become part of the target <xcDatabase>. Similarly, filtered records are not processed and do not become part of the target file.

Warning! The number of records processed will be the LASTREC() of the primary work area multiplied by the LASTREC() of the secondary work area. For example, if you have two database files with 100 records each, the number of records JOIN processes is the equivalent of sequentially processing a single database file of 10, 000 records. Therefore, use this command carefully.

Examples

      .  This example joins Customer.dbf to Invoices.dbf to produce
         Purchases.dbf:
         USE Invoices NEW
         USE Customers NEW
         JOIN WITH Invoices TO Purchases;
            FOR Last = Invoices->Last;
            FIELDS First, Last, Invoices->Number, ;
               Invoices->Amount

Seealso

SET RELATION

C5_SET RELATION

SET RELATION
 Relate two work areas by a key value or record number
------------------------------------------------------------------------------
 Syntax

     SET RELATION TO [<expKey> | <nRecord> INTO <xcAlias>]
        [, [TO] <expKey2> | <nRecord2> INTO <xcAlias2>...]
        [ADDITIVE]

 Arguments

     TO <expKey> is an expression that performs a SEEK in the child work
     area each time the record pointer moves in the parent work area.  For
     this to work, the child work area must have an index in USE.

     TO <nRecord> is an expression that performs a GOTO to the matching
     record number in the child work area each time the record pointer moves
     in the parent work area.  If <nRecord> evaluates to RECNO(), the
     relation uses the parent record number to perform a GOTO to the same
     record number in the child work area.  For a numeric expression type of
     relation to execute correctly, the child work area must not have an
     index in USE.

     INTO <xcAlias> identifies the child work area and can be specified
     either as the literal alias name or as a character expression enclosed
     in parentheses.

     ADDITIVE adds the specified child relations to existing relations
     already set in the current work area.  If this clause is not specified,
     existing relations in the current work area are released before the new
     child relations are set.

     SET RELATION TO with no arguments releases all relations defined in the
     current work area.

 Description

     SET RELATION is a database command that links a parent work area to one
     or more child work areas using a key expression, record number, or
     numeric expression.  Each parent work area can be linked to as many as
     eight child work areas.  A relation causes the record pointer to move in
     the child work area in accordance with the movement of the record
     pointer in the parent work area.  If no match is found in the child work
     area, the child record pointer is positioned to LASTREC() + 1, EOF()
     returns true (.T.), and FOUND() returns false (.F.).

     The method of linking the parent and child work areas depends on the
     type of <expKey> and presence of an active index in the child work area.
     If the child work area has an active index, the lookup is a standard
     SEEK.  If the child work area does not have an active index and the type
     of <expKey> is numeric, a GOTO is performed in the child work area
     instead.

 Notes

     .  Cyclical relations: Do not relate a parent work area to itself
        either directly or indirectly.

     .  Soft seeking: SET RELATION does not support SOFTSEEK and
        always behaves as if SOFTSEEK is OFF even if SOFTSEEK is ON.  This
        means that if a match is not found in the child work area, the child
        record pointer is always positioned to LASTREC() + 1.

     .  Record number relations: To relate two work areas based on
        matching record numbers, use RECNO() for the SET RELATION TO
        expression and make sure the child work area has no active indexes.

 Examples

     .  This example relates three work areas in a multiple parent-
        child configuration with Customer related to both Invoices and Zip:

        USE Invoices INDEX Invoices NEW
        USE Zip INDEX Zipcode NEW
        USE Customer NEW
        SET RELATION TO CustNum INTO Invoices, Zipcode INTO Zip
        LIST Customer, Zip->City, Invoices->Number, ;
                 Invoices->Amount

     .  Sometime later, you can add a new child relation using the
        ADDITIVE clause, like this:

        USE BackOrder INDEX BackOrder NEW
        SELECT Customer

        SET RELATION TO CustNum INTO BackOrder ADDITIVE

 Files   Library is CLIPPER.LIB.

See Also: DBRELATION() DBRSELECT() FOUND() RECNO() SET INDEX



C5 Commands

 ?|??            Display one or more values to the console
 @...BOX         Draw a box on the screen
 @...CLEAR       Clear a rectangular region of the screen
 @...GET         Create a new Get object and display it
 @...PROMPT      Paint a menu item and define a message
 @...SAY         Display data at a specified screen or printer row and column
 @...TO          Draw a single- or double-line box
 ACCEPT*         Place keyboard input into a memory variable
 APPEND BLANK    Add a new record to the current database file
 APPEND FROM     Import records from a database (.dbf) file or ASCII text file
 AVERAGE         Average numeric expressions in the current work area
 CALL*           Execute a C or Assembler procedure
 CANCEL*         Terminate program processing
 CLEAR ALL*      Close files and release public and private variables
 CLEAR GETS      Release Get objects from the current GetList array
 CLEAR MEMORY    Release all public and private variables
 CLEAR SCREEN    Clear the screen and return the cursor home
 CLEAR TYPEAHEAD Empty the keyboard buffer
 CLOSE           Close a specific set of files
 COMMIT          Perform a solid-disk write for all active work areas
 CONTINUE        Resume a pending LOCATE
 COPY FILE       Copy a file to a new file or to a device
 COPY STRUCTURE  Copy the current .dbf structure to a new database (.dbf) file
 COPY STRU EXTE  Copy field definitions to a .dbf file
 COPY TO         Export records to a database (.dbf) file or ASCII text file
 COUNT           Tally records to a variable
 CREATE          Create an empty structure extended (.dbf) file
 CREATE FROM     Create a new .dbf file from a structure extended file
 DELETE          Mark records for deletion
 DELETE FILE     Remove a file from disk
 DELETE TAG      Delete a tag
 DIR*            Display a listing of files from a specified path
 DISPLAY         Display records to the console
 EJECT           Advance the printhead to top of form
 ERASE           Remove a file from disk
 FIND*           Search an index for a specified key value
 GO              Move the pointer to the specified identity
 INDEX           Create an index file
 INPUT*          Enter the result of an expression into a variable
 JOIN            Create a new database file by merging from two work areas
 KEYBOARD        Stuff a string into the keyboard buffer
 LABEL FORM      Display labels to the console
 LIST            List records to the console
 LOCATE          Search sequentially for a record matching a condition
 MENU TO         Execute a lightbar menu for defined PROMPTs
 NOTE*           Place a single-line comment in a program file
 PACK            Remove deleted records from a database file
 QUIT            Terminate program processing
 READ            Activate full-screen editing mode using Get objects
 RECALL          Restore records marked for deletion
 REINDEX         Rebuild open indexes in the current work area
 RELEASE         Delete public and private memory variables
 RENAME          Change the name of a file
 REPLACE         Assign new values to field variables
 REPORT FORM     Display a report to the console
 RESTORE         Retrieve memory variables from a memory (.mem) file
 RESTORE SCREEN* Display a saved screen
 RUN             Execute a DOS command or program
 SAVE            Save variables to a memory (.mem) file
 SAVE SCREEN*    Save the current screen to a buffer or variable
 SEEK            Search an order for a specified key value
 SELECT          Change the current work area
 SET ALTERNATE   Echo console output to a text file
 SET BELL        Toggle sounding of the bell during full-screen operations
 SET CENTURY     Modify the date format to include or omit century digits
 SET COLOR*      Define screen colors
 SET CONFIRM     Toggle required exit key to terminate GETs
 SET CONSOLE     Toggle console display to the screen
 SET CURSOR      Toggle the screen cursor on or off
 SET DATE        Set the date format for input and display
 SET DECIMALS    Set the number of decimal places to be displayed
 SET DEFAULT     Set the CA-Clipper default drive and directory
 SET DELETED     Toggle filtering of deleted records
 SET DELIMITERS  Toggle or define GET delimiters
 SET DESCENDING  Change the descending flag of the controlling order
 SET DEVICE      Direct @...SAYs to the screen or printer
 SET EPOCH       Control the interpretation of dates with no century digits
 SET ESCAPE      Toggle Esc as a READ exit key
 SET EXACT*      Toggle exact matches for character strings
 SET EXCLUSIVE*  Establish shared or exclusive USE of database files
 SET FILTER      Hide records not meeting a condition
 SET FIXED       Toggle fixing of the number of decimal digits displayed
 SET FORMAT*     Activate a format when READ is executed
 SET FUNCTION    Assign a character string to a function key
 SET INDEX       Open one or more order bags in the current work area
 SET INTENSITY   Toggle enhanced display of GETs and PROMPTs
 SET KEY         Assign a procedure invocation to a key
 SET MARGIN      Set the page offset for all printed output
 SET MEMOBLOCK   Change the block size for memo files
 SET MESSAGE     Set the @...PROMPT message line row
 SET OPTIMIZE    Change the setting that optimizes using open orders
 SET ORDER       Select the controlling order
 SET PATH        Specify the CA-Clipper search path for opening files
 SET PRINTER     Toggle echo of output to printer or set the print destination
 SET PROCEDURE*  Compile procedures and functions into the current object file
 SET RELATION    Relate two work areas by a key value or record number
 SET SCOPE       Change the boundaries for scoping keys in controlling order
 SET SCOPEBOTTOM Change bottom boundary for scoping keys in controlling order
 SET SCOPETOP    Change top boundary for scoping keys in controlling order
 SET SCOREBOARD  Toggle the message display from READ or MEMOEDIT()
 SET SOFTSEEK    Toggle relative seeking
 SET TYPEAHEAD   Set the size of the keyboard buffer
 SET UNIQUE*     Toggle inclusion of non-unique keys into an index
 SET WRAP*       Toggle wrapping of the highlight in menus
 SKIP            Move the record pointer to a new position
 SORT            Copy to a database (.dbf) file in sorted order
 STORE*          Assign a value to one or more variables
 SUM             Sum numeric expressions and assign results to variables
 TEXT*           Display a literal block of text
 TOTAL           Summarize records by key value to a database (.dbf) file
 TYPE            Display the contents of a text file
 UNLOCK          Release file/record locks set by the current user
 UPDATE          Update current database file from another database file
 USE             Open an existing database (.dbf) and its associated files
 WAIT*           Suspend program processing until a key is pressed
 ZAP             Remove all records from the current database file

 

Strong Relation

Build strong relationships

Basics of building databases, indexs and relations.