How to get recordset from internal call to stored procedure?

前端 未结 2 552
情深已故
情深已故 2020-12-07 05:28

I have a stored procedure, internally I want to call another procedure that returns a record set, how do I get an navigate the record set returned by the stored procedure vi

2条回答
  •  醉酒成梦
    2020-12-07 06:02

    internally I want to call another procedure that returns a record set,

    In your inner procedure create a TEMPORARY TABLE and populate that temp table saying insert into your_temp_table select query. then you can use that same temp table in your outer query anywhere.

    It can even be a normal table as well and need not be temporary table. Also make sure to DROP the table once your procedure computation done as clean-up.

    That's wrong per your comment. You should do it like below (a sample code)

    create procedure rsHeadOfAnyDepartments(vcCompKey varchar(10), biWho_id int)
    as
    begin
    DROP TEMPORARY TABLE IF EXISTS tbl_HeadOfDepts; 
    CREATE TEMPORARY TABLE tbl_HeadOfDepts(col1 int, col2 varchar(10), col3 varchar(30));
    
    INSERT INTO tbl_HeadOfDepts
    SELECT col1, col2, col3
    FROM tblTest;    
    end
    

提交回复
热议问题