MySQL Forums
Forum List  »  Stored Procedures

Passing TableName to a Stored Procedure
Posted by: Clive Morris
Date: June 09, 2022 04:13PM

I am trying to pass a table name to a stored procedure simple example code follows:

DELIMITER //
CREATE PROCEDURE myProcedure(IN tabName varchar(50))
BEGIN

SELECT tabName; -- Correctly outputs the expected value assigned to tabName

SELECT ClientID FROM tabName limit 100; -- Throws error

END //
DELIMITER ;

The first select statement displays the value of the variable as expected but the second select statement throws the error: Table 'mydatabase.tabName' doesn't exist

Options: ReplyQuote


Subject
Views
Written By
Posted
Passing TableName to a Stored Procedure
407
June 09, 2022 04:13PM


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.