home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / database / sybase / 656 < prev    next >
Encoding:
Text File  |  1993-01-12  |  1.9 KB  |  58 lines

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