When used within single quotes nt
will not be treated as variable but a literal.
Use local variable to set value into and assign the same to out param after execution.
Example:
DELIMITER //
CREATE DEFINER=`root`@`localhost`
PROCEDURE `get_ntime`( in tb varchar(50), in d int, out nt varchar(50) )
BEGIN
SET @staetment = concat( 'Select ntime into @nTime from ', tb );
-- SET @date = CONCAT( ' WHERE date = "', d, '"' );
SET @date = CONCAT( ' WHERE date = ?' );
SET @statement = CONCAT( @statement, @date );
SET @dt := d;
PREPARE stmt FROM @statement;
-- EXECUTE stmt;
EXECUTE stmt using @dt;
DEALLOCATE PREPARE stmt;
SET nt := @nTime;
END;
//
DELIMITER ;