This code has passed several online checks. I do not know what is wrong. After the CONCAT function, he says that I need a semicolon, although there is already one there. And on end it says that it is an outsider when it expects the end of the instruction. What gives?
create procedure AddColumnUnlessExists( IN dbName tinytext, IN tableName tinytext, IN fieldName tinytext, IN fieldDef text) begin IF NOT EXISTS ( SELECT * FROM information_schema.COLUMNS WHERE column_name=fieldName and table_name=tableName and table_schema=dbName ) THEN set @ddl = CONCAT('ALTER TABLE ', dbName, '.', tableName, ' ADD COLUMN ', fieldName, ' ', fieldDef); prepare stmt from @ddl; execute stmt; END IF; end;
syntax mysql semicolon
Indigenuity
source share