Skip navigation links

MySQL Forums :: Stored Procedures :: Error 1054 when select *


Advanced Search

Error 1054 when select *
Posted by: Yuval Cohen ()
Date: October 09, 2012 10:24AM

I create the following stored proc:
====================

DELIMITER $$
DROP procedure IF EXISTS `test` $$
CREATE PROCEDURE `test` (IN num INT)
BEGIN

drop table if exists temp_test;

IF num = 0 THEN
create table temp_test ENGINE=MEMORY as
select
'zero' as zero;
ELSE
create table temp_test ENGINE=MEMORY as
select
'not-zero' as not_zero;
END IF;
SELECT * from temp_test;
drop table temp_test;
END$$

================

Then I try to run:
call test(0);
followed by:
call test(1);

Which output error: Error Code 1054 Unknown column temp_test.zero' in field list.

Strange enough, if I recompile the stored proc, or diconnect => reconnect, and run:
call test(1);
followed by:
call test(0);

The first call succeed whilst the second call fails with error: Error Code 1054 Unknown column temp_test.non_zero' in field

In any case, the second call fails.
WHY???

Options: ReplyQuote


Subject Views Written By Posted
Error 1054 when select * 1250 Yuval Cohen 10/09/2012 10:24AM
Re: Error 1054 when select * 511 Rick James 10/10/2012 10:38AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.