I need to call MySQL stored procedures in kitura application and use it for the query result. how can I do that
The use of Stored Procedures is not something that the current release of the SwiftKuery framework has support for.
If you feel that Stored Procedure support would be of benefit to the community then please feel free to raise an issue on SwiftKueryMySQL.
Related
I have a stored procedure which outputs 2 tables. I would like to save the output into two .csv files or into one Excel file. Is it possible to do so?
I am not sure how much it can help you, but you can create a DLL to generate CSV by excepting some input data and use that dll inside extended stored procedure. Call that store procedure using sqlcmd.
Extended stored procedure
But be aware Microsoft is suggesting to not use extended stored procedure as it will not be available in future.
Important
This feature will be removed in a future version of Microsoft SQL Server. Do not use this feature in new development work, and modify applications that currently use this feature as soon as possible. Use CLR Integration instead.
This not a go/no go question. I've used all kinds of 4GLs (PL/SQL, T-SQL, PGSQL etc.) for database back-end coding and find very useful to establish data layer "closest" to database engine.
Now MySQL stored procedures got my attention and very interested in coding in this brand new 4GL platform.
I would like to start using it in one of my proof of concept projects. What you folks think about MySQL stored procedures? Crucial question is; Is it reliable? How "Oracle Corporation" supports MySQL stored procedures (i.e. documentation, forums etc.)?
Thanks
Support started in v5.0, it's currently in v5.1 (v5.5 is in the pipe). If they weren't reliable, they'd have been removed.
I don't know what you mean by "how Oracle supports it" - the syntax is different, rarely (if ever) will you be able to port an Oracle stored procedure directly to MySQL without alteration.
A mySQL stored procedure will be as reliable as you make it. If you write it to do everything you need then it will be fine. If you don't it wont.
As #OMG states they began supporting in version 5.0.
What do you mean when you ask how Oracle supports it?
I'm working on a project where most of the times I'm going to call database with a stored procedure and I'm a little bit confused what should I do. Options are not just restricted to Sql to Linq and EF. If there are any better options please suggest them too.
UPDATE - Reason for using SPs
I've to apply logic in many of the stored procedure. Apart from this, my intention to use SPs for CRUD operation is to improve performance.
Thanks in advance.
ORM tools wasn't designed to be used only with stored procedures (but they could), it will be very difficult to map data on eneities and perform all operations using EF. You can relay on this guide, but I need some details to suggest something more meaningfull.
Is it possible to step through a mysql stored procedure, watching the values of variables at each step.
See this related question for some ideas related to debugging stored procedures:
How do you debug MySQL stored procedures?
Edit:
I tried out the trial of Debugger for MySQL and it looks promising. You might give that a try.
Where I work it is a requirement for us to go through stored procedures as a mechanism to access our data through code. I am using LINQ2SQL to minimize this pain so that I can work with objects instead of ADO.NET directly. I have a situation Linq2SQL is consuming one of my stored procedures an generating code where the return type from the stored proc call is an int. The stored procedure actually returns a dataset. After doing a little research I have found that this is because the SQLClient library can not properly parse the sproc to generate the expected metadata that Linq2SQL uses to create the object graph. My question is how can sprocs (even complex ones) be structured so that you get an object graph out of linq2sql, or in other words what should you avoid having in your stored procedure that will create confusion for the SQLClient library to not understand how to generate the metadata that linq2sql consumes in order to create an object graph?
This is not actually a limitation of LINQ to SQL but rather of SQL Server which can not always tell a client what the return type would be without actually running it when it contains temporary tables, cursors or dynamic SQL.
As running it with invalid parameters could be potentially catastrophic it doesn't try.
You can either set it by hand using the designer or if it is absolutely okay to run the stored procedure with invalid data (i.e. it is purely passive) then you can add SET FMTOPT OFF to the start of the stored procedure.
DamienG works on the LinqToSql team at Microsoft and I have upvoted his answer as correct.
That said, he likely won't advise you away from LinqToSql and I think it's very important to consider that option.
Trying to guess the return type of a stored procedure is very difficult and LinqToSql does it as well as anyone (for SQL Server). That said, there are very compelling reasons not to use stored procedures:
Stored procedures are bad, m'kay?
If you must protect your tables from developers for "security reasons" (which I'm guessing is the situation you are in), it's best to do that with views instead of stored procedures.
If you are using views, you then have a lot better options in the ORM department than LinqToSql.
The main problem you are going to run into with LinqToSql in this regard is that what works fine for 5 stored procedures in a tiny database doesn't work fine for 50 or 500 stored procedures. You can use the O/R Designer to "override" the return type of a stored procedure, but you will have significant syncing issues when stored procedures or the tables, etc. they operate on change. Changes to stored procedures will not get reflected in the O/R Designer unless you remove the stored procedure from the O/R Designer, re-add it, and then reapply your custom override. If your project is like any normal project, the tables and stored procedures change often and this sync issue soon becomes a nightmare because it's completely manual and if you fail to do it correctly you will get very strange errors at runtime.
I would strongly advise against continuing down the path you are on.