Develop > Programming > System Language reference > List: rtecalls > rtecall("scantable") function

rtecall("scantable") function

A RAD function that scans the specified table for certain types of invalid records and fixes the records.

Function

rtecall("scantable")

Format

$L.success.flg=rtecall($L.fnc.name, $return.code, $scantype, $tablename, $bfix, $columns)

$L.success.flg=rtecall($L.fnc.name, $return.code, $scantype, $tablename, $bfix, $totalnum, $fixed, $deleted)

Parameters

The following parameters are valid for the rtecall("scantable") function:

Parameter Data type Description
$L.success.flg Logical Indicates if the function was successful.
$L.fnc.name String Name of the sub-function to call, in this case "scantable".
$L.return.code Number Provides a more detailed return code.
$scantype Number

Specifies the type of scan the function will perform, which can be one of the following:

  • 1–to scan for duplicate records on specified columns
  • 2–to scan for null values on non-nullable fields, such as fields with a "Unique" or "No Nulls" key applied
  • 3–to scan for values whose data types do not match the data type defined on the field
$L.tablename String The name of the table to be scanned.
$bfix Bool Specifies whether to automatically fix the invalid data.
$columns String array Only available when $scantype is 1, specifies the columns on which the function will scan for duplicate records.
$totalnum Number Indicates the number of the invalid records that were found.
$fixed Number Indicates the number of the invalid records that were fixed.
$deleted Number Indicates the number of the records that were removed.

Factors

If the $L.success.flg is false, the function failed. If it is true, the function succeeded.

$totalnum, $fixed, and $deleted are available when $scantype is 2 or 3. This total number should include $fixed, $deleted, and the number of invalid records that failed to be fixed.

Examples

The following function call scans the ioaction table for duplicate records on the field1 and field2 fields and fixes the duplicate records.

$L.flg=rtecall("scantable", $L.return.code, 1, "ioaction", true, {"field1","field2"})

The following function call scans the ioaction table for null values that are disallowed by keys.

$L.flg=rtecall("scantable", $L.return.code, 2, "ioaction", true, $all, $fixed, $deleted)

Additional information

If you choose to fix invalid data by setting $bfix to 1:

  • In a "type-1" scan, the function differentiates duplicate items by appending suffixes such as -dup1, -dup2...-dupx.
  • In a "type-2" scan, the following behaviors occur:

    • The function removes the record if null values violate a "Unique" key.
    • Or the function replaces the first of the null values with a default value if null values violate a "No Nulls" key.
  • In a "type-3" scan, the following behaviors occur:

    • The function converts the value into the correct data type if the value data makes sense in the target data type.
    • The function replaces the value with a default value in the correct data type.