编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛  
全能 ASP / PHP / ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
发新话题
打印

mysql怎么写一个带输入输出参数的用户自定义函数

mysql怎么写一个带输入输出参数的用户自定义函数

功能就如:
use studentRegisterManager

go
create function differentTime(section_id varchar(10),currenttime datetime)
returns int
begin
declare different int,
declare ttime datetime,

set ttime = (select section_set_time from [section] where section_id=@section_id)

set different=DATEDIFF( d, @time,@currenttime)

return different
end
一样

TOP

这个函数初步看了一下...
是错误的.

我的msn: myfend@hotmail.com

TOP

回复:(purana)这个函数初步看了一下...是错误的.

我知道。我改的时候,不小心就把改动的传上来了,
use studentRegisterManager
go
create function differentTime(@section_id varchar(10),@currenttime datetime)
returns int
as
begin
declare @different int
declare @time datetime

set @time = (select section_set_time from [section] where section_id=@section_id)

set @different=DATEDIFF( d, @time,@currenttime)

return @different
end
这个对的了,能给我一个MYSQL的版本吗??

[glow=200,blue,1]世界上妞是无限的,而我们的精力是有限的,用有限去搞无限,死定了。要用有限的精力去泡一个有钱妞,要发达,吃软饭![/glow]

TOP

delimiter $$
drop function if exists differentTime$$
create function differentTime(in_section_id varchar(10),currenttime datetime)
returns int
begin
declare different int;
declare ttime datetime;
set ttime = (select section_set_time from section where section_id=in_section_id);

set different=to_days(currenttime)-to_days(ttime);

return different;
end $$
delimiter ;

我的msn: myfend@hotmail.com

TOP

谢谢!非常感谢!
[glow=200,blue,1]世界上妞是无限的,而我们的精力是有限的,用有限去搞无限,死定了。要用有限的精力去泡一个有钱妞,要发达,吃软饭![/glow]

TOP

发新话题