2012-06-13 36 views
1

我改变了表中的列名,我需要改变它的功能。所以我改变了功能。但它仍然运行旧功能!它给了我:mysql:改变了功能,但保持旧功能

"Error Code: 1054 Unknown column 'avDoctorID' in 'where clause'" 

我敢肯定我改变了功能,因为如果我看到功能本身,它是新的!怎么会这样?

我在mysql工作台上做了这个,如果我在任何其他程序中看到函数,它会显示新函数,但是当我尝试运行它时会出现相同的错误。

这是查询运行它

select FNC_CreateAppointment(8,1,"2012-08-06","15:30:00","something"); 

而这一点,本身的功能:

DELIMITER $$ 

CREATE DEFINER=`root`@`%` FUNCTION `fnc_CreateAppointment`(clid int,calid int,appdate date,apptime time,commentaar varchar(3000)) RETURNS tinyint(1) 
BEGIN 
declare succeeded boolean; 
declare id2 int; 
declare id int; 
declare dagweek int; 
Declare afwezig int; 
set afwezig = 0; 
set dagweek = Dayofweek(appdate); 
set id =0; 
set id2 = 0; 
set succeeded = false; 
select availableID into id from tbl_available where AVdays = dagweek and AVHours = apptime and avCalendarID = calid 


; 
if id > 0 
then 

select appointmentID into id2 from tbl_appointment where appointmentDate = appdate and appointmentTime = apptime and CalendarID = calid; 

if id2 = 0 
then 

select AbsentID into afwezig from tbl_absent where abHoliday = appdate and abAbsent = apptime and abCalendarID = calid; 
if afwezig = 0 then 

insert into tbl_appointment(clientId,Calendarid,appointmentDate,appointmenttime,remark) 
Values 
(clid,calid,appdate,apptime,commentaar); 

set succeeded = true; 
end if; 

end if; 


end if; 

return succeeded; 

END 

的错误返回是:

call db_demo.FNC_CreateAppointment(8,1,"2012-08-06","15:30:00","something") Error Code: 1054 Unknown column 'avDoctorID' in 'where clause' 

'avDoctorID' 是老列

+1

需要一些更多的信息。你能显示查询吗? –

+0

我编辑我的第一篇文章的查询 – Nick

+0

在函数本身你有它定义为fnc_CreateAppointment(),但然后你调用fnc_CreateAppointment2()。它应该是哪一个? –

回答

1

您可能需要先删除该函数,然后再次运行CREATE语句。

DROP FUNCTION IF EXISTS `<function_name>` 
+0

这不起作用,但是我放弃了整个数据库并将其导回,这很有效! – Nick