Forum Discussion
How to pass a parameter to a MySQL stored procedure from powerBI
Hi - I am using powerBI to connect to a MySQL server. We can connect fine and we can receive data fine - I am calling a stored procedure from powerBI using the following command;
CALL my_sp();
My problem is that when I try to pass a parameter to the stored procedure like this;
SET @p0 = 'xyz';
CALL my_sp(@p0);
Power BI returns a message saying I should use an unencrypted connection. When I do it then gives the following error: "MySQL: Fatal error encountered during command execution."
So my question is - how can I pass a parameter to a MySQL stored procedure from powerBI?
I'd be grateful for any pointers / advice. Thank you.
9 Replies
- AnonymousNot applicable
Hey ebjm
Hopefully this can help you out. I wrote this reply on another thread:
"It turns out that this is actually possible in Power BI. I've created a walkthrough video on how to do this here.
The basic gist is to add an R visual that takes in your slicer selection as its value. There is an R package called RODBC that can run SQL code against your database. You can then pass your slicer value into the SQl query using some string interpolation or the "paste" function. Let me know how this works for you."
You will need to change the connection type from SQL Server to MySQL.
Hope this helps,
Parker
- nirvana_moksh
Impactful Individual
So you can use the R code will pass the date parameter in your Stored Procedure and this will work with more than one parameters too?
- AnonymousNot applicable
Yep, you can pass as many fields into the R visual as you need. You can then reference all of them in your SQL code embedded in your R code
- ebjmRegular Visitor
Thanks but I am puzzled. Why can I pass the following from Power BI to my MySQL server?
CALL my_sp();
but I am not allowed to pass
SET @p0 = 'xyz';
CALL my_sp(@p0);- AnonymousNot applicable
How are you passing it?