| From: | Richard Huxton <dev(at)archonet(dot)com> |
|---|---|
| To: | Patrice OLIVER <oliverp21(at)free(dot)fr> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: Problem with stored procedure |
| Date: | 2004-08-26 13:31:36 |
| Message-ID: | 412DE638.7010207@archonet.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Antonis Antoniou | 2004-08-26 14:59:10 | Re: Problem with stored procedure |
| Previous Message | Patrice OLIVER | 2004-08-26 13:07:09 | Problem with stored procedure |