Kbase P19421: How to pass a literal string using argument reference
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  15/10/2008 |
|
Status: Verified
GOAL:
How to pass a literal string using argument reference?
FIX:
The following sample code demonstrates the usage of argument reference to compile a dynamic query. Note that four sets of double quotes are required to get the literal value "bbb" passed through to the target procedure. Since the argument values aren't known until the RUN statement executes, the deployment site must have a PROGRESS license which will allow compilation of a-query.p. The minimum license requirement depends on the desired functionality of the query procedure.
In the example below, a Query/Runtime license would be sufficient.
/* main.p */
DEFINE VARIABLE MyTable AS CHARACTER NO-UNDO.
DEFINE VARIABLE MyAccess AS CHARACTER NO-UNDO.
DEFINE VARIABLE MyAction AS CHARACTER NO-UNDO.
DEFINE VARIABLE MyWhere AS CHARACTER NO-UNDO.
DEFINE VARIABLE a AS CHARACTER NO-UNDO INITIAL 'name'.
DEFINE VARIABLE b AS CHARACTER NO-UNDO INITIAL '>'.
DEFINE VARIABLE c AS CHARACTER NO-UNDO INITIAL 'bbb'.
ASSIGN MyTable = 'customer'
MyAccess = 'NO-LOCK'
MyWhere = a + b + """" + c + """"
MyAction = 'DISPLAY'.
RUN a-query.p MyTable MyWhere MyAccess MyAction.
/* a-query.p */
FOR EACH {1} WHERE {2} {3}:
{4} {1}.
END.