RETURNS "pg_catalog". "refcursor" AS $BODY $
Declare user_list refcursor;
The BEGIN
The open user_list for
- or relationship with single
Select * from sf_choose_subject where province=p_province and second_subject_attr='or' or second_subject_attr='single' and
(choose_subject1=p_choose_subject1 or choose_subject1=p_choose_subject2 or choose_subject1=p_choose_subject3) and
(choose_subject2=p_choose_subject1 or choose_subject2=p_choose_subject2 or choose_subject2=p_choose_subject3) and
(choose_subject3=p_choose_subject1 or choose_subject3=p_choose_subject2 or choose_subject3=p_choose_subject3)
The union
- no relationshipSelect * from sf_choose_subject where province=p_province and second_subject_attr='no'
The union
- 3 and relationship
Select * from sf_choose_subject where province=p_province and second_subject_attr='and' and
((choose_subject1=p_choose_subject1 and choose_subject2=p_choose_subject3 and choose_subject3=p_choose_subject2) or
(choose_subject1=p_choose_subject3 and choose_subject2=p_choose_subject1 and choose_subject3=p_choose_subject2) or
(choose_subject1=p_choose_subject2 and choose_subject2=p_choose_subject3 and choose_subject3=p_choose_subject1) or
(choose_subject1=p_choose_subject3 and choose_subject2=p_choose_subject2 and choose_subject3=p_choose_subject1) or
(choose_subject1=p_choose_subject1 and choose_subject2=p_choose_subject2 and choose_subject3=p_choose_subject3) or
(choose_subject1=p_choose_subject2 and choose_subject2=p_choose_subject1 and choose_subject3=p_choose_subject3))
The union
- 2 and the relationship between
Select * from sf_choose_subject where province=p_province and second_subject_attr='and' and
((choose_subject1=p_choose_subject1 and choose_subject2=p_choose_subject3) or
(choose_subject1=p_choose_subject3 and choose_subject2=p_choose_subject1) or
(choose_subject1=p_choose_subject2 and choose_subject2=p_choose_subject3) or
(choose_subject1=p_choose_subject3 and choose_subject2=p_choose_subject2) or
(choose_subject1=p_choose_subject1 and choose_subject2=p_choose_subject2) or
(choose_subject1=p_choose_subject2 and choose_subject2=p_choose_subject1)) and (choose_subject3 is null or choose_subject3=");
The close user_list;
RETURN user_list;
END $BODY $
LANGUAGE PLPGSQL VOLATILE
COST 100
CodePudding user response:
Will not write,,, can't find errors,CodePudding user response:
Can't close in the function body user_list, close again after the function call