mysql - Error Code: 1054. Unknown column 'abcdef' in 'field list' in stored procedure -
i have written following stored procedure. working quite fine , giving correct results. after addition of attributes shows error. if change name of last retrieved attribute 4 letters word runs correctly. if run stored procedure shows error: "error code: 1054. unknown column 'fiel' in 'field list'"
if run independent statements shows errors: "0 row(s) affected, 1 warning(s): 1260 row 69 cut group_concat()" "error code: 1054. unknown column 'fiel' in 'field list'"
create definer=`root`@`localhost` procedure `getcases`() begin set @sql = concat('select ', (select group_concat(column_name) information_schema.columns table_schema = 'xyz_data_base' , table_name = 'table1' , column_name not in ('col_one', 'col_last')), ', table2.name xyz_data_base.table1, xyz_data_base.table2 table1.col_last = table2.id'); prepare stmt1 @sql; execute stmt1; end
before run group_concat
must change system parameter group_concat_max_len
prevent results cut.
create definer=`root`@`localhost` procedure `getcases`() begin set @@session.group_concat_max_len = 10000; set @sql = concat('select ', (select group_concat(column_name) information_schema.columns table_schema = 'xyz_data_base' , table_name = 'table1' , column_name not in ('col_one', 'col_last')), ', table2.name xyz_data_base.table1, xyz_data_base.table2 table1.col_last = table2.id'); prepare stmt1 @sql; execute stmt1; end
wiki
Comments
Post a Comment