Foros del Web » Programación para mayores de 30 ;) » Programación General »

[SOLUCIONADO] Arrays con octave database

Estas en el tema de Arrays con octave database en el foro de Programación General en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 31/01/2016, 16:49
Avatar de 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.
  #2 (permalink)  
Antiguo 01/02/2016, 02:53
Avatar de diego9j  
Fecha de Ingreso: septiembre-2011
Mensajes: 33
Antigüedad: 12 años, 7 meses
Puntos: 2
Respuesta: Arrays con octave database

Ya fui capaz de solucionarlo

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

En la DEMOSTRACION 2 Utilizan un tipo compuesto. Lo importante es utilizar la funcion struct

Saludos y suerte

Etiquetas: cast, cell, matlab, parse, postgres, sql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:48.