Selecting fields from a sql stored procedure

8 Ansichten (letzte 30 Tage)
Thomas
Thomas am 23 Mai 2013
Beantwortet: Piyush Kumar am 29 Okt. 2024 um 11:15
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

Antworten (1)

Piyush Kumar
Piyush Kumar am 29 Okt. 2024 um 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.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by