List:General Discussion« Previous MessageNext Message »
From:Imre Palik Date:March 7 2007 4:13pm
Subject:Table doesn't exist from stored function
View as plain text  
Hi,

When I try to run this function, I receive ERROR 1146 (42S02): Table 
'gi2.meta' doesn't exist

CREATE FUNCTION get_version()
RETURNS INT UNSIGNED
BEGIN
  DECLARE exist_ TINYINT;
  SELECT COUNT(*) INTO exist_ FROM INFORMATION_SCHEMA.TABLES
   WHERE TABLE_SCHEMA = 'GI2' AND TABLE_NAME = 'Meta' LIMIT 1;
  IF (0 < exist_) THEN BEGIN
      DECLARE ver_ INT UNSIGNED;
      SELECT SUBSTRING(Version, 14, LENGTH(Version) - 15) INTO ver_
        FROM GI2.Meta LIMIT 1;
      IF (ver_ <= 65) THEN RETURN 5;
      ELSE RETURN 0;
      END IF;
    END;
  END IF;
  RETURN 1;
END;

I can't see why I am receiving this error, as I am checking if the table 
exists before the select.  If this is a limitation in MySQL, any ideas 
how to circumvent it?

Thanks

ImRe

Thread
Table doesn't exist from stored functionImre Palik8 Mar
  • Re: Table doesn't exist from stored functionShawn Green11 Mar
    • Re: Table doesn't exist from stored functionPeter Brawley11 Mar