GBase8s数据库自定义函数SPL例程撰写

本文介绍了一个自定义的date_add()函数,用于日期的加减运算,包括年、月、日、季度和星期;以及datetime_add()函数,用于时间的加减运算,包括小时、分钟和秒。提供了使用示例。

示例:

date_add()函数:

DELIMITER |
create dba function gbasedbt.date_add(date_exp date, interval_int int, int_type varchar(25)) 
 returns date;
 define r_date date;
 if upper(int_type)='YEAR' then
   select  (date_exp+interval_int units YEAR)  into r_date from systables where tabid=1;
 elif upper(int_type)='QUARTER' then
   select  (date_exp+interval_int*3 units MONTH)  into r_date from systables where tabid=1;
 elif upper(int_type)='MONTH' then
   select  (date_exp+interval_int units MONTH)  into r_date from systables where tabid=1;
 elif upper(int_type)='WEEK' then
   select  (date_exp+interval_int*7 units DAY)  into r_date from systables where tabid=1;
 elif upper(int_type)='DAY' then
   select  (date_exp+interval_int units DAY)  into r_date from systables where tabid=1;
 else
   select int_type into r_date from systables where tabid=1;
 end if;
 return r_date;
 end function;                                                                                     
评论 4
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值