2
BEGIN

SET @sql = NULL;
SELECT
GROUP_CONCAT(DISTINCT
CONCAT(
'MAX(IF(questions= ''',
questions,
''', yes_no, NULL)) AS ''',
questions,''''
)
) INTO @sql
FROM tbl_main where task=in_task;
SET @sql = CONCAT('SELECT case_id,audited_by,resolved_by, ', @sql, ' FROM  tbl_main WHERE task IN  (''',in_task,''') and audited_date   between(''',from_date,''') and (''',to_date,''') GROUP BY   case_id,audited_by,resolved_by');

PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;


END

Hi, I'm using the stored procedure and I'm converting row values to column headers dynamically , the stored procedure works fine if the row value is within 50 words or so and it fails when the row value is longer than 50 words . I don't know how to fix it. Can any one help me with this .

4
  • Max column header size is 64 characters see dev.mysql.com/doc/refman/5.7/en/identifiers.html Commented Aug 11, 2017 at 7:29
  • Is there a way to fix it ? P.salmon Commented Aug 11, 2017 at 7:31
  • Looks like an absolute limit but you can try googling mysql max column name length to see if anyone has come up with a workaround you can live with. Commented Aug 11, 2017 at 8:07
  • I fixed it by adding below line within procedure and it works fine now . Commented Aug 11, 2017 at 12:45

1 Answer 1

1

set session group_concat_max_len = 5000;

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.