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: Stored Procedures and temp tables
- In-Reply-To: caw@gtech.com's message of Thu, 21 Jan 1993 18:20:32 GMT
- Message-ID: <WFINNERT.93Jan22092800@larry.shearson.com>
- Sender: news@shearson.com (News)
- Organization: Lehman Brothers
- References: <wolfgang.727637656@sfu.ca> <1993Jan21.182032.23975@gtech.com>
- Date: Fri, 22 Jan 1993 14:28:00 GMT
- Lines: 62
-
- In article <1993Jan21.182032.23975@gtech.com> caw@gtech.com (Christopher A. White) writes:
-
- > [ I don't know if any of you have had a hard time figuring out
- > how to do this, but we did for some reason, so I figured I post
- > a copy of my internal note. If you didn't already know this,
- > it can save you a lot of code and make things easier.]
- >
- > Here is a little programming tidbit: #temp tables created in a
- > stored procedure are visible to stored procedures call by the
- > creator. So, if procedure a creates #techs and then calls
- > procedure b, b can use, access, update, etc. #techs.
- >
- > The problem we've always had is that the called procedure (b,
- > in this example) could not be created. However, I have come
- > up with a way to do so. It requires adding some code to the
- > procedure creation script [our scripts have a section at the top
- > that drops the procedure if it already exists, then the creation
- > script itself. Since they are isql scripts, each section is
- > terminated with a "go"].
- >
- > Since we know what proc b exepects to be in the temp table,
- > we can put the temp table creation clauses in the section
- > between the drop procedure and the create procedure, like this:
- >
- > If exists (select * from sysobjects ... etc
- > drop procedure b
- > go
- >
- > select * into #techs from techs where 1 = 2
- > go
- >
- > create table #display as (disp_line char(80) )
- > go
- >
- > create procedure b as
- > .
- > .
- > .
- > go
- >
- > The #temp tables must be the SAME in both procedures (a and b).
-
- CAUTION:
-
- I use this technique for some items that really *have* to be done
- this way, however....
-
- There have been cases where if a index that a child proc uses is dropped
- the proc refuses ( is unable ) to recompile itself and gives a nasty
- message until reloaded ( 4.0.1 EBF726 )
-
- > Topher
- > --
- > Christopher A. White | Free Radical Programming
- > caw@gtech.com | High combat Rock'n'Roll
- > GTech Corporation, West Greenwich, RI | Software - Break the rules
- > The opinions expressed are mine alone | and take no prisoners!
- --
- warren finnerty | 388 Greenwich St.
- Lehman Brothers | NYC NY 10013
- "Back off man!" | wfinnert@shearson.com
-
-