mysql - 从另一个存储过程中的存储过程返回表

时间:2015-01-23 23:58:12

标签: mysql stored-procedures

我有storedproc1,在此我想调用usp_splitDelimitedStr。 usp_splitDelimitedStr创建临时表并从中进行选择 我想使用从usp_splitDelimitedStr返回的值将它们插入到storedproc1中创建的临时表的列中。 所以它看起来像这样,

CREATE PROCEDURE storedproc1
 (
CREATE TEMPORARY TABLE tmpAdditionalInfo 
    (FieldKeys VARCHAR(255), FieldValues VARCHAR(255));

.....

-- here I insert into the column using the 
INSERT INTO tmpAdditionalInfo(FieldKeys) VALUES (CALL usp_splitDelimitedStr(In_OrderFieldKeys,'|'));

)

注意:这样做的背景是使用usp_splitDelimitedStr来拆分分隔的字符串并通过从它创建的临时表中选择它们来返回分割的字符串(即调用者,即storedproc1),我不能使用函数,因为它无法在mysql函数中返回表。

任何建议都将不胜感激

1 个答案:

答案 0 :(得分:0)

调用该过程,然后从SELECT语句中创建的临时表中调用INSERT

CALL usp_splitDelimitedStr(In_OrderFieldKeys, '|');

INSERT INTO tmpAdditionalInfo (FieldKeys)
SELECT FieldKeys
FROM tableCreatedBy_usp_splitDelimitedStr;