我收到以下错误,相同的代码不会在我的本地系统中抛出任何错误。
MySQL说:#1064 - 您的SQL语法出错;检查与MySQL服务器版本对应的手册,以获得正确的语法 靠近' GROUP_CONCAT(CASE WHEN atv.alid = 1906962 and atv.atrtid = 1 那么concat(替换'在第1行
下面我发布了我的代码
BEGIN
SET
@@group_concat_max_len = 1024 * 13;
SET
@sql3 = NULL;
SELECT
GROUP_CONCAT(
CONCAT(
'replace(format(SUM(CASE WHEN atv.alid = ',
b.alid,
' and atv.atrtid = 1 THEN concat((atv.amount) , "") when atv.alid =',
b.alid,
' and atv.atrtid = 2 then concat((atv.amount) , "") END),2), ", " , "") as ',
REPLACE
(
CONCAT('`',
TRIM(acl.name),
'`'),
'.',
't'
),
' , replace(format( SUM(case when atv.alid = ',
b.alid,
' and atv.atrtid = 2 then concat((atv.amount/',
b.value,
'*100),"") WHEN atv.alid = ',
b.alid,
' and atv.atrtid = 1 then concat((atv.amount/',
b.value,
'*100) , "") end),2), ", ","") as ',
REPLACE
(
CONCAT('`',
TRIM(acl.name),
'-value`'),
'.',
't'
)
)
)
INTO
@sql1
FROM
business_tax_profile b
LEFT JOIN
account_ledger acl ON(
acl.alid = b.alid AND acl.company_id = 19
)
WHERE
b.butaptid = 2 AND b.butapsid = 1 AND b.company_id = 19;
SELECT
GROUP_CONCAT(
CONCAT(
'replace(format(SUM(CASE WHEN atv.alid = ',
b.alid,
' and atv.atrtid = 1 THEN concat((atv.amount) , "") when atv.alid =',
b.alid,
' and atv.atrtid = 2 then concat((atv.amount) , "") END) , 2) , ", " , "") as ',
REPLACE
(
CONCAT('`',
TRIM(acl.name),
'`'),
'.',
't'
),
' , replace(format(SUM(case when atv.alid = ',
b.alid,
' and atv.atrtid = 2 then concat((atv.amount/',
b.value,
'*100),"") WHEN atv.alid = ',
b.alid,
' and atv.atrtid = 1 then concat((atv.amount/',
b.value,
'*100) , "") end),2) , ", " , "") as ',
REPLACE
(
CONCAT('`',
TRIM(acl.name),
'-value`'),
'.',
't'
)
)
)
INTO
@sql4
FROM
business_tax_sub_profile b
LEFT JOIN
account_ledger acl ON(
acl.alid = b.alid AND acl.company_id = 19
)
WHERE
b.butasuptid = 2 AND b.company_id = 19 AND b.butasupsid = 1;
SELECT
GROUP_CONCAT(
CONCAT(
'GROUP_CONCAT(CASE WHEN atv.alid = ',
c.alid,
' and atv.atrtid = 1 THEN concat(replace(format(atv.amount,2),", ","") , "") when atv.alid=',
c.alid,
' AND atv.atrtid = 2 then concat(replace(format(atv.amount , 2),", ","") , "") END) as `',
TRIM(ao.name),
'`'
)
)
INTO
@sql2
FROM
extra_charges c
LEFT JOIN
account_ledger ao ON(
ao.alid = c.alid AND ao.company_id = 19
)
WHERE
c.ectid = 2 AND c.company_id = 19 AND c.ecsid = 1;
SET
@sql3 = CONCAT(
'CREATE OR REPLACE ALGORITHM = UNDEFINED DEFINER = root@localhost SQL SECURITY DEFINER VIEW `purchase_invoice_tax_report_view_19` AS SELECT i.pinvid as pinvid, ROUND(i.total_tax_amount,2) AS `total_tax_amount1`, i.outlet_chkid,i.receive_date as receive_date, i.total_qty, replace(format(i.payable_amount,2),", ","") as payable_amount, replace(format((i.complete_amount -i.total_tax_amount),2) , ", " , "") as total_amount_before_tax, v.gstin, v.data as vendor_data, group_concat((case when atv.alid = 35 and atv.atrtid = 1 then concat(replace(format(atv.amount,2),", ","") , "") when atv.alid = 35 and atv.atrtid = 2 then concat(replace(format(atv.amount,2),", ",""), "") end) separator " ") as `round`,',
COALESCE(@sql1,
'"0"'),
',',
COALESCE(@sql4,
'"0"'),
',',
COALESCE(@sql2,
'"0"'),
', al.name as vendor_name , i.date, (CASE WHEN i.is_transportation IS NULL and is_expense = 0 THEN "Purchase" WHEN i.is_transportation IS NULL and is_expense > 0 THEN "Expense" WHEN i.is_transportation > 0 and is_expense >0 THEN "Transportation" ELSE "Purchase" END) as purchase_type,i.invoice_number ,(case when a.avtid = 3 then "Purchases" end) as voucher_type , a.avtid, i.pinvsid FROM purchase_invoice i LEFT JOIN account_transaction atv ON(atv.avid = i.avid and atv.company_id = 19) left join account_voucher a on (a.avid = atv.avid and a.company_id=19) LEFT join vendor v on (v.venid = i.venid and v.company_id = 19) LEFT join account_ledger al on(al.alid = v.alid and al.company_id = 19) where a.avsid = 1 and a.avtid = 3 and a.company_id = 19 group by i.pinvid'
);
PREPARE
stmt
FROM
@sql3;
EXECUTE
stmt;
DEALLOCATE
PREPARE
stmt;
END
是否有任何语法错误或其他原因,因为相同的代码在本地系统中正常工作....