Hi Dan, Thanks for the clue!
Putting `Title` = 'var_a' (or combinations of \' or ` or \` or " ) was putting var_a as the text in the table. Resolution is: begin set @Populate = CONCAT('insert into ', tableName,' set OwnerID=0, Type=1, State=0, Title=\'', var_a ,'\';'); PREPARE populate1 from @Populate; EXECUTE populate1; DEALLOCATE PREPARE populate1; end; And that works! Again, many thanks for putting me onto the right track. Regards, Martin On Tue, 27 Jun 2006 15:03:28 -0500 Dan Buettner said: >DB- Martin, do you need to quote it? I think MySQL is telling you it's >DB- trying to set >DB- `Title` = var_a; >DB- which is the same as >DB- `Title` = Individual; >DB- which is the same as setting the Title column equal to the Individual >DB- column. >DB- What you want instead is >DB- `Title` = "individual"; >DB- Dan >DB- On 6/27/06, Martin Lancaster <[EMAIL PROTECTED]> wrote: > > Hi all, > > > > Running MySQL 5.0.22 Community on Win 2003 Server. > > > > Can anyone give me some guidance as to what is wrong with the following SP? > > It continually errors with "1054 Unknown column 'Individual' in 'field > > list'. " > > > > The SP is completing the drop table and the create table, but it is when it > > comes to run the cursor and to pass one value from that into the insert > > that the error is thrown (I think). "Individual" is the expected first > > record from the cursor query. > > > > CREATE PROCEDURE `sp_original`( IN tableName varchar (255)) > > BEGIN > > DECLARE var_a varchar (255); > > DECLARE b int (11); > > DECLARE MemType CURSOR for select bdbFormValuesControlValue from > > bdblookuplistvalues where bdbFormValuesControlNameFlag = 4 order by > > bdbFormValuesDisplayOrder asc; > > DECLARE CONTINUE HANDLER FOR NOT FOUND set b =1; > > > > set @dropTable = CONCAT('DROP TABLE if exists ', tableName, ';'); > > PREPARE dropTable1 from @dropTable; > > EXECUTE dropTable1; > > DEALLOCATE PREPARE dropTable1; > > > > set @createTable = CONCAT('CREATE TABLE ', tableName,' (`ID` int(11) NOT > > NULL auto_increment, > > `OwnerID` int(11) NOT NULL, `Type` int(1) NOT NULL, `State` int(1) NOT > > NULL, `Title` varchar(255) NOT NULL, > > PRIMARY KEY (`ID`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;'); > > > > PREPARE createTable1 from @createTable; > > EXECUTE createTable1; > > DEALLOCATE PREPARE createTable1; > > > > OPEN MemType; > > REPEAT > > FETCH MemType into var_a; > > insert into tableName set > > `OwnerID` = 0, > > `Type` = 1, > > `State` = 0, > > `Title` = var_a; > > > > until b = 1 > > END REPEAT; > > Close MemType; > > > > END; > > > > Many thanks in advance > > > > Martin > > -- > > -------------------------------------------------- > > [EMAIL PROTECTED] > > -------------------------------------------------- > > > > > > > > > > > > > > > > > > > > > > > > -- > > MySQL General Mailing List > > For list archives: http://lists.mysql.com/mysql > > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] > > > > -- -------------------------------------------------- [EMAIL PROTECTED] -------------------------------------------------- -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]