472,119 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

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 2039

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 leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.