Selecting fields from a sql stored procedure
8 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Piyush Kumar
2024 年 10 月 29 日 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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Database Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!