crie o campo da tabela projeto q referencia a tb_centro_custo como integer ao inves de serial Em Terça 30 Janeiro 2007 15:07, Milena Leite escreveu: > Gente, > > Estou aprendendo PostgreSQL e gostaria de saber o porque desse erro. > > > Tenho duas tabelas com os seguintes dados: > > tb_centro_custo > > id_centro_custo | nm_centro_custo | > ------------------------------------ > 1 desenvolvimento > 2 administrativo > 3 financeiro > > > tb_projeto > > id_projeto | nm_projeto | id_centro_custo | > ------------------------------------------- > 1 Sistema PHP 1 > 2 Automação 2 > > > > Elas foram criadas da seguinte forma: > > CREATE TABLE tb_centro_custo(id_centro_custo SERIAL NOT NULL, > nm_centro_custo varchar(80), PRIMARY KEY(id_centro_custo))"); > > > CREATE TABLE tb_projeto(id_projeto SERIAL NOT NULL, nm_projeto varchar(80), > id_centro_custo SERIAL REFERENCES tb_centro_custo, PRIMARY > KEY(id_projeto))"); > > > > O QUE FIZ DE ERRADO !? > > Obrigada, > > > > > *Warning*: pg_query() > [function.pg-query<http://192.168.0.29/teste/SISTEMA/function.pg-query>]: > Query failed: ERROR: insert or update on table "tb_projeto" violates > foreign key constraint "tb_projeto_id_centro_custo_fkey" DETAIL: Key > (id_centro_custo)=(10) is not present in table "tb_centro_custo". in * > D:\Inetpub\teste\SISTEMA\inserir_dados.php* on line *42* _______________________________________________ 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
