X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7A28E5E46DC for ; Thu, 26 Aug 2004 10:31:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52409-07 for ; Thu, 26 Aug 2004 13:31:36 +0000 (GMT) Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net [194.217.242.89]) by svr1.postgresql.org (Postfix) with ESMTP id 31F9C5E3639 for ; Thu, 26 Aug 2004 10:31:34 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) id 1C0KLp-000HMO-0V; Thu, 26 Aug 2004 13:31:37 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 65DB1179E0; Thu, 26 Aug 2004 14:31:36 +0100 (BST) Message-ID: <412DE638.7010207@archonet.com> Date: Thu, 26 Aug 2004 14:31:36 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Patrice OLIVER Cc: pgsql-sql@postgresql.org Subject: Re: Problem with stored procedure References: <412DE07D.1060800@free.fr> In-Reply-To: <412DE07D.1060800@free.fr> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/290 X-Sequence-Number: 18787 Patrice OLIVER wrote: [snip] > create function insert_uv(varchar,varchar,varchar) returns integer as ' > declare > codeuv alias for $1; > codetype alias for $2; > libuv alias for $3; > cletype integer; > begin > select into cletype numtype(codeuv); > insert into uv values (codeuv, cletype, libuv); > return cletype; > end; > ' language 'plpgsql'; > > When I do : > > select insert_uv('SGBD','DUVC','TEST BD'); > I get the following message : > ERROR: insert or update on table "uv" violates foreign key constraint > "fk_uv_caracteri_type" > DETAIL: Key (typnum)=(43) is not present in table "types". > > I don't kown why. Before your "insert into" add: RAISE NOTICE ''cletype = %'', cletype; This will show what value cletype has. Presumably it's 43 and you don't have an equivalent row in "types". Or have I misunderstood the problem? -- Richard Huxton Archonet Ltd