Xbasic

RECORD_UPDATE Function

Syntax

Result_Flag as L = record_update(C tablename ,C filter ,C data [,N style ])

Arguments

tablenameCharacter

The name of a table

filterCharacter

A filter expression that evaluates to a logical value and selects a record from the table.

dataCharacter

A CR-LF delimited list of the field values to write into the selected record. The data can be presented in two different formats as defined by the Style argument.

styleNumeric

Default = 1. An optional style selector. See explanation below for more information.

Returns

Result_FlagLogical

.T. = the record was modified. .F. = the record was not modified.

Description

Updates a record in a table. Data is CRLF delimited list. Style 1 - data is fieldname=fieldvalue pairs, Style 2 data is just fieldvalues in same order as fieldnames

Discussion

RECORD_UPDATE() modifies a record in table Table_Name. The record is selected using Record_Filter and updated with the field values specified by Data_List.Note : If more than one record matches the filter, the function only modifies the first record found in record number order.

Example 

The following example changes the values of the firstname and lastname fields in the first record of the salespeople table.

dim str as C
str = <<%dat%
firstname = george
lastname = white
%dat%
? record_update("salespeople", ".t.", str) = .T.

Setting the Style 

The Style selector defines the format of the data. There are two options available:

  • Style = 1 

    The default style used, data is listed using a CR-LF delimited list of <field_name> = <value> pairs. For example:

    Fieldname1 = Value1
    Fieldname2 = Value2
    FieldnameN = ValueN
  • If data must be included for auto-increment fields, you must use Style 1. You can specify the auto-increment field with a blank value as follows:

    Fieldname1 =
  • Style = 2 

    Data only includes the values. For example:

    Value1
    Value2
    ValueN

See Also