幼
幼儿
Unregistered / Unconfirmed
GUEST, unregistred user!
在数据库里面写的函数报错,找不出什么原因,谢谢大虾给看看啊,小女子哭求:这个是创建的数据库表:CREATE TABLE [SchemeDataTab] ( [SchDataID] [int] NOT NULL , [CaseID] [int] NULL , [SchID] [int] NULL , [FstGlucose] [char] (10) COLLATE Chinese_PRC_CI_AS NULL , [OldGlucose] [char] (10) COLLATE Chinese_PRC_CI_AS NULL , [CurGlucose] [char] (10) COLLATE Chinese_PRC_CI_AS NULL , [CurInsulin] [char] (10) COLLATE Chinese_PRC_CI_AS NULL , [Feeding] [char] (10) COLLATE Chinese_PRC_CI_AS NULL , [OldGlucoseTime] [datetime] NULL , [NewInsulinIn] [char] (10) COLLATE Chinese_PRC_CI_AS NULL , [MindSufferer] [int] NULL , [SugarDiabetes] [int] NULL , [Incretion] [int] NULL , [InsulinDose] [char] (10) COLLATE Chinese_PRC_CI_AS NULL , [GlucoseDose] [char] (10) COLLATE Chinese_PRC_CI_AS NULL , [NewInsulinOut] [char] (10) COLLATE Chinese_PRC_CI_AS NULL , [NewGlucoseTime] [datetime] NULL , [CallDoctor] [int] NULL CONSTRAINT [DF_SchemeDataTab_CallDoctor] DEFAULT (0), [InsulinDoseFact] [char] (10) COLLATE Chinese_PRC_CI_AS NULL , [GlucoseDoseFact] [char] (10) COLLATE Chinese_PRC_CI_AS NULL , [NewInsulinOutFact] [char] (10) COLLATE Chinese_PRC_CI_AS NULL , [NewGlucoseTimeFact] [datetime] NULL , [CallDoctorFact] [int] NULL , [crtDate] [datetime] NULL , CONSTRAINT [PK_SchemeDataTab] PRIMARY KEY CLUSTERED ( [SchDataID] ) ON [PRIMARY] ) ON [PRIMARY]GO这个是在这个表的基础上的函数:CREATE FUNCTION xh_LowTimeYSFW (@LowGlucose char(10),@curtime datetime,@Caseid int,@SchID int)RETURNS char(20)AS BEGIN DECLARE @d_retun char(20) SET @curtime = CAST(@curtime as datetime) begin set select @d_retun = (DATEDIFF(hour,OldGlucoseTime,crtDate)*(@LowGlucose-GlucoseDoseFact)+ DATEDIFF(hour,crtDate,NewGlucoseTimeFact)*(CurGlucose-@LowGlucose))/(CurGlucose-GlucoseDoseFact) from (select top 1 OldGlucoseTime,CurGlucose,GlucoseDoseFact,NewGlucoseTimeFact,OldGlucoseTime,crtDate from SchemeDataTab where CurGlucose>@LowGlucose and GlucoseDoseFact<@LowGlucose and Caseid=@Caseid and SchID=@SchID and DATEDIFF(hour,OldGlucoseTime,NewGlucoseTimeFact)<24) end return @d_retunEND