ResultSet Looping ResultSet Looping Example While Looping

2-8 Oracle Fusion Middleware Idoc Script Reference Guide ■ Boolean Operators can be used to combine conditional clauses. For example, you can use the and operator as follows: if UseBellevueLook and isTrueUseBellevueLook ■ If the condition expression is the name of a ResultSet available for inclusion in the HTML page, the conditional clause returns true if the ResultSet has at least one row. This ensures that a template page presents information for a ResultSet only if there are rows in the ResultSet. ■ A conditional clause that does not trigger special computation is evaluated using the XXXXXXXXXXXX_cannot_cross-reference to a marker on a para in a bable_XXXXXXXXXXXXXX prefix. The result is true if the value is not null and is either a nonempty string or a nonzero integer. For an example of conditional code, see Section 2.3.4.1, Conditional Example.

2.3.4.1 Conditional Example

In this example, a table cell td is defined depending on the value of the variable xDepartment: if xDepartment tdxDepartmenttd else tdDepartment is not defined.td endif xDepartment= ■ If the value of xDepartment is defined, then the table cell contains the value of xDepartment. ■ If the value of xDepartment is not defined or is an empty null string, a message is written as the content of the table cell. ■ The last line of code clears the xDepartment variable by resetting it to an empty string.

2.3.5 Looping

Loop structures allow you to execute the same code a variable number of times. Looping can be accomplished in two ways with Idoc Script: ■ Section 2.3.5.1, ResultSet Looping ■ Section 2.3.5.3, While Looping For information on exiting and ending a loop structure, see Section 2.3.5.5, Ending a Loop.

2.3.5.1 ResultSet Looping

ResultSet looping repeats a set of code for each row in a ResultSet that is returned from a query. The name of the ResultSet to be looped is specified as a variable using the following syntax: loop ResultSet_name code endloop ■ The code between the loop and endloop tags is repeated once for each row in the ResultSet. Idoc Script Application 2-9 ■ When inside a ResultSet loop, you can retrieve values from the ResultSet using the getValue function. Substitution of values depends on which row is currently being accessed in the loop. ■ When inside a ResultSet loop, that ResultSet becomes active and has priority over other ResultSets when evaluating variables and conditional statements. ■ You cannot use the loop tag to loop over a variable that points to a ResultSet. Instead you must loop over the ResultSet manually using the rsFirst and rsNext functions. For example, you cannot use the following code to loop over a ResultSet: name=SearchResults loop name --output code-- endloop Instead, you must use the following code: name=SearchResults rsFirstname loopwhile getValuename, isRowPresent --output code-- rsNextname endloop

2.3.5.2 ResultSet Looping Example

In this example, a search results table is created by looping over the SearchResults ResultSet, which was generated by the GET_SEARCH_RESULTS service. QueryText=dDocType matches ADACCT executeServiceGET_SEARCH_RESULTS table tr tdTitletdtdAuthortd tr loop SearchResults tr tda href=SearchResults.URLSearchResults.dDocTitleatd tdSearchResults.dDocAuthortd tr endloop table

2.3.5.3 While Looping

While looping enables you to create a conditional loop. The syntax for a while loop is: loopwhile condition code endloop ■ If the result of the condition expression is true, the code between the loopwhile and endloop tags is executed. ■ After all of the code in the loop has been executed, control returns to the top of the loop, where the condition expression is evaluated again. – If the result is true, the code is executed again. – If the code if the result is false, the loop is exited. 2-10 Oracle Fusion Middleware Idoc Script Reference Guide

2.3.5.4 While Looping Example