From: Richard Huxton <dev@archonet.com>
To: Patrice OLIVER <oliverp21@free.fr>
Cc: pgsql-sql@postgresql.org
Subject: Re: Problem with stored procedure
Date: Thu, 26 Aug 2004 14:31:36 +0100
Message-ID: <412DE638.7010207@archonet.com> (raw)
In-Reply-To: <412DE07D.1060800@free.fr>
References: <412DE07D.1060800@free.fr>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, oliverp21@free.fr
Subject: Re: Problem with stored procedure
In-Reply-To: <412DE638.7010207@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox