View Single Post

   
  #1 (permalink)  
Old 02-28-2008, 07:13 AM
Artur Baæ
 
Posts: n/a
Default StoredProc: How to pass 'table' as argument ?

I have such StoredProc (Function)
Is it possible to pass 'Table' to stored proc as argument?

code
-----------------------------
CREATE FUNCTION `DDT`.`GetSelectMd5`() RETURNS varchar(255)
BEGIN
DECLARE done INT DEFAULT 0;

DECLARE row_crc32 INT;
DECLARE column_concat longtext;
DECLARE column_md5 varchar (64);
DECLARE reader CURSOR FOR SELECT CRC32_DATA FROM Table;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
OPEN reader;
SET column_concat = '';
WHILE not done DO
FETCH reader INTO row_crc32;
SET column_concat = concat(column_concat,row_crc32);
end while;
CLOSE reader;
set column_md5 = md5(column_concat);
RETURN md5(column_md5);
END
-----------------

How to use TableName from variable inside CURSOR FOR SELECT ...FROM
'TableName'?



Reply With Quote