Though there are many questions in Stack Overflow regarding this problem I didn't able to figure it out properly, could anyone can help me to figure this out, let's say that there are two stored procedures as,
CREATE PROCEDURE `procOne`(stName varchar(7),fullItemCode varchar(12), fullLedNo varchar(12))
BEGIN
set @x = concat('
SELECT ID, Uprice FROM ',stName,'
where Uprice > 0 and FulItmCode="',fullItemCode,'" and FullLedgerNo = "',fullLedNo,'" order by Dat desc limit 1;
');
PREPARE stmt FROM @x;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END
and
CREATE PROCEDURE `prcTwo`()
BEGIN
CREATE TEMPORARY TABLE tmpStore (
ID int(10),
Uprice decimal(18,2)
)
insert into tmpStore exec procOne(@param1, @param2)
select * from tempStore;
DROP TABLE tmpStore;
END
I have tried this, but am getting the following error when attempting to save prcTwo
ERROR 1064: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'insert into tmpStore exec procOne 'St_BFG','SCI019', 'BIO-JVS-30' output
sele' at line 9 SQL Statement: CREATE DEFINER=user1@localhost PROCEDURE
prcTwo() BEGIN CREATE TEMPORARY TABLE tmpStore ( ID int(10), Uprice
decimal(18,2) ) insert into tmpStore exec procOne 'St_BFG','SCI019',
'BIO-JVS-30' output select * from tempStore; DROP TABLE tmpStore; END