SQL code// 想将下面的转为mysql的,求各位帮帮忙,非常感谢!!在线等,我先去恶补下SQL的函数知识,希望等会能有好心人的回答~~
create or replace function getFiberStatus(in_stationid in varchar2, -- 局站标识
in_markid in varchar2, -- 地标标识
in_segmentid in varchar2, -- 光缆段标识
in_fiberid in varchar2) -- 光纤标识
return integer is
v_count integer := 0;
begin
-- 是否被光纤连接占用
select count(*)
into v_count
from fams_fiberconnection
where decode(stationid, in_stationid, 1, 0) = 1
and decode(markid, in_markid, 1, 0) = 1
and ((asegmentid = in_segmentid and afiberid = in_fiberid) or
(zsegmentid = in_segmentid and zfiberid = in_fiberid));
if v_count > 0 then
return 1;
end if;
-- 是否被分光器占用
select count(*)
into v_count
from fams_splitter
where decode(stationid, in_stationid, 1, 0) = 1
and decode(markid, in_markid, 1, 0) = 1
and segmentid = in_segmentid
and fiberid = in_fiberid;
if v_count > 0 then
return 1;
end if;
-- 是否被分光器连接占用
select count(*)
into v_count
from fams_splitter s, fams_splitterconnection sc
where decode(stationid, in_stationid, 1, 0) = 1
and decode(markid, in_markid, 1, 0) = 1
and s.splitterid = sc.splitterid
and sc.segmentid = in_segmentid
and sc.fiberid = in_fiberid;
if v_count > 0 then
return 1;
end if;
-- 是否被光开关连接占用
select count(*)
into v_count
from fams_rtu r, fams_oswconnection oc
where r.stationid = in_stationid
and r.rtuid = oc.rtuid
and oc.segmentid = in_segmentid
and oc.fiberid = in_fiberid;
if v_count > 0 then
return 1;
end if;
-- 其它需要补充,否则未被占用状态
return 0;
end getFiberStatus;