creating triggers with a stored procedure

Danny Lewkin daniel.lewkin at cognosis.be
Fri Aug 1 05:37:30 CDT 2008


Hi List,

we want to do this :

CREATE OR REPLACE PROCEDURE sp_max_CreateTriggers( IN table_name  
STRING )
BEGIN

DECLARE tbl_name, trigger_name1 STRING;
SET trigger_name1 = SELECT CONCAT( '"trigger_', table_name, '_BI"' );


"CREATE OR REPLACE TRIGGER  trigger_name1   BEFORE INSERT ON    
table_name  FOR EACH ROW
BEGIN
IF @user_id IS NOT NULL THEN
  NEW.objptr_created_by = @user_id;
  NEW.objptr_modified_by = @user_id;
END IF
NEW.creation_dt = NOW();
NEW.modification_dt = NOW();
END;"

END;"

But we get error that table "table_name" was not found... So I'm  
guessing the variable name is not replaced with the value of it, and  
of course, if it would work, it would create trigger "trigger_name1"...
So we want a stored procedure that will create a trigger on the table  
we pass in the arguments...
Any ideas on a workaround?
Or is this a bug??

Greetz,

Danny





More information about the Valentina mailing list