我尝试使用此代码创建新的存储过程,该错误总是出现在我身上:
#count and sort the votes instaed of using collections
vote_count_dict = {}
for vote in votes:
if vote in vote_count_dict:
vote_count_dict[vote] += 1
else:
vote_count_dict[vote] = 1
vote_count = sorted(vote_count_dict.items(), key=lambda items: items[1], reverse=True)
MySQL说:文档
#1064-您的SQL语法有错误;检查手册 对应于您的MariaDB服务器版本,以使用正确的语法 在第4行的“”附近
我使用以下代码创建存储过程:
CREATE PROCEDURE `retriveData`() NOT DETERMINISTIC CONTAINS SQL SQL
SECURITY DEFINER BEGIN
SET @sql = NULL
答案 0 :(得分:0)
您忘记了定界符:
DELIMITER $$
CREATE PROCEDURE `retriveData`() NOT DETERMINISTIC CONTAINS SQL SQL SECURITY DEFINER
BEGIN
SET @sql = NULL;
SELECT
GROUP_CONCAT(DISTINCT
CONCAT(
'MAX(IF(pa.item = ''',
item,
''', pa.comValue, 0)) AS ',
item
)
) INTO @sql
FROM salaryStructureView;
SET @sql = CONCAT('SELECT p.id
, p.fullname
, p.salary, ', @sql, '
FROM employee p
LEFT JOIN salaryStructureView AS pa
ON p.id = pa.id
GROUP BY p.id');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END
$$