Update variable after panel update

I have a panel that executes a SQL Server stored procedure. I want a variable to be updated after the stored procedure’s execution is complete, how can i do it?

welcome to forum @miguelcasadinho

does your procedure return a value? Like in following

CREATE PROCEDURE dbo.miguel_jeffe
@SalesPerson NVARCHAR (50), @SalesYTD MONEY OUTPUT
AS

Yes, the input parameters are date from and date to and it returns a dataset. Then I need to update a variable when the execution is complete

a dataset mapped to a variable? hmmm, not sure that is possible. now we go to the nook of your requirement. what is it you are attempting to do.

I have a panel that executes a SQL Server stored procedure. This stored procedure can’t be called multiple times because it creates temporary tables. However it also saves results to a table. I want to execute it once and, when it finishes, update a variable to signal that the execution is complete. Other panels should then use this variable to query the result table.

However, all panels refresh simultaneously. So when the stored procedure is executed, the result table is not yet updated, and the other panels end up reading outdated data.

remember grafana is a visualization tool primarily. you are trying to use it to manage some sort of state or manage some sequence of events. I would highly recommend you re-think this approach.

why not have maybe some other process that keeps populating the main table on some sql server schedule.

1 Like

Thanks for your support, Yosiasz. That was actually my first thought. I was just trying to find out if there was a way to handle this on the Grafana side—like I mentioned before, by updating a variable after a panel loads.