在postgresql函数中返回null时返回一个非null值

时间:2018-10-11 08:54:48

标签: postgresql

CREATE OR REPLACE FUNCTION wlmember.fn_string_to_row(p_str character varying)
 RETURNS SETOF text
 LANGUAGE plpgsql
 SECURITY DEFINER
AS $function$
declare
    v_str TEXT[];
  BEGIN
    /* Check to see the number of occurences of the comma */
         v_str := string_to_array($1, ',');
    FOR i IN coalesce(array_lower(v_str, 1),1) .. coalesce(array_upper(v_str, 1),1) LOOP
      RETURN NEXT v_str[i];
    END LOOP;
        RETURN;
   END;
$function$;

0 个答案:

没有答案