0
DROP FUNCTION IF EXISTS `opalv3`.`LineRecordTemp` $$
CREATE FUNCTION `opalv3`.`LineRecordTemp` ( TABLE_ID INT,   COLUMN_DATA TEXT) RETURNS INT
BEGIN
     SET @sql= NULL;

     SELECT CONCAT('UPDATE TABLE SET c_name = \'',ATTR_DATA,'\' WHERE t_id =',TABLE_ID) INTO  @sql;

   PREPARE stmt FROM @sql ;
   EXECUTE stmt;
   DEALLOCATE PREPARE stmt;

   RETURN 0;

END $$

I am getting the error "Dynamic SQL is not allowed in stored function or trigger" Is there any way through which I can run the Dynamic query from the MYSQL function

Jaspreet Singh
  • 105
  • 1
  • 3
  • 10
  • possible duplicate of [What is the workaround for using dynamic SQL in a stored Procedure](http://stackoverflow.com/questions/12568577/what-is-the-workaround-for-using-dynamic-sql-in-a-stored-procedure) – Rikesh Apr 07 '14 at 12:56
  • Instead of trying to do something that MySQL tells you is not allowed (and it's not allowed for a reason), why don't you try to change your logic instead of the RDBMS logic? This looks like a trigger job to me. – N.B. Apr 07 '14 at 12:58
  • Use procedure instead of function. – dkasipovic Apr 07 '14 at 12:58

0 Answers0