I have a reference which is guaranteed not to have a valid reference
(preferably NULL) until it is processed later. How can I defer a
reference entry so that both NULL and an actual reference are valid in
the reference field? The processing which I speak of takes place later
and not in the same transaction (thus making DEFERRABLE useless,
right?). A solution I thought of is to forget keys and just make it an
INT8 since I am also guaranteed that its referenced item is never
deleted. But certainly, there is a more reliable way to do it, right?
In summary, what I want is
field INT8 REFERENCES sometable NULL OK
or
field INT8 CHECK(SELECT id FROM someothertable WHERE field=id)
(can I do this? this allows NULL right?)
The rule is ref2 can either be a valid reference or NULL.
CREATE TABLE thetable(
ref2 INT8 REFERENCES someothertable,
...
);
Thanks for any help.
><><><><><><><><><
AgentM
[EMAIL PROTECTED]
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
- [SQL] Wallingford, Ted
- Re: [SQL] Bruce Momjian
- [SQL] Ricardo Javier Aranibar León
- Re: [SQL] Richard Huxton
- [SQL] Luis Mix
- [SQL] John Geng
- [SQL] dnaren
- Re: [SQL] Richard Huxton
- [SQL] sun yu
- Re: [SQL] Tomasz Myrta
- Re: [SQL] A.M.
- Re: [SQL] Tom Lane
- Re: [SQL] A.M.
- [SQL] Backup to data base how ? ksql
- Re: [SQL] Backup to data base how ? Frank Bax
- [SQL] Bruce Becker
- [SQL] mail.luckydigital.com
- Re: [SQL] PL/pgSQL question Josh Berkus
- Re: [SQL] Oliver Elphick
- Re: [SQL] Tomasz Myrta
- [SQL] Tilo Schwarz