Reputation: 1303
I have a stored procedure as follows.
Here I have created a temporary table named tempDesTable and put the data from database. Now I have to put additional data from another select query. But it shows Error Code : 1327 Undeclared variable: tempDesTable
BEGIN
CREATE TEMPORARY TABLE tempDesTable AS (SELECT ID, FirstName, LastName FROM t_users WHERE `DesignationID` = p_DesignationID AND BranchID = 0);
SELECT ID, FirstName, LastName INTO `tempDesTable` FROM t_users WHERE `DesignationID` = p_DesignationID AND BranchID = p_BranchID;
END$$
Upvotes: 0
Views: 8866
Reputation: 1883
You need to use insert ... select rather than select ... into
INSERT INTO tempDesTable SELECT ID, FirstName, LastName FROM t_users
WHERE `DesignationID` = p_DesignationID AND BranchID = p_BranchID;
Upvotes: 3