Using appRules to Read and Process Stored Procedure Records

appRules Studio includes workflow activites for reading records from a stored procedure.  By utilizing the stored procedure related activities, the stored procedure records and the fields they contain can be read from the database and utilized in appRules just like any other records and fields.

Once a stored procedure record is read into an appRules project, the record and its fields can be used in Mappings, Custom Functions, Conditions, and other modules and facilities.

In this post, we will walk through a simple workflow example for reading records from a stored proceedure and viewing the field values using the ViewRuntimeRecords  activity.

Below is the sample workflow for reading records from a SQL Server Northwinds sample database stored procedure:

 

The table below shows the key workflow activities used in composing the workflow:

 

# Activity Type Notes
1 initializeProject Use the default values
2 ExecuteMssqlStoredProcedure

(ExecuteSqlServerStoredProcedure)

This activity is used to define a Source to select the records to be processed.

 

  • Configure the DataSource property to select the data source to be used for connecting to the database.

 

  • Set the StoredProcedure property by selecting it from the list of stored procedures in the database.

 

  • Define the fields in the stored procedure record by adding an entry for each field in the StoredProcedureFields collection. Only the field name and field type is required when defining the field.  The field name must match the column name used in the stored procedure.

 

  • If your stored procedure uses parameters, you can define them by adding an entry for each parameter in the StoredProcedureParams collection.

 

  • Set the AutoLoad property to FirstRecord to read the first record from the stored procedure once the activity is initialized.

 

3 While Use a While activity to control the flow of the workflow.

 

  • Configure the Condition by using the App.ActionResultIsValid flag to check the last action performed by the activity before the While activity.

 

  • Add a Sequence activity to the Body of the While activity. This Sequence will contain activities that will read and display the next record from the stored procedure.

 

4 ViewRuntimeRecords Use the default values to display the fields read from the stored procedure.

 

5 GetNextMssqlRecord

(GetNextSqlServerRecord)

Reads the next record from the stored procedure.
6 CloseMssqlSource

(CloseSqlServerSource)

Closes the connection to the database
7 CloseProject Closes the project, logs statistics and frees resources
 

 

 

Below are the properties of the ExecuteSqlServerStoredProcedure activity:

 

This is an example of how you can use appRules workflow activities to read records and associated columns from a stored procedure.

You can download appRules Studio including this sample project at: http://www.appstrategy.com/appRulesTrial

Author: appStrategy Team

appStrategy Support Team blog