Selecting fields from a sql stored procedure

8 visualizzazioni (ultimi 30 giorni)
Thomas
Thomas il 23 Mag 2013
Risposto: Piyush Kumar il 29 Ott 2024 alle 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

Risposte (1)

Piyush Kumar
Piyush Kumar il 29 Ott 2024 alle 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