How can I work with an Oracle SQL function which returns a REF CURSOR in Database Toolbox 3.5.1 (R2009a)?
3 次查看(过去 30 天)
显示 更早的评论
My SQL function in my ORACLE database returns a REF CURSOR. Can I work with this SQL CURSOR object in MATLAB? How can I execute this procudere which returns a REF CURSOR and retrieve the resulting dataset?
采纳的回答
MathWorks Support Team
2011-11-2
To execute the stored procedure use the EXEC function:
result = exec(conn,'SELECT my_package.my_function FROM myTable');
Then you may parse the value manually by working with the Java objects:
%%Get the java object
res = result.ResultSet;
res.next;
res = res.getObject(1);
%%Get the data from the Java object
i=1;
while res.next == 1 % For all rows
x{i,1}=res.getObject(1); % Get data from 1st column
x{i,2}=res.getObject(2); % Get data from 2nd column
% etc
i = i + 1;
end
0 个评论
更多回答(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!