From: | Davi Leal <davi(at)leals(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Foreign Key: what value? |
Date: | 2006-07-05 15:19:26 |
Message-ID: | 200607051719.27466.davi@leals.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi,
How to know the value which I must set in the foreign key field?. I have two
tables:
CREATE TABLE AAAAAA (
Id SERIAL PRIMARY KEY,
data char(9)
);
CREATE TABLE BBBBBB (
BBBBBB_Id integer REFERENCES AAAAAA(Id) NOT NULL,
field char(5)
);
I insert a register on table AAAAAA,
INSERT INTO AAAAAA (data) VALUES ('123456789');
and then, I want to insert a related register in table BBBBBB, but I do not
know how get the proper value to the Foreign key BBBBBB_Id. Note that a lot of
client are inserting at the same time on the AAAAAA table, so I can not just
get the greater value of AAAAAA.Id
Maybe using transactions ?. Any tip, URI, ... will be welcome.
INSERT INTO BBBBBB (BBBBBB_Id, field) VALUES (??????,'12345');
Regards,
Davi
From | Date | Subject | |
---|---|---|---|
Next Message | A. Kretschmer | 2006-07-05 15:34:15 | Re: Foreign Key: what value? |
Previous Message | Rodrigo Sakai | 2006-07-04 16:59:56 | Null attributes |