IQ里写一个function

ALTER FUNCTION "DBA"."itv_isvalid_vodchooser"( in v_id bigint, v_request_time timestamp, v_ip_addr varchar(20)/* [IN] 参数名称 参数类型 [DEFAULT 缺省值], ... */ )
RETURNS INTEGER
DETERMINISTIC
BEGIN
 DECLARE "result" INTEGER;
 /* 在此处键入函数语句 */
   
 select  top 1 url,request_time,id into #itv_access_log0501
  from demo.itv_access_log0501
  where ip_addr= v_ip_addr and id!=v_id
  and request_time>= v_request_time and (url like '%/vod_chooser.php' or url like '%/vod_player.php')
  order by request_time,id;
 
 select count(*) into result from #itv_access_log0501 where url like '%/vod_player.php';
 RETURN "result";
END

原文地址:https://www.cnblogs.com/tomcatandjerry/p/2536775.html