1

I wrote the following procedure but am having trouble setting the results of my stored procedures to the variables: @pZipID and @pCountyID. I have tried nesting the stored procedures in parentheses. That is to say:

SET @pCountyID = (CALL addCounty(pCounty));

I also tried:

CALL addCounty(pCounty) INTO @pCountyID

But to no avail. This is the entire stored procedure:

DROP PROCEDURE IF EXISTS readZipAndCountyIntoTables;
DELIMITER //
CREATE PROCEDURE getCountyNameFromZip(pZipcode VARCHAR(16), pCounty VARCHAR(250))
BEGIN
    DECLARE pZipID INT DEFAULT 0;
    DECLARE county_id INT DEFAULT 0;
    SET @pZipID = CALL addZipcode(pZipcode);
    SET @pCountyID = CALL addCounty(pCounty);
    CALL addZipToCounty(pZipID, pCountyID);
END//
DELIMITER ;

MySql has been absolutely useless in finding the error. Please let me know if there is a small syntax issue I am causing as I know for a fact it is either the declaring or the setting that have issues. I took out the setting and declarations and called the stored procedures and no errors occured.

Let me know if you need to see the other stored procedures if you need more clarity. But they have been thoroughly tested.

Any help is appreciated. Thanks in advance.

Tyson Graham
  • 227
  • 3
  • 9
  • take a look at this here http://stackoverflow.com/questions/2608668/mysql-save-results-of-execute-in-a-variable – algor Feb 25 '16 at 01:47
  • 1
    You need to use `OUT` parameters in stored procedures. See [13.1.16 CREATE PROCEDURE and CREATE FUNCTION Syntax](http://dev.mysql.com/doc/refman/5.7/en/create-procedure.html). – wchiquito Feb 25 '16 at 14:09
  • https://stackoverflow.com/a/39029289/2669139 – Mark Kreyman Aug 07 '20 at 18:50

0 Answers0