Was this helpful?
tabledata Statement--Traverse Columns
This statement traverses the columns in a table field.
Syntax
tabledata
begin
    program code;
end
Description
The tabledata statement works in conjunction with the formdata statement to create a loop through all the columns in the current table field, executing the same section of code for each column. You must embed this statement inside a formdata statement.
The statement's begin/end block contains the code that are executed for each column in the table field. The inquire_frs statement is often part of this code, so that the program can make inquiries about each column in the table field. This is particularly useful if the program does not know which form is in use until run time. The template for this usage is:
formdata formname
begin
    ...
tabledata
    begin
            inquire_frs on current column;
            program code;
    end
    ...
end
The full range of inquire_frs column variants, as well as all other embedded SQL and host language statements, can appear in the tabledata loop. (See the inquire_frs statement description for a complete list of its possibilities.) The tabledata loop simply starts the first pass on the first column in the current table field and sequences along to the next column with each additional pass through the loop.
You can use the endloop statement to break out of the loop when necessary. See the endloop Statement--Terminate a Loop for its syntax and usage.
Example--tabledata statement:
Loop through a form, printing out all field and column names.
exec frs formdata :formname;
 exec frs begin;
    exec frs inquire_frs field '' 
        (:fldname = name, :istable = table);
    if (istable = 1) then
        print fldname,' is a table field';
        print '---------------';
        exec frs tabledata;
        exec frs begin;
            exec frs inquire_frs column '' ''
                (:colname = name);
            print colname, ' is a column';
        exec frs end;
        print '---------------';
    else
        print fldname, ' is a regular field';
    end if;
exec frs end;
Last modified date: 08/14/2024