Jump to: navigation, search

Database Query Result Template

TempDBResult.png>br>
This template demonstrates how to access the results of a database query in a workflow.

  1. 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.
  2.  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.
  3. The SaveToVariables Assign block assigns the columns of the row in DBCurrentRecord into separate variables.
  4. 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.
  5. The FetchNextRecord ECMAScript block runs a script to load the next row from the DBRecords variable obtained by the first query.
  6. 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.

Feedback

Comment on this article:

blog comments powered by Disqus
This page was last modified on 28 October 2016, at 09:29.