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]

Reply via email to