Skip site navigation (1) Skip section navigation (2)

Re: Novice Help Needed

From: "Robert B(dot) Easter" <reaster(at)comptechnews(dot)com>
To: "Brian C(dot) Doyle" <bcdoyle(at)mindspring(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Novice Help Needed
Date: 2000-05-18 19:27:56
Message-ID: 00051815354701.14806@comptechnews (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
On Thu, 18 May 2000, Brian C. Doyle wrote:
> Hello,
> I am in need of a rule or trigger that will only allow one entry where the 
> date and a userid field are the same?
> So on the insert I want it to first check and see if userid and date exist 
> and if so do not enter them.  If they do exist, allow the insert
> Brian C. Doyle

If I understand, maybe you can just make a composite primary key out of userid
and date.

CREATE TABLE  atable (
	userid	INTEGER,
	thedate	TIMESTAMP,
	PRIMARY KEY (userid, thedate)

 --  Robert B. Easter

In response to

pgsql-sql by date

Next:From: migDate: 2000-05-18 19:38:29
Subject: Re: SQL command speed
Previous:From: Kate CollinsDate: 2000-05-18 19:11:27
Subject: SQL command speed

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group