GURUS - SHOW TABLES & SQL_CALC_FOUND_ROWS
Posted by:
Peter Larb
Date: January 23, 2006 03:06PM
Good morning
APOLOGIES: I have placed this code here as it is inside a stored proc, but alsio because I had no success in the "general" category.
I wish to do the following:
1. return an integer (0 or 1) whether a table exists in the database
otherwise I will create the table
Problem: instead of returning an integer I am being returned the "table
name" if it exists, or a NULL.
Now I understand that I need to use "SQL_CALC_FOUND_ROWS" but I am
unsure of how to implement that here.
Can anyone help ?
Thanks
Peter
My code so far:
DELIMITER $$;
DROP PROCEDURE IF EXISTS `Research`.`spTableExists`$$
CREATE PROCEDURE `spTableExists`(tableName varchar (5))
BEGIN
DECLARE MyTable VARCHAR(512);
SET @MyTable = concat('SHOW TABLES FROM MyDatabase LIKE ',"'",
tableName, "%'");
PREPARE stmt1 FROM @MyTable;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;
SELECT FOUND_ROWS();
END$$
DELIMITER ;$$
Peter Larb
Subject
Views
Written By
Posted
GURUS - SHOW TABLES & SQL_CALC_FOUND_ROWS
1870
January 23, 2006 03:06PM
1272
January 24, 2006 10:46AM
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.