From: | Zitan Broth <zitan(at)mediasculpt(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Assigning Values to Arrays |
Date: | 2003-10-07 21:41:32 |
Message-ID: | 01f001c38d1b$c6635d60$3201a8c0@zitan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Greetings All,
Running pg 7.3.4 and was reading: http://archives.postgresql.org/pgsql-interfaces/2003-09/msg00018.php . Basically want to assign values to an array and then a 2d array.
However I can't get this to run in properly I get a syntax error (at or near "[") with function listed below.
Any suggestions are greatly appreciated :-)
Thanks,
Z.
btw, is there an user-contributed notes section of the pg documentation I could post a working example too (yeah php developer in the house :-)).
Test procedure::
create table test_output(
output_num_arr numeric[][],
output_txt_arr TEXT[],
output_str text
);
CREATE OR REPLACE FUNCTION F_TEST(TEXT) RETURNS NUMERIC AS '
DECLARE
HeaderArray text[] = ''{}'';
BEGIN
HeaderArray[1] := \'hi\';
HeaderArray[2] := \'this\';
HeaderArray[3] := \'is\';
HeaderArray[4] := \'not\';
HeaderArray[5] := \'a\';
HeaderArray[6] := \'test\';
insert into test_output(output_txt_arr) values (HeaderArray);
insert into test_output(output_str) values (HeaderArray[1]);
insert into test_output(output_str) values (HeaderArray[2]);
insert into test_output(output_str) values (HeaderArray[3]);
insert into test_output(output_str) values (HeaderArray[4]);
insert into test_output(output_str) values (HeaderArray[5]);
insert into test_output(output_str) values (HeaderArray[6]);
END;
'LANGUAGE 'plpgsql';
select F_TEST('a');
select * from test_output;
drop function F_TEST(TEXT);
drop table test_output;
From | Date | Subject | |
---|---|---|---|
Next Message | nolan | 2003-10-07 23:21:17 | Re: "select count(*) from contacts" is too slow! |
Previous Message | Gaetano Mendola | 2003-10-07 21:33:00 | Re: concenation of strings and null values |