home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases.sybase
- Path: sparky!uunet!tekbspa!tssgate!esh
- From: esh@prague.tss.com (Edward S. Hirgelt)
- Subject: Re: Questions sbout time based queries
- In-Reply-To: jimj@meaddata.com's message of 8 Jan 1993 21:54:22 GMT
- Message-ID: <ESH.93Jan11095641@prague.tss.com>
- Sender: news@tss.com (USENET Network News)
- Organization: Teknekron Software Systems, Inc.
- References: <1ikt6eINNh61@meaddata.meaddata.com>
- Distribution: na
- Date: Mon, 11 Jan 1993 17:56:41 GMT
- Lines: 49
-
-
- 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:
-
- Jim> 1. Are timestamps the best way to go?
- Jim> (nice because they are automatic, bad because they can't be
- Jim> CONVERTed)
-
- Depending on what you haven't said about your requirements, I probably
- wouldn't use timestamps. They do get changed when someone updates the
- row. This may or may not be the same person who did the insert. You may
- or may not care. Also rows bcp'd in do not appear to get their
- timestamps set. Or rather, timestamps columns seme to be set to 0.
-
- I tend to use timestamps to notice when someone updated a row out from
- under a browse rather than for anything else. Perhaps this is too narrow
- a view for timestamps. My solution follows below:
-
- 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.
-
- Ed
- --
- Ex vitio alterius |Ed Hirgelt |esh@tss.com
- sapiens emendat suum. |Teknekron Software Systems, Inc|
- (Publilius Syrus) |Palo Alto, Ca. |
-