pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: A.M. <agentm@cmu.edu>
To: pgsql-sql@postgresql.org
Date: Fri, 29 Nov 2002 22:50:27 -0500
Message-ID: <DCD7116F-0416-11D7-98F3-0030657192DA@cmu.edu> (raw)

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
agentm@cmu.edu





view thread (3+ messages)  latest in thread

Message-ID: <DCD7116F-0416-11D7-98F3-0030657192DA@cmu.edu>
Permalink:  ../DCD7116F-0416-11D7-98F3-0030657192DA@cmu.edu/
Also on:    postgresql.org/message-id/DCD7116F-0416-11D7-98F3-0030657192DA@cmu.edu

 · 

reply

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: agentm@cmu.edu
  Subject: Re: 
  In-Reply-To: <DCD7116F-0416-11D7-98F3-0030657192DA@cmu.edu>

* 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