2.2 Accessing a table
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • Managing external tables for SWI-Prolog
        • Managing external tables
          • Accessing a table
            • Finding record locations in a table
            • Reading records
              • read_table_record/4
              • read_table_fields/4
              • read_table_record_data/4
            • Searching the table
            • Miscellaneous

2.2.2 Reading records

There are two predicates for reading records. The read_table_record/4 reads an entire record, while read_table_fields/4 reads one or more fields from a record.

read_table_record(+Handle, +Start, -Next, -Record)
Read a record from the table. Handle is a handle as returned by new_table/4. Start is the location of a record. If Start does not point to the start of a record, this predicate searches backwards for the starting position. Record is unified with a term constructed from the functor associated with the table (default name record and arity the number of not-skipped columns), each of the arguments containing the converted data. An error is raised if the data could not be converted. Next is unified with the start position for the next record.
read_table_fields(+Handle, +Start, -Next, -Fields)
As read_table_record/4, but Fields is a list of terms +Name(-Value), and the Values will be unified with the values of the specified field.
read_table_record_data(+Handle, +Start, -Next, -Record)
Similar to read_table_record/4, but unifies record with a Prolog string containing the data of the record unparsed. The returned record does not contain the terminating record-separator.