Lakshmana Babu S
Lakshmana Babu S

Reputation: 51

Stored procedure throwing error when value is more than certain character count

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 .

Upvotes: 2

Views: 53

Answers (1)

Lakshmana Babu S
Lakshmana Babu S

Reputation: 51

set session group_concat_max_len = 5000;

Upvotes: 1

Related Questions