Progress
Results Administration
and Development Guide


Generating New Queries

You can generate new queries programmatically in Results from a feature or integration procedure. Query generation from a feature or integration procedure uses the vstbll.p API procedure and some special Results features.

The vstbll.p API procedure allows you to set the table list for a new query in Results. You cannot run the vstbll.p API procedure when there is a current query in Results. If there is an active query in Results, you must execute the AdminProgInitialize feature to clear the query prior to running the vstbll.p API procedure. Use the following syntax to call the vstbll.p API procedure from a feature procedure or integration procedure:

RUN aderes/vstbll.p (INPUT tableList, OUTPUT result). 

The following list describes the parameters associated with the vstbll.p API procedure:

INPUT tableList

A string value containing a comma-separated list of table or alias names to establish the currently active query in Results. The tables specified must be available in the currently attached databases. If you intend to join a table to another table, you must specify both tables in the list in the order specified in the join. For example, the join Customer OF Order requires that the Customer table must be listed before the Order table in the table list.

OUTPUT result

A logical value that indicates whether the API procedure executed successfully.

To generate queries from a feature or integration procedure, follow these general steps:

  1. Execute the AdminProgInitialize feature using the sffire.p API procedure to clear the current query from Results.
  2. Run the vstbll.p API procedure to set the table list for the new query.
  3. Define fields and format information for the new query using the API shared variables and procedures. At a minimum, set the qbf–module and qbf–name variables and define a field for the query.
  4. Execute the AdminProgInstantiate feature using the sffire.p API procedure to initialize any unset API shared variables with valid default values. You must execute this feature before you attempt to display or run the new query.
  5. Save the new query, generate 4GL code for the query, then print it or display it in Results.

The following feature procedure generates a new query, then displays it in Results:

tstFeat.p
/* 1 */ 
{ aderes/u-pvars.i } 
/* 2 */ 
DEFINE INPUT  PARjAMETER args AS CHARACTER NO-UNDO. 
DEFINE OUTPUT PARAMETER winState AS LOGICAL NO-UNDO. 
/* 3 */ 
DEFINE VARIABLE result AS LOGICAL NO-UNDO. 
/* 4 */ 
RUN aderes/sffire.p("AdminProgInitialize", ?, OUTPUT result). 
/* 5 */ 
RUN aderes/vstbll.p("sports.Customer,sports.Order", OUTPUT result). 
    IF result = TRUE THEN DO:     
/* 6 */
   RUN aderes/vstbli.p(INPUT "sports.Customer", INPUT ?, INPUT ?, 
    INPUT "Customer.State = ""MA""", INPUT ?, INPUT ?, OUTPUT result). 
   RUN aderes/vstbli.p(INPUT "sports.Order", INPUT "sports.Customer",  
    INPUT "OF sports.Customer", INPUT ?, INPUT ?, INPUT ?, 
    OUTPUT result). 
/* 7 */ 
    ASSIGN
    qbf-module = "r" 
    qbf-name = "newque" 
    qbf-rc# = 2 
    qbf-rcn[1] = "sports.Customer.Name" 
    qbf-rcl[1] = "Cust Name" 
    qbf-rcf[1] = "X(25)" 
    qbf-rct[1] = 1 
    qbf-rcp[1] = ",,,,,,," 
    qbf-rcn[2] = "sports.Order.Order-num" 
    qbf-rcl[2] = "Ord Num" 
    qbf-rcf[2] = ">>>>9" 
    qbf-rct[2] = 4
    qbf-rcp[2] = ",,,,,,,". 
END. /* DO */ 
/* 8 */ 
RUN aderes/sffire.p(INPUT "AdminProgInstantiate", INPUT? ,  
    OUTPUT result). 
/* 9 */ 
    winState = TRUE. 

The commented numbers in the code refer to these notes:

  1. Includes the u-pvars.i file to define the API shared variables for access in the procedure.
  2. Defines the input and output parameters required by a feature procedure.
  3. Defines a variable to capture the output values of the different API procedures used in this feature procedure.
  4. Executes the AdminProgInitialize feature using the sffire.p API procedure to clear the current query from Results.
  5. Sets the table list for the new query. The example feature procedure uses tables from the sports database.
  6. Defines the join and selection criteria for the tables specified for the new query.
  7. Defines two fields for the new query.
  8. Instantiates the rest of the data structures of the new query in preparation for use in Results.
  9. Sets the output parameter of the feature procedure to TRUE, which tells Results to redraw the window and display the new query defined in the feature procedure.

For more information about the language elements used in the this example procedure, see the Progress Language Reference.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095