Skip to content

Instantly share code, notes, and snippets.

@aimtiaz11
Last active August 29, 2015 14:06
Show Gist options
  • Save aimtiaz11/b50f1a010adb910f9240 to your computer and use it in GitHub Desktop.
Save aimtiaz11/b50f1a010adb910f9240 to your computer and use it in GitHub Desktop.
Item in List Function
CREATE OR REPLACE FUNCTION "ITEM_IN_LIST" (p_num IN NUMBER, p_list in VARCHAR2, p_separator in varchar2 default ':')
RETURN NUMBER
IS
l_vc_arr2 APEX_APPLICATION_GLOBAL.VC_ARR2;
TYPE number_list is TABLE OF NUMBER;
num_list number_list := number_list();
x_ret NUMBER;
BEGIN
/* checks if p_num exists in the colon delimited list p_list */
l_vc_arr2 := APEX_UTIL.STRING_TO_TABLE(p_list, p_separator);
FOR i IN 1..l_vc_arr2.COUNT LOOP
num_list.EXTEND;
num_list(i):= CAST(l_vc_arr2(i) AS NUMBER);
END LOOP;
IF p_num MEMBER OF num_list then
return 1;
else
return 0;
end if;
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment