Subject call stored procedure from another one.
Author mcnamara_gio
Hello,

I have a stored procedure that accepts a single parameter and returns
multiple rows with multiple columns. Can I call this stored procedure
from another stored procedure and how do I read its result?

The first procedure is like this:

CREATE PROCEDURE sp1( pid Varchar(15) )
RETURNS (
CODE Varchar(15),
NAME Varchar(50)
//Some more variables.)
AS
BEGIN
for
with recursive test as (
select id, pid, nm, 0 depth
from smth
where pid= :pidd
union all

select smth.id, smth.pid, smth.nm,test.depth+1
from smth
join test on smth.pid=test.id
)

select id, nmfrom test
union all
select id, nm from smth
where ccode=:parent
into :code,:name do
begin
-- Here I want to call another sp read it's return values (all rows
and columns) and put them in return variable of this stored procedure.
end
END^

Is it possible? If yes how?

Thanks in advance