Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/03/2010, 10:03
edwinsp
 
Fecha de Ingreso: septiembre-2008
Mensajes: 75
Antigüedad: 15 años, 8 meses
Puntos: 1
insertando en campos tipo array

Hola a todos tengo un problema al insertar en una tabla que tiene un campo array de un tipo definido por el usuario, expongo mi script

--Creo mi tipo de dato
create type td_detalle_prestamo as
(
cuenta character varying(15),
importe real,
otracuenta character varying(15),
aplicacion character(1),
cuentaaplica character varying(15)
);

--Creo mi tabla
CREATE TABLE prestamocab
(
codempresa character(3) NOT NULL,
tipo character(1) not null,
codigoreg character varying(50) not null,
codanexo character varying(6) NOT NULL,
fecha date not null,
moneda character(2) DEFAULT '1'::bpchar,
tcambio real not null,
total real not null,
porcinicial real not null,
cuotainicial real not null,
afectaigv character(1) not null,
nrocuotas int not null,
usuario character varying(20) NOT NULL,
fechareg timestamp without time zone DEFAULT now(),
estado character(1) not null,
detalle td_detalle_prestamo[],
CONSTRAINT "PK_prestamocab" PRIMARY KEY (codigoreg),
CONSTRAINT "CH_prestamocab_tipo" CHECK (tipo = 'L'::bpchar OR tipo = 'P'::bpchar OR tipo = 'O'::bpchar)
)
WITH (OIDS=FALSE);

--Insertar registro
insert into prestamocab(codempresa,tipo,codigoreg,codanexo,fec ha,moneda,tcambio,total,porcinicial,cuotainicial,a fectaigv,nrocuotas,usuario,estado,detalle)
values('001', 'P', '04714','000001', '2010-03-01', '1', 1, 50000, 10, 5000, 'S', 6,
'ADMIN', 'A',ARRAY[ROW('10',100,'10','S','10'),ROW('12',200,'12','S', '12')]);

--Error
ERROR: column "detalle" is of type td_detalle_prestamo[] but expression is of type record[]
LINEA 4: 'ADMIN', 'A',ARRAY[ROW('10',0,'10','S','10')]);
^
HINT: You will need to rewrite or cast the expression.

gracias