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:

CREATE PROCEDURE myProcedure(IN tabName varchar(50))

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

SELECT ClientID FROM tabName limit 100; -- Throws error

END //

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

Written By
Passing TableName to a Stored Procedure
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.