CoMmAnD aNd CoDe

Wednesday 8 July 2015

Spotfire - Triggers to DB via passing parameter from dxp

Spotfire can execute stored procedures and these procedures could be fetching data, or can be procedures that can be run Pre or Post running a query. You can then use procedures that basically update your database table or even inserts new rows in tables.

When using Spotfire information model it allows you to use these procedures which you can repurpose for updating your database.
Spotfire also understands inputs to a procedure and they can be mapped to your marked rows/filtered rows/ properties/constants etc from your analytics.

Steps to do that would be
1)Create a procedure that accepts inputs e.g. what is the value you want to update and some sort of key column(s) identifier for the record to update.
2) Create a Spotfire procedure element
3) Depending if you procedure is going to bring back some data or not, use the query or pre or post option correctly.
4) Create an Information Link that uses this Procedure element.
5) Ensure that your inputs to procedures are parameters and then use ?name syntax to map them to parameters.
6)Now in your analysis you can add this information link and chose to make it on demand.
7)Map you inputs to desired marking, filtering or property controls etc.
8) Generally I would recommend not using Automatic updates to avoid unnecessary write backs and also not select caching to ensure the procedure is run every time you need to.

9)Then the last step is writing a small ironpython script trigger the procedure whenever desired. Attach the script to a button or a link as desired in text area

if ondemandTable.IsRefreshable and ondemandTable.NeedsRefresh:
   ondemandTable.Refresh()
   dataTable.Refresh()