CREATE OR REPLACE PROCEDURE sp_Vote (
VoteID number,
VoteItemIDStr varchar2,
VoterID number,
VotedBefore out number
)AS
VoteItemID varchar2(3);
temp_VoteItemIDStr varchar2(200);
separatorIndex number;
v_count number;begin
VotedBefore:=0;
temp_VoteItemIDStr := VoteItemIDStr;
--此用户已经投过票
--if exists( select d.*, i.F_VOTEID from T_VOTEDETAILS d inner join T_VOTEITEMS i on d.F_VOTEITEMID = i.F_VOTEITEMID where i.F_VOTEID = VoteID and d.F_VOTERID = VoterID )
select count(*) into v_count from T_VOTEDETAILS d inner join T_VOTEITEMS i on d.F_VOTEITEMID = i.F_VOTEITEMID where i.F_VOTEID = VoteID and d.F_VOTERID = VoterID ;
if(v_count > 0) then
VotedBefore := 1;
return;
end if;
--循环插入每个选中项
while(temp_VoteItemIDStr <> '')
loop
separatorIndex := instrb(temp_VoteItemIDStr, ',');
--该选项的ID --多个选项
if(separatorIndex > 0) then
VoteItemID := substrb(temp_VoteItemIDStr,1, separatorIndex-1);
temp_VoteItemIDStr := substrb(temp_VoteItemIDStr, separatorIndex + 1, lengthb(temp_VoteItemIDStr)-separatorIndex);
--只有一个选项
else
VoteItemID := temp_VoteItemIDStr;
temp_VoteItemIDStr := '';
end if; if(VoteItemID<>'') then
insert into T_VOTEDETAILS(F_VOTERID, F_VOTEITEMID) values(VoterID, VoteItemID);
end if;
end loop;
end sp_Vote;==================================================
Compilation errors for PROCEDURE LKNET32.SP_VOTEError: Hint: Comparison with NULL in 'sp_Vote'
Line: 27
Text: while(temp_VoteItemIDStr <> '')Error: Hint: Comparison with NULL in 'sp_Vote'
Line: 42
Text: if(VoteItemID<>'') then
VoteID number,
VoteItemIDStr varchar2,
VoterID number,
VotedBefore out number
)AS
VoteItemID varchar2(3);
temp_VoteItemIDStr varchar2(200);
separatorIndex number;
v_count number;begin
VotedBefore:=0;
temp_VoteItemIDStr := VoteItemIDStr;
--此用户已经投过票
--if exists( select d.*, i.F_VOTEID from T_VOTEDETAILS d inner join T_VOTEITEMS i on d.F_VOTEITEMID = i.F_VOTEITEMID where i.F_VOTEID = VoteID and d.F_VOTERID = VoterID )
select count(*) into v_count from T_VOTEDETAILS d inner join T_VOTEITEMS i on d.F_VOTEITEMID = i.F_VOTEITEMID where i.F_VOTEID = VoteID and d.F_VOTERID = VoterID ;
if(v_count > 0) then
VotedBefore := 1;
return;
end if;
--循环插入每个选中项
while(temp_VoteItemIDStr <> '')
loop
separatorIndex := instrb(temp_VoteItemIDStr, ',');
--该选项的ID --多个选项
if(separatorIndex > 0) then
VoteItemID := substrb(temp_VoteItemIDStr,1, separatorIndex-1);
temp_VoteItemIDStr := substrb(temp_VoteItemIDStr, separatorIndex + 1, lengthb(temp_VoteItemIDStr)-separatorIndex);
--只有一个选项
else
VoteItemID := temp_VoteItemIDStr;
temp_VoteItemIDStr := '';
end if; if(VoteItemID<>'') then
insert into T_VOTEDETAILS(F_VOTERID, F_VOTEITEMID) values(VoterID, VoteItemID);
end if;
end loop;
end sp_Vote;==================================================
Compilation errors for PROCEDURE LKNET32.SP_VOTEError: Hint: Comparison with NULL in 'sp_Vote'
Line: 27
Text: while(temp_VoteItemIDStr <> '')Error: Hint: Comparison with NULL in 'sp_Vote'
Line: 42
Text: if(VoteItemID<>'') then
CREATE OR REPLACE PROCEDURE sp_Vote (
VoteID number,
VoteItemIDStr varchar2,
VoterID number,
VotedBefore out number
)AS
VoteItemID varchar2(3);
temp_VoteItemIDStr varchar2(200);
separatorIndex number;
v_count number;begin
VotedBefore:=0;
temp_VoteItemIDStr := VoteItemIDStr;
--此用户已经投过票
select count(*) into v_count from T_VOTEDETAILS d inner join T_VOTEITEMS i on d.F_VOTEITEMID = i.F_VOTEITEMID where i.F_VOTEID = VoteID and d.F_VOTERID = VoterID ;
if(v_count > 0) then
VotedBefore := 1;
return;
end if;
--循环插入每个选中项
while(temp_VoteItemIDStr <> '')
loop
separatorIndex := instrb(temp_VoteItemIDStr, ',');
--该选项的ID --多个选项
if(separatorIndex > 0) then
VoteItemID := substrb(temp_VoteItemIDStr,1, separatorIndex-1);
temp_VoteItemIDStr := substrb(temp_VoteItemIDStr, separatorIndex + 1, lengthb(temp_VoteItemIDStr)-separatorIndex);
--只有一个选项
else
VoteItemID := temp_VoteItemIDStr;
temp_VoteItemIDStr := '';
end if; if(VoteItemID<>'') then
insert into T_VOTEDETAILS(F_VOTERID, F_VOTEITEMID) values(VoterID, VoteItemID);
end if;
end loop;
end sp_Vote;