Consultor Eletrônico



Kbase 16102: How to pass a literal string using argument reference
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
How to pass a literal string using argument reference

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 thru 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 */
DEF VAR mytable AS CHAR.
DEF VAR myaccess AS CHAR.
DEF VAR myaction AS CHAR.
DEF VAR a AS CHAR INIT "name".
DEF VAR b AS CHAR INIT ">".
DEF VAR c AS CHAR INIT "bbb".
DEF VAR mywhere AS CHAR.

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.

Note that argument values are substituted into the subprocedure
in the order in which they appear on the RUN statement. Given the
above main.p, the arguments in a-query.p will be substituted
and compiled as follows:

FOR EACH customer WHERE name > "bbb" NO-LOCK:
DISPLAY customer.
END.

Refer to Language Reference section entitled:
"{} Argument Reference"

Progress Software Technical Support Note # 16102