Subject | Stored procedure return multiple resultsets? |
---|---|
Author | |
Post date | 2017-01-06T15:36:02Z |
Will Firebird 4.0 support stored procedures returning multiple resultsets to the application layer? All other DBMS support such a feature.
The whole point of stored procedures are to encapsulate SQL logic and sometimes it is required to send multiple record sets to the application layer. Currently, we have to have a separate stored procedure for each recordset and then have to combine them at the application layer which creates more work and breaks encapsulation.
Here is an pseudo example in postgresql:
CREATE FUNCTION get_topics
(
OUT p_topics REFCURSOR,
OUT p_users REFCURSOR
)
AS
BEGIN
OPEN p_topics FOR SELECT * FROM topics;
OPEN p_users FOR SELECT * FROM users;
END
Here is a pseudo example in TSQL (Mssql):
CREATE PROCEDURE get_topics()
AS
BEGIN
SELECT * FROM topics;
SELECT * FROM users;
END
The whole point of stored procedures are to encapsulate SQL logic and sometimes it is required to send multiple record sets to the application layer. Currently, we have to have a separate stored procedure for each recordset and then have to combine them at the application layer which creates more work and breaks encapsulation.
Here is an pseudo example in postgresql:
CREATE FUNCTION get_topics
(
OUT p_topics REFCURSOR,
OUT p_users REFCURSOR
)
AS
BEGIN
OPEN p_topics FOR SELECT * FROM topics;
OPEN p_users FOR SELECT * FROM users;
END
Here is a pseudo example in TSQL (Mssql):
CREATE PROCEDURE get_topics()
AS
BEGIN
SELECT * FROM topics;
SELECT * FROM users;
END