From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | Edwin Quijada <listas_quijada(at)hotmail(dot)com> |
Cc: | Ayuda <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | Re: Errores con PK |
Date: | 2011-08-09 02:25:08 |
Message-ID: | 1312856587-sup-9599@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Excerpts from Edwin Quijada's message of lun ago 08 19:29:00 -0400 2011:
>
> Hola!Estoy teniendo errores extranos con una clave primaria en PostgresTengo esta tabla
> CREATE TABLE "public"."t_factura_alquiler" ( "f_tipo" VARCHAR(10) NOT NULL, "f_numero" INTEGER DEFAULT 0 NOT NULL, "f_fecha" TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT now() NOT NULL, "f_id_cliente" INTEGER DEFAULT 0, "f_ncf" VARCHAR(20), "f_monto" NUMERIC(15,2) DEFAULT 0 NOT NULL, "f_tax" NUMERIC(15,2) DEFAULT 0 NOT NULL, "f_balance" NUMERIC(15,2) DEFAULT 0 NOT NULL, "f_hechopor" INTEGER DEFAULT 0 NOT NULL, "f_pagada" BOOLEAN DEFAULT false NOT NULL, "f_descu" NUMERIC(15,2), CONSTRAINT "t_factura_alquiler_pkey" PRIMARY KEY("f_tipo", "f_numero"), CONSTRAINT "t_factura_alquiler_fk" FOREIGN KEY ("f_id_cliente") REFERENCES "public"."t_clientes"("f_id") ON DELETE NO ACTION ON UPDATE CASCADE NOT DEFERRABLE) WITH OIDS;
>
> --- Insertinsert into public.t_factura_alquiler(f_tipo,f_numero,f_id_cliente,f_monto) VALUES('FDD',1,1,300);
> -- ErrorERROR: duplicate key value violates unique constraint "t_factura_alquiler_pkey"ERROR: duplicate key value violates unique constraint "t_factura_alquiler_pkey"
>
> -- version------------------------------------------------------------------------------------- PostgreSQL 8.3.7 on i686-pc-linux-gnu, compiled by GCC gcc (Debian 4.3.2-1.1) 4.3.2(1 row)
> --db_alquipller=# select * from public.t_factura_alquiler where f_tipo = 'FDD' and f_numero = 1; f_tipo | f_numero | f_fecha | f_id_cliente | f_ncf | f_monto | f_tax | f_balance | f_hechopor | f_pagada | f_descu--------+----------+---------+--------------+-------+---------+-------+-----------+------------+----------+---------(0 rows)
>
> No se como me dice que esta duplicada la clave si no hay nada en esta tabla.
Es bien raro. Deberías actualizar a 8.3.15 y si quieres simplemente
arreglar el problema hacerle reindex a esa tabla (o truncate).
Si me pasas los archivos de la tabla y el índice a lo mejor puedo
mirarlos para ver cuál es el problema.
--
Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
From | Date | Subject | |
---|---|---|---|
Next Message | Carlos Joaniquet Tamburini | 2011-08-09 08:39:38 | Debian 6 + Postgresql 9 |
Previous Message | Alejandro Soto De las Cuevas | 2011-08-08 23:40:51 | Subir un excel que esta en FTP a una tabla de motor Postgresql |