Salesforce

How to retrieve the Database Schema (fields and indexes of a table)

« Go Back

Information

 
TitleHow to retrieve the Database Schema (fields and indexes of a table)
URL NameP2622
Article Number000148622
EnvironmentProduct: OpenEdge
Version: All supported versions
OS: All supported platforms
Question/Problem Description
How to get the field and index-field information of a table?
How to use metaschema tables to list a table's field and index information
Example ABL code to retrieve the Database Schema (fields and indexes of a table)
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
The following code can be customised to requirement. This code example provides the fields and indexes of a given table in the Database Schema.
 
DEFINE VARIABLE vIdxflags    AS CHARACTER          NO-UNDO.

REPEAT WITH SIDE-LABELS ATTR:

    PROMPT-FOR _file._file-name.
    FIND _file USING _file-name NO-LOCK.

DISPLAY _file-name.

FOR EACH _field OF _file NO-LOCK:
    DISPLAY 
        _field._field-name FORMAT "x(25)"
        _field._data-type FORMAT "x(10)"
        _field._initial LABEL "INIT" FORMAT "x(4)"
        _field._format FORMAT "x(30)"
        _field._label FORMAT "x(30)" 
    WITH NO-BOX WIDTH 150.
END.

FOR EACH _index OF _file,
    EACH _index-field OF _index NO-LOCK:
    FIND _field OF _index-field NO-ERROR.
    IF AVAILABLE (_field) THEN
    
    ASSIGN vIdxflags = (IF RECID(_Index) EQ _File._Prime-Index THEN "p" ELSE "")
                    + (IF _Index._Unique       THEN "u" ELSE "")
                    + (IF _Index._Wordidx EQ 1 THEN "w" ELSE "").
    
    DISPLAY 
    _index-Name FORMAT "X(15)"  
    _index-seq
    vIdxflags
    _field-name FORMAT "X(30)"
        WITH NO-BOX WIDTH 150.
END.
RELEASE _file.
END.
Workaround
Notes
Keyword Phrase
Last Modified Date10/22/2021 1:56 PM

Powered by