mysql:改变了函数但保留了旧函数

时间:2012-06-13 03:44:02

标签: mysql function alter

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

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

并且我确定我更改了功能,因为如果我看到功能本身就是新功能!怎么会这样?

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

这是运行它的查询

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 :(得分:1)

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

DROP FUNCTION IF EXISTS `<function_name>`