# Execute a Stored Procedure from mySQL database table into my Bar Chart & Easy Chart

**URL:** <https://forum.inductiveautomation.com/t/execute-a-stored-procedure-from-mysql-database-table-into-my-bar-chart-easy-chart/15372>\
**Category:** Ignition\
**Created:** [September 16, 2017, 5:50am UTC](https://forum.inductiveautomation.com/t/execute-a-stored-procedure-from-mysql-database-table-into-my-bar-chart-easy-chart/15372 "2017-09-16T05:50:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AkikRanade](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@AkikRanade](https://forum.inductiveautomation.com/u/AkikRanade)\
**Post date:** [September 16, 2017, 5:50am UTC](https://forum.inductiveautomation.com/t/execute-a-stored-procedure-from-mysql-database-table-into-my-bar-chart-easy-chart/15372/1 "2017-09-16T05:50:04Z")

</div>

I am trying to implement Bar Chart & Easy Chart for my logged KWh values. These values have been logged in a mySQL database table and I am trying to extract KWh Consumption on variable time-period basis. For this purpose, I have created a Stored Procedure in mySQL & am trying to Call this Stored Procedure into Bar Chart & Easy Chart with a selectivity on basis of Historical Date/Popup Calendar.  
I tested the same with a Table and Column Selector, which worked quite easily. The script which I implemented on my Table & Column Selector is as follows;-  
\<call = system.db.createSProcCall(“meter\_historian.Test”)  
\<system.db.execSProcCall(call)  
\<results = call.getResultSet()

\<table = event.source.parent.getComponent("Table") \<table.data = results \<event.source.Data\_in= results \<event.source.Data\_out= results

How could I use similar script onto my Bar Chart & Easy Chart.

Thanks  
Akik

---

<div class="post-metadata">

**Author:** ![rrdiggy76](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rrdiggy76/32/3741_2.png) [@rrdiggy76](https://forum.inductiveautomation.com/u/rrdiggy76)\
**Post date:** [September 18, 2017, 7:26pm UTC](https://forum.inductiveautomation.com/t/execute-a-stored-procedure-from-mysql-database-table-into-my-bar-chart-easy-chart/15372/2 "2017-09-18T19:26:22Z")

</div>

Does it need to be a script? Just bind the DATA property of the Easy Chart or Bar Chart to an SQL query. In your query, call the SP with whatever parameters you need. (Note, my example shown is probably for calling an SP in MS SQL…)

The parameters you call can be bound to elements on your page to a calendar selector so it’s dynamic.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/fb21b8c51a933c4f9aa0ae12175c7e03d7439929.PNG)

---

<div class="post-metadata">

**Author:** ![AkikRanade](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@AkikRanade](https://forum.inductiveautomation.com/u/AkikRanade)\
**Post date:** [September 18, 2017, 7:37pm UTC](https://forum.inductiveautomation.com/t/execute-a-stored-procedure-from-mysql-database-table-into-my-bar-chart-easy-chart/15372/3 "2017-09-18T19:37:38Z")

</div>

I tried applying SP directly into SQL query binding of Data property but it didn’t fetch the data.  
And even if it did, how will I provide column selectivity, i.e. selectivity similar to Column Selector and Table. I tried binding Column Selector with Bar Chart but that didn’t work either.  
Could you suggest a better way to provide selectivity so that it stays interactive for the User. He just has to select respective datetime and his choice of tags & Bar Chart component does the rest.

P.S. I saw a somewhat similar feature in Demo wherein Ad-Hoc Chart was prepared with Tag Browser & DB selection. I would need a simplified version of what’s done in there.
