pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
(no subject)
3+ messages / 2 participants
[nested] [flat]

* (no subject)
@ 2002-11-30 03:50  A.M. <agentm@cmu.edu>
  0 siblings, 1 reply; 3+ messages in thread

From: A.M. @ 2002-11-30 03:50 UTC (permalink / raw)
  To: pgsql-sql

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





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re:
@ 2002-11-30 04:28  Tom Lane <tgl@sss.pgh.pa.us>
  parent: A.M. <agentm@cmu.edu>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2002-11-30 04:28 UTC (permalink / raw)
  To: A.M. <agentm@cmu.edu>; +Cc: pgsql-sql

"A.M." <agentm@cmu.edu> writes:
> In summary, what I want is

>   field INT8 REFERENCES sometable NULL OK

Er ... NULL *is* OK, unless you say

   field INT8 REFERENCES sometable NOT NULL

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re:
@ 2002-11-30 04:31  A.M. <agentm@cmu.edu>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: A.M. @ 2002-11-30 04:31 UTC (permalink / raw)
  To: pgsql-sql

Wow. That's a real head-slapper. Thanks for the quick answer!

On Friday, November 29, 2002, at 11:28  PM, Tom Lane wrote:

> "A.M." <agentm@cmu.edu> writes:
>> In summary, what I want is
>
>>   field INT8 REFERENCES sometable NULL OK
>
> Er ... NULL *is* OK, unless you say
>
>    field INT8 REFERENCES sometable NOT NULL
>
> 			regards, tom lane
>
>
 ><><><><><><><><><
AgentM
agentm@cmu.edu






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2002-11-30 04:31 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-11-30 03:50  A.M. <agentm@cmu.edu>
2002-11-30 04:28 ` Re: Tom Lane <tgl@sss.pgh.pa.us>
2002-11-30 04:31   ` Re: A.M. <agentm@cmu.edu>

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