RuleAPI:Procedural commands/Database/SelectList

From FlexRule Wiki
Jump to: navigation, search

Summary

This command is very similar to SelectRow command the difference is it builds a list for values based on the return result from query. If one column is selected from SELECT command, then the list contains all the values for that selected column only. If multiple columns are selected, then the list contains complex object that the values of column can be access by object properties.

Parameters

  1. command
    1. Description: The Select command
    2. Mandatory: Yes
    3. Type: String
  2. return
    1. Description: Name of the variable in which the row will be stored
    2. Mandatory: Yes
    3. Type: String
  3. storedProcedure
    1. Description: Determines whether the command should execute a stored procedure in the database
    2. Mandatory: No
    3. Type: Boolean (true/false). Default is true.
  4. multi
    1. Description: Indicates whether the Select command will return multiple rows
    2. Mandatory: No
    3. Type: Boolean (true/false)

Internal Commands

Param

This command sends a Break command to the execution flow iterating inside a Do command.

Sample

Return list is a list of string values:

  1. <Database connection-ref="cnn" type="MsSql">
  2.   <SelectList command="select ([Made]+'-'+[Model]) as Car from [dbo].[HighRiskCars]" return="listResults"/>
  3. </Database>
  4.  
  5. <!-- This will read the first value which is a string -->
  6. <Var name="firstItem" value="listResults[0]"/>


Return list is a list of objects that have tow properties: made and model

  1. <Database connection-ref="cnn" type="MsSql">
  2.   <SelectList command="select [Made] as made, [Model] as model from [dbo].[HighRiskCars]" return="listResults"/>
  3. </Database>
  4.  
  5. <!-- This will read the 'made' property of the first item in the list -->
  6. <Var name="firstItem" value="listResults[0].made"/>