469,602 Members | 1,962 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

How to pass table name as IN Parameter

HI All,

I have a requirement, I need to pass table as IN parameter in the stored procedure. But when I do this it just says Table 'database.strtable' doesn't exist
.
Can you guys please advice me how can I do so. I need to pass table from outside. Following is my stored procedure, please have a look

DELIMITER $$;
DROP PROCEDURE IF EXISTS `user`.`sp_performancereport`$$
CREATE DEFINER=`user`@`%` PROCEDURE `sp_performancereport`(startDate date,endDate date,user VARCHAR(255),strTable VARCHAR(255))
BEGIN
select R.DIAGNOSTIC_ID,
R.FEEDER_ID,
R.FEEDER_NAME,
R.DIAGNOSTIC_NAME,
R.UNIT UNIT,
Round(Max(VALUE),2) MAX_VALUE,
Round(MIN(VALUE),2) MIN_VALUE ,
Round(AVG(VALUE),2) MEAN_VALUE,
Round(STDDEV_POP(VALUE),2) STD
from strTable R
where R.TIMESTAMP between startDate and endDate
and R.FEEDER_ID IN (select DEVICE_ID from gm_temp_devices where USER_ID=user)
group by R.DIAGNOSTIC_ID
order by R.FEEDER_NAME,R.DIAGNOSTIC_NAME;
END$$
DELIMITER ;$$
Mar 31 '07 #1
0 1821

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Zlatko Matić | last post: by
9 posts views Thread by Jay Douglas | last post: by
1 post views Thread by Tarlanim | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.