Documentation Data Sources FAQs

Call stored procedures in SQL Mode

Chartio allows you to call stored procedures you’ve created in your database in your SQL Mode queries. Our ability to visualize that data will depend on how the data is returned from the stored procedure.

MySQL and PostgreSQL

MySQL Permissions

Make sure to grant EXECUTE privileges for the database user you’re using to connect to Chartio by running the following command in your database:

GRANT EXECUTE ON PROCEDURE procedure_name TO 'username'@'host';

where host is typically Chartio’s IP address (52.6.1.1) or % for any IP address.

Run MySQL or PostgreSQL stored procedures

Use the following syntax in your SQL Mode query to call your stored procedure, replacing stored_proc_name with the name of your stored procedure:

CALL stored_proc_name();

Here’s an example of how you’d pass required parameters to your stored procedure:

CALL stored_proc_name('var_name1_value', 'var_name2_value');

You can also pass Dashboard Controls as parameters—just use the proper SQL Mode syntax for referencing Controls.


SQL Server

Run SQL Server stored procedures

Use the following syntax in your SQL Mode query to call your stored procedure, replacing stored_proc_name with the name of your stored procedure:

EXEC stored_proc_name;

Here’s an example of how you’d pass required parameters to your stored procedure:

EXEC stored_proc_name @var_name1 = 'value1', @var_name2 = 'value2';

You can also pass Dashboard Controls as parameters—just use the proper SQL Mode syntax for referencing Controls.


Other syntaxes

Chartio can also execute stored procedures for databases that use the SELECT stored_proc_name() syntax.