Registriert seit: 5. Jul 2006
Ort: Magdeburg
8.276 Beiträge
Delphi 10.4 Sydney
|
Re: Tabellenname als Parameter für Stored Procedure
2. Jun 2010, 15:28
Hallo,
Ein Bsp aus meinem Link
SQL-Code:
DELIMITER $$
DROP PROCEDURE IF EXISTS `eduplan`.`GetStakeholder`$$
CREATE PROCEDURE `eduplan`.`GetStakeholder`(usingtable varchar(255), usingid varchar(255), identifier varchar(255))
BEGIN
SET @qry = CONCAT('SELECT * FROM ', usingtable, ' WHERE ', usingid,' = ?');
PREPARE stmt1 FROM @qry;
SET @c = identifier;
EXECUTE stmt1 USING @c;
DEALLOCATE PREPARE stmt1;
END$$
DELIMITER ;
Oder so
SQL-Code:
declare @ mySql varchar(220)
set @ mysql = ' select customerid from customers'
exec (' DECLARE cur CURSOR FOR ' + @ mysql)
Heiko
Heiko
|
|
Zitat
|