Search Postgresql Archives

Re: Populating a sparse array piecemeal in plpgsql

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Eliot, Christopher" <christopher.eliot@xxxxxxxxxxxxx> writes:
> Thank you for your reply, but I don't really understand how to use this
> information.
> My problem is that I can put one value into this array, and that's it.
> Any subsequent attempts to put another value elsewhere in the array are
> rebuffed, saying that the subscripts are out of range.  I don't
> understand what I would do "by hand" that would help this.

Well, the point is that you need to initialize the array as a whole to
have the dimensions you want; PG won't guess about this.  For instance
you could do something like

	declare a integer[];
	begin
	  a := '{{null,null,null},{null,null,null},{null,null,null}}';

which sets up a null-filled 3x3 array that you can then manipulate
individual elements of.  For the sorts of dimensions you were showing,
writing out the initial value as a constant would be pretty dang
tedious, but you could build up the textual value in a loop and then
assign it.

To be honest, I wonder whether you are working in the wrong language.
PG (and therefore plpgsql) isn't very good with multidimensional arrays,
and especially not large ones.  Perhaps you ought to be pushing your
data around in pl/R or some such.

			regards, tom lane


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux