database package - inserting array data into array field
I've just started using the database package coupled with postgresql. I am
able to connect, create tables with array colums (e.g, column_name
float8), perform queries, etc, without issue. However, I can not seem to
successfully insert arrays into array fields, except by literal ARRAY
strings in the INSERT statement.
My attempts to do the same via placeholders (e.g. $1), and via the copy from
with binary from variable have all failed.
Even if I manually insert an array and read it back out via SELECT query, I
am still not able to insert that data back in to the table.
I imagine I am missing something simple and fundamental, but after having
combed through all of the documentation and examples i could find, I am
If someone could provide an example, I would be very grateful.
Re: database package - inserting array data into array field
I finally got it.
I had tried several times to use structures with the fields "data" (cell
array), and "ndims" for my arrays, as indicated in the SQL data types
documentation. I did not, however, realize that I also had to specifically
declare the "param_types" (e.g. "float8") with setdbopts().
I was falsely under the impression that data types such as double were
automatically converted. As it turns out, they are automatically converted
when passed as single scalars, but not when passed in arrays.