home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / database / sybase / 727 < prev    next >
Encoding:
Text File  |  1993-01-23  |  2.7 KB  |  75 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: Stored Procedures and temp tables
  5. In-Reply-To: caw@gtech.com's message of Thu, 21 Jan 1993 18:20:32 GMT
  6. Message-ID: <WFINNERT.93Jan22092800@larry.shearson.com>
  7. Sender: news@shearson.com (News)
  8. Organization: Lehman Brothers
  9. References: <wolfgang.727637656@sfu.ca> <1993Jan21.182032.23975@gtech.com>
  10. Date: Fri, 22 Jan 1993 14:28:00 GMT
  11. Lines: 62
  12.  
  13. In article <1993Jan21.182032.23975@gtech.com> caw@gtech.com (Christopher A. White) writes:
  14.  
  15. >   [ I don't know if any of you have had a hard time figuring out
  16. >   how to do this, but we did for some reason, so I figured I post
  17. >   a copy of my internal note. If you didn't already know this,
  18. >   it can save you a lot of code and make things easier.]
  19. >
  20. >   Here is a little programming tidbit: #temp tables created in a
  21. >   stored procedure are visible to stored procedures call by the
  22. >   creator. So, if procedure a creates #techs and then calls 
  23. >   procedure b, b can use, access, update, etc. #techs.
  24. >
  25. >   The problem we've always had is that the called procedure (b,
  26. >   in this example) could not be created. However, I have come
  27. >   up with a way to do so. It requires adding some code to the
  28. >   procedure creation script [our scripts have a section at the top
  29. >   that drops the procedure if it already exists, then the creation
  30. >   script itself. Since they are isql scripts, each section is
  31. >   terminated with a "go"].
  32. >
  33. >   Since we know what proc b exepects to be in the temp table,
  34. >   we can put the temp table creation clauses in the section
  35. >   between the drop procedure and the create procedure, like this:
  36. >
  37. >   If exists (select * from sysobjects ... etc
  38. >      drop procedure b
  39. >   go
  40. >
  41. >   select * into #techs from techs where 1 = 2
  42. >   go
  43. >
  44. >   create table #display as (disp_line   char(80) )
  45. >   go
  46. >
  47. >   create procedure b as
  48. >   .
  49. >   .
  50. >   .
  51. >   go
  52. >
  53. >   The #temp tables must be the SAME in both procedures (a and b).
  54.  
  55. CAUTION:
  56.  
  57. I use this technique for some items that really *have* to be done
  58. this way, however....
  59.  
  60. There have been cases where if a index that a child proc uses is dropped
  61. the proc refuses ( is unable ) to recompile itself and gives a nasty
  62. message until reloaded ( 4.0.1 EBF726 )
  63.  
  64. >   Topher
  65. >   -- 
  66. >    Christopher A. White                    | Free Radical Programming
  67. >    caw@gtech.com                           |   High combat Rock'n'Roll 
  68. >    GTech Corporation, West Greenwich, RI   |      Software - Break the rules
  69. >    The opinions expressed are mine alone   |         and take no prisoners!
  70. --
  71. warren finnerty      | 388 Greenwich St.
  72. Lehman Brothers      | NYC NY 10013
  73. "Back off man!"      | wfinnert@shearson.com
  74.  
  75.