database package - inserting array data into array field

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

database package - inserting array data into array field

ajdunford
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
still stumped.

If someone could provide an example, I would be very grateful.





--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: database package - inserting array data into array field

ajdunford
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.

Hopefully my fumbling might help someone else.



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html