home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases.sybase
- Path: sparky!uunet!shearson.com!newshost!wfinnert
- From: wfinnert@larry.shearson.com (Warren Finnerty)
- Subject: Re: Questions sbout time based queries
- In-Reply-To: esh@prague.tss.com's message of Mon, 11 Jan 1993 17:56:41 GMT
- Message-ID: <WFINNERT.93Jan12151350@larry.shearson.com>
- Sender: news@shearson.com (News)
- Organization: Lehman Brothers
- References: <1ikt6eINNh61@meaddata.meaddata.com> <ESH.93Jan11095641@prague.tss.com>
- Distribution: na
- Date: Tue, 12 Jan 1993 20:13:50 GMT
- Lines: 44
-
- >In article <ESH.93Jan11095641@prague.tss.com> esh@prague.tss.com (Edward S. Hirgelt) writes:
-
- > On 8 Jan 1993 21:54:22 GMT,
- > jimj@meaddata.com (Jim Johnstone) said:
-
-
-
- > Jim> We have a need to query out all rows entered by a given user since
- > Jim> a specified time. My first thought was to use timestamp columns in
- > Jim> all tables. So (I am very new to Sybase, so please be nice) my
- > Jim> questions are:
-
- [ stuff deleted ]
-
- > Jim> 2. Should I just use datetime in each table?
- > Jim> ... insert TABLE values(..., getdate(), ...)
- > Jim> then
- > Jim> ... select * from TABLE where date > @threshold and user = @user
-
- > This is what I would do. However I would define a trigger that
- > automatically set the date field to the current date when the row is
- > inserted. This ensures that no one can subvert the dating mechanism. You
- > also get to decide what to do on updates.
-
- > Your select above works nicely.
-
- > Jim> 3. Is there some Sybase table/feature that will allow me to meet the
- > Jim> requirement directly?
-
- > See above -- triggers.
-
- > Hope this helps.
-
-
- If you are not too worried about people trying to subvert the timestamping...
- I would create a userdatatype called time_thingy_type as datetime and bind
- a default of getdate() to it. Can be much cheaper than triggers.
-
- Just my $.02
- --
- warren finnerty | 388 Greenwich St.
- Lehman Brothers | NYC NY 10013
- "Back off man!" | wfinnert@shearson.com
-
-