From: | "Rod Taylor" <rbt(at)zort(dot)ca> |
---|---|
To: | "Hackers List" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | plpgsql nitpicking -- possible TODO item? |
Date: | 2002-03-04 02:49:05 |
Message-ID: | 030e01c1c327$6d115d80$8001a8c0@jester |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2002-03-04 02:49:07 | Re: elog() patch |
Previous Message | Tom Lane | 2002-03-04 02:23:40 | Re: elog() patch |