return array in postgres

15 pts.
Tags:
Database
Postgres
when i execute following function in postgres, it gives me null. select get_strelements('1000-2000-3000-4000',array[''::text]); here, "get_strelements" function is as follows: CREATE OR REPLACE FUNCTION "public"."get_strelements" (str varchar, dummyarr "pg_catalog"."anyarray") RETURNS "pg_catalog"."anyarray" AS $body$ declare ------------------------------------------------------------------------------------------------------------------ len integer; len1 integer; len2 integer; v_str varchar; repl_char varchar := '-'; i integer; num numeric; noarr varchar[10]; splstr varchar; ------------------------------------------------------------------------------------------------------------------ begin ------------------------------------------------------------------------------------------------------------------ v_str := str; len1 := length(v_str); select length(replace(v_str,repl_char,'')) into len2; len := (len1 - len2) + 1; for i in 1..len loop select split_part(v_str,repl_char,i) into splstr; num := splstr::numeric; noarr[i] := num; end loop; raise notice 'noarr = %',noarr; return noarr; ------------------------------------------------------------------------------------------------------------------ exception when others then raise notice 'Exception while updating quotation master data..............'; return noarr; ------------------------------------------------------------------------------------------------------------------ end; $body$ LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: