Consultor Eletrônico



Kbase P109700: 4GL: Why does the ADD-FIELDS-FROM( ) method not generate error with invalid table name parameters?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/7/2005
Status: Unverified

GOAL:

4GL: Why does the ADD-FIELDS-FROM( ) method not generate error with invalid table name parameters?

FIX:

The ADD-FIELDS-FROM( ) method copies the field definitions from the specified source table. It returns TRUE if the copying is successful and returns FALSE otherwise. Passing an invalid table name to this method does not generate an error because the method executes successfully by returning the logical FALSE indicating the failure of the field copying operation. It is the value returned by this method that developers should check to know whether the actual copying of the fields was successful or not.
To illustrate consider the following two code snippets:
A. Connect to the sports2000 database and run the following 4GL code:
DEFINE VARIABLE pcTable AS CHARACTER NO-UNDO.
DEFINE VARIABLE hTempTable AS HANDLE NO-UNDO.
DEFINE VARIABLE lResult AS LOGICAL NO-UNDO.
pcTable = "Customer".
CREATE TEMP-TABLE hTempTable.
lResult = hTempTable:ADD-FIELDS-FROM(pcTable) NO-ERROR.
MESSAGE
lResult
ERROR-STATUS:ERROR
VIEW-AS ALERT-BOX INFO BUTTONS OK.
In the above sample:
The variable lResult evaluates to TRUE because there is a table named "Customer".
The expression ERROR-STATUS:ERROR evaluates to FALSE because the explicit assignment statement and the ADD-FIELDS-FROM( ) method executed successfully without error.

B. Connect to the sports2000 database and run the following code snippet:
DEFINE VARIABLE pcTable AS CHARACTER NO-UNDO.
DEFINE VARIABLE hTempTable AS HANDLE NO-UNDO.
pcTable = "NonExistingTableName".
CREATE TEMP-TABLE hTempTable.
lResult = hTempTable:ADD-FIELDS-FROM(pcTable) NO-ERROR.
MESSAGE
hTempTable:ADD-FIELDS-FROM(pcTable)
ERROR-STATUS:ERROR
VIEW-AS ALERT-BOX INFO BUTTONS OK.
In the above sample:
The expression "hTempTable:ADD-FIELDS-FROM(pcTable)" evaluates to FALSE because there is no table named "NonExistingTableName".
The expression ERROR-STATUS:ERROR evaluates to FALSE because the ADD-FIELDS-FROM( ) method executed again successfully without error.