At run-time the parameter is replaced by the results of the method.
Class Parameters
[PRO] A class parameter allows an operation to call off to a specified Java method.
Syntax
??>
A class parameter is in the following format:
??>FULL_CLASS_NAME|METHOD_NAME|METHOD_PARAM1|METHOD_PARAM2 …
So a class parameter which calls the method util.Census.getPopulation(String city, String state) might look like this:
??>util.Census|getPopulation|Boston|Massachusetts
Whitespace characters cannot be included in a parameter unless the parameter’s value is enclosed in double quotes:
??>util.Census|getPopulation|Boston|Massachusetts|”United States”
If a parameter’s value should include an actual double quote then it needs to be escaped with the backslash character:
??util.MyClass|myMethod|”This is a double quote: \””|”This is a dollar sign: $”|
Usage
When a class parameter appears in the code of an SQLOperation, it is replaced with its value before it is sent to the database.
So if an operation’s SQL was:
SELECT * FROM SCHEM.CITIES WHERE CITY_POP > ??>util.Census|getPopulation|Boston|Massachusetts
Then the SQL which would actually be sent to the database would be:
SELECT * FROM SCHEM. CITIES WHERE CITY_POP > 645000
Class parameters are never displayed as prompts to the user.
Class parameters can also be used in the operation instructions. Placing the text:
Population of Boston, MA is ??>util.Census|getPopulation|Boston|Massachusetts
...in the operation instructions would result in the instructions reading:
Population of Boston, MA is 645000
Running Operations from Class Parameters
WOW has a built in class named RunOp for running SQL queries from class parameters.
This allows you to run one operation and place its results into the SQL of another operation.
RunOp/getValue
The getValue method of RunOp will run an operation and return a single value. For example, if this was the SQL of operation 110:
SELECT CITY_POP FROM SCHEM.CITYDATA WHERE CITY_NAME = ‘Boston’ AND CITY_STATE = ‘MA’
...then in a different operation you could use this SQL to select names of cities with a greater population than Boston:
SELECT CITY_NAME FROM SCHEM.CITYDATA WHERE CITY_POP > ??>RunOp|getValue|110
In this example, both operations queried the same table, however they could be querying two different tables on two completely different databases.
RunOp|getValue will always give the value from the first column of the first record in the results.
RunOp/getSQLValue
RunOp|getSQLValue works in much the same way as RunOp|getValue, however
the value it returns will be formatted for inclusion in SQL. For example character
values returned by getSQLValue will be wrapped in single quotes; characters
values returned by RunOp|getValue will not be wrapped in quotes.
RunOp/buildInClause
RunOp|buildInClause can be used to build a SQL IN clause based on the results of an operation.
The syntax for RunOp|buildInClause is as follows:
??>RunOp|buildInClause|<Operation ID>|<Prefix>
Consider the Account table:
Operation #220 has SQL which selects the IDs of accounts which are overdue:
SELECT ID FROM SCHEM.ACCOUNTS WHERE OVERDUE = ‘Y’
A different operation could use the results of operation #220 to calculate the total balance on all accounts that are overdue:
SELECT SUM(BALANCE) FROM SCHEM.ACCOUNTS WHERE ??>RunOp|buildInClause|220|”ID IN”
That will result in the following SQL being sent to the DB:
SELECT SUM(BALANCE) FROM SCHEM.ACCOUNTS WHERE ID IN (1, 4, 5)
RunOp|buildInClause takes an optional third parameter, which is the SQL to generate when there are no values returned by the executed operation.
For example:
SELECT SUM(BALANCE) FROM SCHEM.ACCOUNTS WHERE ??>RunOp|buildInClause|220|”ID IN”|”1 = 2”
If the above SQL is run, and operation 220 does not return any results, then the SQL sent to the database would be:
SELECT SUM(BALANCE) FROM SCHEM.ACCOUNTS WHERE 1 = 2
Run an operation and include the whole HTML generation:
??>RunOp|getOperation|2246
This will execute WOW Operation with ID = 2246 and generate and return the operations HTML.
NOTE: This feature should only be used in limited READ ONLY scenarios.
TAGS: Run an operation and generate HTML, include operation HTML