我已经在mySql中成功创建了一个存储过程,并在尝试运行该存储过程时返回了
错误 静态分析:
在分析过程中发现1个错误。
缺少表达。 (在位置25“开”附近) SQL查询:编辑编辑
SET FOREIGN_KEY_CHECKS = ON;
MySQL说:文档
#2014-命令不同步;您现在不能运行此命令
我不知道该如何解决这个问题,因为搜索没有给我带来任何运气。我以这种方式调用存储过程:
str = "SELECT [RIFQuery].*, " & vbCrLf & _
" ([_Employee].[EmployeeLastName] & ', ' & [_Employee].[EmployeeFirstName]) AS [EmployeeLastFirst], " & vbCrLf & _
" [_Employee].[EmployeeTitle], " & vbCrLf & _
" [_Employee].[Phone] AS [EmployeePhone], " & vbCrLf & _
" [_Employee].[EmailAddress] AS [EmployeeEmailAddress], " & vbCrLf & _
" [_Clients].[Gender] AS [ClientGender], " & vbCrLf & _
" [_Clients].[DOB] AS [ClientDOB], " & vbCrLf & _
" [_Clients].[SSN] AS [ClientSSN] " & vbCrLf & _
"FROM [_Clients] " & vbCrLf & _
" INNER JOIN [RIFQuery] ON [RIFQuery].[LastFirst] = [_Clients].[LASTNAME] & ', ' & [_Clients].[FIRSTNAME] " & vbCrLf & _
" INNER JOIN [_Employee] ON [_Employee].[AutoNumber] = [RIFQuery].[CreatedBy] " & vbCrLf & _
"WHERE [RIFQuery].[Autonumber] = 1;"
代码:
call getReport('2018-09-27','2018-09-27');
我的存储过程需要两个日期参数。有时候,我的存储过程可以正常工作而没有任何错误,并且我丝毫没有涉及其配置。我的查询也可以在同事的PC上运行,我认为问题已经解决了,我不知道如何解决。
答案 0 :(得分:1)
SET
语句语法错误。您使用=
而不是:=
CONCAT
函数将字符串连接为不同的参数。尝试以下操作:
BEGIN
SET @query = CONCAT('select * from history where date(`history`.`execDate`) between ',
startDate,
' and ',
endDate);
PREPARE stmt FROM @query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END