Ver Mensaje Individual
  #1 (permalink)  
Antiguo 31/01/2016, 16:49
Avatar de diego9j
diego9j
 
Fecha de Ingreso: septiembre-2011
Mensajes: 33
Antigüedad: 12 años, 7 meses
Puntos: 2
Arrays con octave database

Buenas

Estoy haciendo un programa con octave(similar a matlab) que necesita conectarse a base de datos PostgreSQL. La conexión y todo la he conseguido, incluso almacenar variables simples. El problema lo tengo al intentar almacenar arrays.

Código:
array=[1,2,3];
pq_exec_params(conn,"CREATE TABLE test (nombre float4[]);");
pq_exec_params(conn,"INSERT INTO test VALUES ($1);",{array});
y me devuelve

Código:
fatal error: ERROR: column "nombre" is of type real[] but expression is of type point

HINT: you will need to rewrite or cast the expression

Evidentemente tengo que hacer un parse a mi array pero no se a que. En esta página viene la correspondencia entre los tipos de PostgreSQL con los de octave pero no entiendo nada de lo que dice para arrays.

http://octave.sourceforge.net/databa...ec_params.html

Cita:
Structure with fields data (holding a cell-array with entries of a type corresponding to the Postgresql element type), ndims (holding the number of dimensions of the corresponding Postgresql array, since this can not be deduced from the dimensions of the Octave cell-array in all cases), and optionally (but always present in returned values) lbounds (a row vector of enumeration bases for all dimensions, default is ones (1, ndims), see Postgresql documentation). Array elements may not correspond to arrays in Postgresql (use additional dimensions for this), but may correspond to composite types, which is allowed to lead to arbitrarily deep nesting.

Sinceramente no entiendo nada de ese parrafo. He intentado pasar como argumento variables de tipo cell pero me dice que no reconoce el tipo de variable.

Si alguien me puede ayudar estaré muy agradecido.