Thread: plpgsql nitpicking -- possible TODO item?

plpgsql nitpicking -- possible TODO item?

From
"Rod Taylor"
Date:
In order to add items to an array:
ie. array[2] := variable;

Use the below works, but is quite slow (due to the execute):

DECLARE data ALIAS FOR $1; arr text[];
 -- Required due to bad arrays query text; rec RECORD;
BEGIN
 -- WHAT WE WANT: -- arr[1] := data;

 -- HERE''S HOW WE DO IT: query := ''SELECT cast(''''{"'' || data || ''"}'''' as _text) as
arr'';
 -- Expecting a single loop only. FOR rec IN EXECUTE query LOOP   arr := rec.arr; END LOOP

END;

--
Rod Taylor

Your eyes are weary from staring at the CRT. You feel sleepy. Notice
how restful it is to watch the cursor blink. Close your eyes. The
opinions stated above are yours. You cannot imagine why you ever felt
otherwise.