parametrize stored procedure
Hi,
I have one code that is as below:
CREATE ROCEDURE `get_count`()
BEGIN
SELECT count(`id`) FROM `t1`;
END
so I want change this code to new code that I can count any filed form any table.
for example:
CREATE PROCEDURE `get_count`(IN filed VARCHAR(25),IN table VARCHAR(25))
BEGIN
SELECT count(`field`) FROM `table`;
END
so wehen we use get_count('id','t1') so this code run:
SELECT count(`id`) FROM `t1`;
or get_count('name','t2') so this code run:
SELECT count(`name`) FROM `t2`;
and etc....
is this possible?
thanks
Subject
Views
Written By
Posted
parametrize stored procedure
1765
May 01, 2014 08:45AM
1050
May 01, 2014 10:02AM
1009
May 05, 2014 10:04PM
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.