Reading Data
Overview
Your appRules projects may require reading data from files, data bases, SAAS applications and other sources. appConnector activity modules include activities for initializing Sources for reading data. For example, the appConnector SQL Server module features the InitializeMssqlSource and InitializeMssqlSourceFromQuery activities. Once initialized, you can use the GetNextMssqlRecord activity to read the next record from the result set in the Source.
InitializeSource Activity
The appRules InitializeSource activity is used for initializing the Source. For example, to read data from Microsoft SQL Server, you will need to initialize the Source of the data, select the connector to use and define filters for specifying the records to read. At design time, you can also get a count and view the records defined by the Source that you have defined.
For example, to define the Source for reading SQL Server data source, drag the InitializeSource activity from the SQL Server module activities on to the designer and configure the properties as follows:
InitializeSourceFromQuery Activity
In addition to the standard Source initialization activity defined in the previous section, you can also optionally use a query to define the Source to be used for reading records if the appRules module includes the InitializeSourceFromQuery activity.
For example, to use a query to read data from SQL Server, use the InitializeSourceFromQuery activity from the SqlServer toolbox:
For example, to define the Source for reading SQL Server data source, drag the appropriate InitializeSourceFromQuery activity on to the designer and configure the properties as follows:
GetNextRecord Activity
To read the next record from an open connection in appRules, you use the GetNextRecord activity from the appropriate activity module. For example, to read the next record from a SQL Server data source, drag and drop the GetNextRecord activity on to the designer. The only property required is the Source (An InitializeSource activity defined previously in the project).
Looking up Data
appRules includes activities for looking up data from data sources. Lookups provide a convenient means of reading a specific record from the data source. You can also use the Lookup activities to verify existence of a record in the data source.
LookupRecord Activity
The LookupRecord activity returns a specific record from a data source. It uses the same properties as the as the InitializeSource activity discussed in the previous chapter.
LookupPreloadedRecord Activity
The appConnector InitializeSource activities can be configured to load records into memory. If an activity module supports preloading of records, a record can be loaded from the list by using a LookupPreloadedRecord activity.