Selecting fields from a sql stored procedure
8 views (last 30 days)
Show older comments
I am trying to figure out how to translate a sql query such as the following using the database toolbox. Assistance much appreciated!
Select PositionDate, Quantity, StrategyDescription
From MYStoredProc('DEF', '1', default)
where StrategyDescription not in ('Event')
Thanks Thomas
0 Comments
Answers (1)
Piyush Kumar
on 29 Oct 2024 at 11:15
Hi,
I couldn't find a way to write a SQL query that directly achieves the desired filtering.
However, If you want to call a stored procedure and filter its output using a MATLAB script, you can use fetch function to execute the sql query and filter its output using MATLAB.
% Define the SQL query to call the stored procedure
query = "CALL MYStoredProc('DEF', '1', DEFAULT)";
% Execute the query and fetch the results
data = fetch(conn, query);
% Filter the results in MATLAB
Also, I have found a stack overflow question that highlights this as the limitations of stored procedures in SQL and suggests to use user defined functions in these scenarios.
0 Comments
See Also
Categories
Find more on Database Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!