Basta traduzir a mensagem que está em inglês:

ERROR:  insert or update on table "image" violates foreign key constraint "image_album_id_fkey"
DETAIL:  Key (album_id)=(1) is not present in table "album".

Ou seja, inclua o registro 1 na tabela Album antes de inserir na tabela Image.

De qualquer forma, creio que não funcionará desse jeito. O tipo de dados "bytea" não vai ler o arquivo "c:\ivo.jpg" automaticamente. Sugiro que você consulte a documentação oficial [1], no que diz respeito a "tipo de dados bytea" e "large objects".

[1] http://www.postgresql.org/docs

--
Regards,

Rodrigo Hjort
http://icewall.org/~hjort


2006/10/17, Alberto Ivo <[EMAIL PROTECTED]>:
Bom dia Rodrigo, desculpa te incomodar, é que eu nao estou conseguindo inserir uma imagem (bytea) na tabela. É um erro besta mas nao consigo solucionar. pode me ajudar?
é o seguinte, as tabelas estão abaixo, o erro está na ultima linha, no INSERT INTO.

CREATE TABLE Album
(
  album_id           SERIAL    NOT NULL    PRIMARY KEY,
  album_name         TEXT    NOT NULL
);

CREATE TABLE Image
(
  image_id          SERIAL    NOT NULL     PRIMARY KEY,
  album_id          INT        NOT NULL,
  image_thumb       bytea,
  image_full        bytea    NOT NULL,
  image_desc           TEXT,
  image_author        TEXT,
  image_date        DATE
);

ALTER TABLE Image
  ADD FOREIGN KEY (album_id) REFERENCES Album (album_id);


INSERT INTO Image (album_id, image_desc, image_full) VALUES (1, 'ivo' , 'c:\ivo.jpg' );

mensagem de erro:

ERROR:  insert or update on table "image" violates foreign key constraint "image_album_id_fkey"
DETAIL:  Key (album_id)=(1) is not present in table "album".


Obrigado!

_______________________________________________
Grupo de Usuários do PostgreSQL no Brasil
Antes de perguntar consulte o manual
http://pgdocptbr.sourceforge.net/

Para editar suas opções ou sair da lista acesse a página da lista em:
http://pgfoundry.org/mailman/listinfo/brasil-usuarios

Responder a