dbUseArea()

DBUSEAREA()

Opens a work area and uses a database file.

Syntax

      DBUSEAREA( [<lNewArea>], [<cDriver>], <cName>, [<xcAlias>],
      [<lShared>], [<lReadonly>])

Arguments

<lNewArea> A optional logical expression for the new work area

<cDriver> Database driver name

<cName> File Name

<xcAlias> Alias name

<lShared> Shared/exclusive status flag

<lReadonly> Read-write status flag.

Description

This function opens an existing database named <cName> in the current work area. If <lNewArea> is set to a logical true (.T.) value, then the database <cName> will be opened in the next available and unused work area. The default value of <lNewArea> is a logical false (.F.). If used, <cDriver> is the name of the database driver associated with the file <cName> that is opened. The default for this will be the value of DBSETDRlVER().

IF used, <xcAlias> contains the alias name for that work area, If not specified, the root name of the database specified in <cName> will be used.

If <lShared> is set to a logical true (.T.) value, the database that is specified in <cName> will be opened by the user EXCLUSIVELY. Thus locking it from all other nodes or users on the network. If <lShared> is set to a logical false (.F.) value, then the database will be in SHARED mode. If <lShared> is not passed, then the function will turn to the internal setting of SET EXCLUSIVE to determine a setting.

If <lReadOnly> is specified, the file will be set to READ ONLY mode. If it is not specified, the file will he opened in normal read-write mode.

Examples

      DBUSEAREA( .T.,, "tests" )

Compliance

Clipper

Files

Library is rdd

Seealso

DBCLOSEAREA(), DBSETDRIVER(), SELECT(), SET()

dbUnlockAll()

DBUNLOCKALL()

Unlocks all records and releases all file locks in all work areas.

Syntax

      DBUNLOCKALL()

Description

This function will remove all file and record locks in all work area.

Examples

      nId := 10
      USE tests INDEX testid NEW
      USE tests1 INDEX tests NEW
      IF testid->( DBSEEK( nId ) )
         IF testid->( RLOCK() )
            DBDELETE()
         ELSE
            DBUNLOCK()
         ENDIF
      ELSE
         DBUNLOCKALL()
      ENDIF
      USE

Compliance

Clipper

Files

Library is rdd

Seealso

DBUNLOCK(), FLOCK(), RLOCK()

dbUnlock()

DBUNLOCK()

Unlock a record or release a file lock

Syntax

      DBUNLOCK()

Description

This function releases the file or record lock in the currently selected or aliased work area. It will not unlock an associated lock in a related databases.

Examples

      nId := 10
      USE testid INDEX testid NEW
      IF testid->( DBSEEK( nId ) )
         IF testid->( RLOCK() )
            DBDELETE()
         ELSE
            DBUNLOCK()
         ENDIF
      ENDIF
      USE

Compliance

Clipper

Files

Library is rdd

Seealso

DBUNLOCKALL(), FLOCK(), RLOCK()

dbStruct()

DBSTRUCT()

Creates a multidimensional array of a database structure.

Syntax

      DBSTRUCT() --> aStruct

Returns

DBSTRUCT() returns an array pointer to database structure

Description

This function returns a multidimensional array. This array has array pointers to other arrays, each of which contains the characteristic of a field in the active work area. The lenght of this array is based in the number of fields in that particular work area. In other words, LEN(DBSTRUCT()) is equal to the value obtained from FCOUNT(). Each subscript position

Examples

      #include "dbstruct.ch"
      PROCEDURE Main()
         LOCAL aStru, x
         USE tests NEW
         aStru := dbStruct()
         FOR x := 1 TO LEN( aStru )
            ? aStru[ x ][ DBS_NAME ]
         NEXT
         USE
         RETURN

Compliance

Clipper

Files

Library is rdd Header is dbstruct.ch

Seealso

AFIELDS()*

dbSkip()

DBSKIP()

Moves the record pointer in the selected work area.

Syntax

      DBSKIP([<nRecords>])

Arguments

<nRecords> Numbers of records to move record pointer.

Description

This function moves the record pointer <nRecords> in the selected or aliased work area. The default value for <nRecords> will be 1. A DBSKIP(0) will flush and refresh the internal database bufer and make any changes made to the record visible without moving the record pointer in either direction.

Examples

      PROCEDURE Main()
         USE tests NEW
         DBGOTOP()
         DO WHILE ! EOF()
            ? tests->Id, tests->Name
            DBSKIP()
         ENDDO
         USE
         RETURN

Compliance

Clipper

Files

Library is rdd

Seealso

BOF(), DBGOBOTTOM(), DBGOTOP(), DBSEEK(), EOF()

dbSetFilter()

DBSETFILTER()

Establishes a filter condition for a work area.

Syntax

      DBSETFILTER(<bCondition>, [<cCondition>])

Arguments

<bCondition> Code block expression for filtered evaluation.

<cCondition> Optional character expression of code block.

Description

This function masks a database so that only those records that meet the condition prescribed by the expression in the code block <bCondition> and literally expressed as <cCondition> are visible. If <cCondition> is not passed to this function, then the DBFILTER() function will return an empty string showing no filter in that work area which in fact, would be not correct.

Examples

      PROCEDURE Main()
         USE tests NEW
         DBSETFILTER( {|| tests->Id <100 }, "tests->Id <100" )
         DBGOTOP()

Compliance

Clipper

Files

Library is rdd

Seealso

DBFILTER(), DBCLEARFILTER()

dbSetDriver()

DBSETDRIVER()

Establishes the RDD name for the selected work area

Syntax

      DBSETDRIVER( [<cDriver>] ) --> cCurrentDriver

Arguments

<cDriver> Optional database driver name

Returns

DBSETDRIVER() returns the name of active driver

Description

This function returns the name of the current database driver for the selected work area. The default will be “DBFNTX”. If specified, <cDriver> contains the name of the database driver that should be used to activate and manage the work area. If the specified driver is not avaliable, this function will have no effect.

Examples

      DBSETDRIVER("ADS")

Compliance

Clipper

Files

Library is rdd

Seealso

DBUSEAREA()