Database Query Result Template
This application demonstrates how to access the results of a database query in a workflow.
- First, the application makes a query in the GetStockQuotes DB Data block. The query is defined using the Query Builder interface. The results of the query are saved to variables call DBColumnNames and DBRecords, which are defined in the Entry block. They are assigned using the Database Result Set properties of the DBData block.
- Next, the FetchFirstRecord ECMAScript block uses a script to access the data. The DBRecords variable is a two-dimensional array containing the rows and columns of the returned data. The script in the FetchFirstRecord block extracts and assigns the first row of to a variable called DBCurrentRecord.
- The SaveToVariables Assign block assigns the columns of the row in DBCurrentRecord into separate variables.
- The next DB Data block, DBData1, uses the variables assigned in the previous step to make a stored procedure query to the database. The stored procedure is defined with the Stored Procedure builder interface, which is similar to the Query Builder.
- The FetchNextRecord ECMAScript block runs a script to load the next row from the DBRecords variable obtained by the first query.
- The CheckMoreRecord Branching block checks if there are any more records (rows) in the result set and will loop back if there are in order to process the next row and repeat the stored procedure query in DBData1. Once there are no more records to process, the workflow exits.
This page was last modified on July 23, 2013, at 12:15.