Consultor Eletrônico



Kbase P148263: 4GL/SQL: What are the OpenEdge SQL reserved words?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   18/06/2009
Status: Unverified

GOAL:

4GL/SQL: What are the OpenEdge SQL reserved words?

GOAL:

How to list all table and field names that are OpenEdge SQL reserved words?

GOAL:

4GL/ABL procedure to report all database user table and field names that are OpenEdge SQL reserved words.

FACT(s) (Environment):

All Supported Operating Systems
OpenEdge 10.2A

FIX:

The following 4GL procedure generates a report of all the database user table and field names that are OpenEdge 10.2A SQL reserved words.

The procedure reads the OpenEdge 10.2A SQL reserved words from the file OpenEdge102ASqlReservedWords.txt. This is a one line text file of the reserved words as a comma separated list which was built from the "OpenEdge SQL reserved words" table in the "OpenEdge Data Management: SQL Reference" manual.

The procedure generates the file myTableAndFieldNamesReport.txt, a report listing all the table and field names that are are OpenEdge SQL reserved words.

Both of the input OpenEdge102ASqlReservedWords.txt file and sample output myTableAndFieldNamesReport.txt are listed in the notes below:

/*** GenerateTableAndFieldNameSqlReservedWordsReport.p ***/
DEFINE VARIABLE cSqlWordListFileName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cTableAndFieldNamesReport AS CHARACTER NO-UNDO.
DEFINE VARIABLE cOpenEdge102AReservedWords AS CHARACTER NO-UNDO.
DEFINE VARIABLE cTableString AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFieldString AS CHARACTER NO-UNDO.
DEFINE TEMP-TABLE ttReport
FIELD cTableName AS CHARACTER
FIELD cFieldName AS CHARACTER
FIELD cKeyWord AS CHARACTER.
ASSIGN
cSqlWordListFileName = "OpenEdge102ASqlReservedWords.txt"
cTableAndFieldNamesReport = "myTableAndFieldNamesReport.txt".
/* Initialize SQL Keyword List */
INPUT FROM VALUE ( cSqlWordListFileName ).
IMPORT UNFORMATTED cOpenEdge102AReservedWords.
INPUT CLOSE.
/* Populate Report TEMP-TABLE */
FOR EACH _File NO-LOCK WHERE _Tbl-Type = "T",
EACH _field NO-LOCK OF _File:
IF LOOKUP ( _file-name, cOpenEdge102AReservedWords) > 0 OR LOOKUP ( _field-name, cOpenEdge102AReservedWords) > 0 THEN DO:
CREATE ttReport.
ASSIGN
cTableName = _file-name
cFieldName = _field-name
cKeyWord = IF LOOKUP ( _file-name, cOpenEdge102AReservedWords) > 0 THEN _file-name ELSE _field-name.
END.
END.
/* Send report to file */
OUTPUT TO VALUE ( cTableAndFieldNamesReport ).
/* Output header line */
PUT UNFORMATTED "Table Name" AT 1 "Field Name" AT 25 "SQL Keyword" AT 50 SKIP.
/* Output report details */
FOR EACH ttReport:
ASSIGN
cTableString = IF cTableName = cKeyWord THEN cTableName + "(Keyword)" ELSE cTableName
cFieldString = IF cFieldName = cKeyWord THEN cFieldName + "(Keyword)" ELSE cFieldName.
PUT UNFORMATTED cTableString AT 1 cFieldString AT 25 CAPS(cKeyWord) AT 50 SKIP.
END.
OUTPUT CLOSE.