Embedded SQL: foreign keys. - Mailing list pgsql-general

From TPCCUVA
Subject Embedded SQL: foreign keys.
Date
Msg-id 63f1a619fb.619fb63f1a@teleline.es
Whole thread Raw
Responses Re: Embedded SQL: foreign keys.  (Devrim GUNDUZ <devrim@oper.metu.edu.tr>)
List pgsql-general
Hi,

We have a problem with the next table declarations:


EXEC SQL CREATE TABLE table1(

    p1 int4,
    p2 varchar(10),
    p3 varchar(20),
    CONSTRAINT table1_1 PRIMARY KEY (p1)
);
EXEC SQL COMMIT;

EXEC SQL CREATE TABLE table2(
    s1 int4,
    s2 int4,
    s3 varchar(10),
    s4 varchar(20),
    CONSTRAINT table2_1 PRIMARY KEY (s2, s1),
    CONSTRAINT table2_2 FOREIGN KEY (S2) REFERENCES table1 (p1) DEFERRABLE
);
EXEC SQL COMMIT;

EXEC SQL CREATE TABLE table3 (
    x1 int4,
    x2 int4,
    x3 int4,
    x4 varchar(16),
    CONSTRAINT table3_1 PRIMARY KEY (x3, x2, x1),
    CONSTRAINT table3_2 FOREIGN KEY (x3) REFERENCES table2 (s1) DEFERRABLE
);
EXEC SQL COMMIT;

 After compile, when we run the program, we obtain the next error in the
third "COMMIT";

Err code: -400
    ERROR: UNIQUE constraint matching given keys for referenced table
"table2" not found.

We are using postgres 7.1.3, could you help us?

Thanks.



pgsql-general by date:

Previous
From: Devrim GUNDUZ
Date:
Subject: Re: About functions
Next
From: Lincoln Yeoh
Date:
Subject: Re: Need to vacuum multiple times for effectiveness?