Consultor Eletrônico



Kbase P35814: How to retrieve database connection parameters from within 4GL
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   12/11/2009
Status: Verified

GOAL:

How to retrieve database connection parameters from within 4GL

GOAL:

How to access the parameters for a connected database

FACT(s) (Environment):

All Supported Operating Systems
Progress 9.x
OpenEdge 10.x

FIX:

Using 4GL, it is possible to retrieve the database connection parameters of any connected database.
To do so, parse the results of the DBPARAM function; this function returns a comma-separated list of all parameters passed when the database was connected (either during session startup, or after a CONNECT statement).

For example, the following procedure will retrieve the service name (-S parameter) for a database with the logical name "sports":

DEFINE VARIABLE cParams AS CHARACTER NO-UNDO CASE-SENSITIVE.
DEFINE VARIABLE cParameter AS CHARACTER NO-UNDO CASE-SENSITIVE INITIAL "-S".
/* because parameters are case-sensitive */

DEFINE VARIABLE cParamValue AS CHARACTER NO-UNDO.
DEFINE VARIABLE iCount AS INTEGER NO-UNDO.

cParams = DBPARAM("sports").

DO iCount = 1 TO NUM-ENTRIES(cParams):
cParamValue = ENTRY(iCount,cParams).
IF cParamValue BEGINS cParameter THEN DO:
/* strip off parameter, leaving only the value */
cParamValue = LEFT-TRIM(SUBSTRING(cParamValue,LENGTH(cParameter) + 1)).
LEAVE.
END.
cParamValue = "".
END.

MESSAGE cParamValue.