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()

dbSelectArea()

DBSELECTAREA()

Change to another work area

Syntax

      DBSELECTAREA(<xArea>) -

Arguments

<xArea> Alias or work area

Description

This function moves the Harbour internal primary focus to the work area designated by <xArea>. If <xArea> is numeric, then it will select the numeric work area; if <xArea> is character, then it will select the work area with the alias name.

DBSELECTAREA(0) will select the next avaliable and unused work area. Up to 255 work areas are supported. Each work area has its own alias and record pointer, as well as its own FOUND(), DBFILTER(), DBRSELECT() and DBRELATION() function values.

Examples

      PROCEDURE Main()
         LOCAL nId
         USE tests NEW INDEX tests
         USE tests1 NEW INDEX tests1
         DBSELECTAREA( 1 )
         nId := tests->Id
         DBSELECTAREA( 2 )
         IF DBSEEK( nId )
            ? tests1->cName
         ENDIF
         DBCLOSEALL()
         RETURN

Compliance

Clipper

Files

Library is rdd

Seealso

DBUSEAREA(), SELECT()

dbSeek()

DBSEEK()

Searches for a value based on an active index.

Syntax

      DBSEEK(<expKey>, [<lSoftSeek>],[<lFindLast>]) --> lFound

Arguments

<expKey> Any expression

<lSoftSeek> Toggle SOFTSEEK condition

<lFindLast> is an optional logical value that set the current record position to the last record if successful

Returns

DBSEEK() returns logical true (.T.) if found, otherwise false

Description

This function searches for the first record in a database file whose index key matches <expKey>. If the item is found, the function will return a logical true (.T.), the value of FOUND() wilI be a logical true (.T.), and the value of EOF() wilI be a logical false (.F.). If no item is found. then the function will return a logical false, the value of FOUND( ) will be a logical false (.F.), and the value of EOF( ) will be a logical true (.T.).

This function always “rewinds” the database pointer and starts the search from the top of the file.

If the SOFTSEEK flag is on or if <lSoftSeek> is set to a logical true (.T.) the value of FOUND() will be a logical false and EOF() will be false if there is an item in the index key with a greater value than the key expression <expKey>; at this point the record pointer will position itself on that record. However, if there is no greater key in the index, EOF() will return a logical true (.T.) value. If <lSoftSeek> is not passed, the function will look to the internal status of SOFTSEEK before performing the operation. The default of <lSoftSeek> is a logical false (.F.)

Examples

      PROCEDURE Main()
         USE tests NEW INDEX tests
         DBGOTO( 10 )
         nId := tests->nId
         IF tests->( DBSEEK( nId ) )
            IF RLOCK()
               ? tests->Name
               DBRUNLOCK()
            ENDIF
         ENDIF
         USE
         RETURN

      ACCEPT "Employee name: " TO cName
      IF Employee->( DBSEEK( cName ) )
         Employee->( ViewRecord() )
      ELSE
         ? "Not found"
      ENDIF

Compliance

DBSEEK() is Compatible with CA-Cl*pper 5.3

Files

Library is rdd

Seealso

DBGOBOTTOM(), DBGOTOP(), DBSKIP(), EOF(), BOF(), FOUND()

dbRUnlock()

DBRUNLOCK()

Unlocks a record based on its identifier

Syntax

      DBRUNLOCK([<xIdentity>])

Arguments

<xIdentity> Record identifier, typically a record number

Description

This function will attempt to unlock the record specified as <xIdentity>, which in a .dbf format is the record number. If not specified, them the current active record/data item will be unlocked

Examples

      PROCEDURE Main()
         USE tests NEW
         DBGOTO( 10 )
         IF RLOCK()
            ? tests->ID
            DBRUNLOCK()
         ENDIF
         USE
         RETURN

Compliance

Clipper

Files

Library is rdd

Seealso

RLOCK(), DBRLOCK(), DBRLOCKLIST()