...
The SQL database has two tables called "Zone" and "Rules". Users are allowed to select a "zone_id" from the Zone table and use the "zone_id" as a foreign key to select the rules display all the rows associated with that " zone_id ". In the Zone tablein the Rules tables. Here, "zone_id" is the primary key in the Zone table and "Demog" is the foreign key in the Rules table. Please see below the structure of Zones and Rules tables.
...
Code Block | ||
---|---|---|
| ||
{groovy:output=wiki} import com.atlassian.renderer.v2.RenderMode def choiceSql = "select distinct concat( zone_id,':', zone_id,':') from zone ;" def choiceMacro = "{sql-query:datasource=yoga-sql|table=false} ${choiceSql} {sql-query}" def choices = subRenderer.render(choiceMacro, context, RenderMode.suppress(RenderMode.F_FIRST_PARA)) def runMacro = """ {run:id=dynamic|autorun=true|replace=report:2010::select::${choices.replaceAll(" ","::")} } {sql-query:datasource=yoga-sql|rowStyles= ,background-color:lightblue,} select * from rules where demog = '\$report'; {sql-query} {run} """ out.println runMacro {groovy} |
The end result would be as shown in the screenshot below.
- The customer is asked to select a zone Id from the drop-down.
- Hit the Run button to generate the output
- The output shows the table results.
Note |
---|
Modify the SQL data source, table names, and columns as per the instance. |
...